mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-17 07:36:47 +01:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
using FluentAssertions;
|
|
using WireMock.Util;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Util;
|
|
|
|
public class CultureInfoUtilsTests
|
|
{
|
|
[Theory]
|
|
[InlineData(null, typeof(CultureInfo))]
|
|
[InlineData("en-US", typeof(CultureInfo))]
|
|
[InlineData("fr-FR", typeof(CultureInfo))]
|
|
[InlineData("es-ES", typeof(CultureInfo))]
|
|
public void Parse_ValidInputs_ReturnsExpectedCultureInfo(string? value, Type expectedType)
|
|
{
|
|
// Act
|
|
var result = CultureInfoUtils.Parse(value);
|
|
|
|
// Assert
|
|
result.Should().BeOfType(expectedType);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("InvalidCulture")]
|
|
[InlineData("123456")]
|
|
public void Parse_InvalidInputs_ReturnsCurrentCulture(string? value)
|
|
{
|
|
// Arrange
|
|
var expectedCulture = CultureInfo.CurrentCulture;
|
|
|
|
// Act
|
|
var result = CultureInfoUtils.Parse(value);
|
|
|
|
// Assert
|
|
result.Should().Be(expectedCulture);
|
|
}
|
|
|
|
#if !NETSTANDARD1_3
|
|
[Fact]
|
|
public void Parse_IntegerInput_ReturnsExpectedCultureInfo()
|
|
{
|
|
// Arrange
|
|
string value = "1033"; // en-US culture identifier
|
|
var expectedCulture = new CultureInfo(1033);
|
|
|
|
// Act
|
|
var result = CultureInfoUtils.Parse(value);
|
|
|
|
// Assert
|
|
result.Should().Be(expectedCulture);
|
|
}
|
|
#endif
|
|
|
|
[Fact]
|
|
public void Parse_CurrentCultureInput_ReturnsCurrentCulture()
|
|
{
|
|
// Arrange
|
|
string value = nameof(CultureInfo.CurrentCulture);
|
|
var expectedCulture = CultureInfo.CurrentCulture;
|
|
|
|
// Act
|
|
var result = CultureInfoUtils.Parse(value);
|
|
|
|
// Assert
|
|
result.Should().Be(expectedCulture);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_InvariantCultureInput_ReturnsInvariantCulture()
|
|
{
|
|
// Arrange
|
|
string value = nameof(CultureInfo.InvariantCulture);
|
|
var expectedCulture = CultureInfo.InvariantCulture;
|
|
|
|
// Act
|
|
var result = CultureInfoUtils.Parse(value);
|
|
|
|
// Assert
|
|
result.Should().Be(expectedCulture);
|
|
}
|
|
} |