mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 14:23:34 +01:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System.Collections;
|
|
using FluentAssertions;
|
|
using WireMock.Extensions;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Extensions;
|
|
|
|
public class DictionaryExtensionsTests
|
|
{
|
|
[Fact]
|
|
public void TryGetStringValue_WhenKeyExistsAndValueIsString_ReturnsTrueAndStringValue()
|
|
{
|
|
// Arrange
|
|
var dictionary = new Hashtable { { "key", "value" } };
|
|
|
|
// Act
|
|
var result = dictionary.TryGetStringValue("key", out var value);
|
|
|
|
// Assert
|
|
result.Should().BeTrue();
|
|
value.Should().Be("value");
|
|
}
|
|
|
|
[Fact]
|
|
public void TryGetStringValue_WhenKeyExistsAndValueIsNotString_ReturnsTrueAndStringValue()
|
|
{
|
|
// Arrange
|
|
var dictionary = new Hashtable { { "key", 123 } };
|
|
|
|
// Act
|
|
var result = dictionary.TryGetStringValue("key", out var value);
|
|
|
|
// Assert
|
|
result.Should().BeTrue();
|
|
value.Should().Be("123");
|
|
}
|
|
|
|
[Fact]
|
|
public void TryGetStringValue_WhenKeyDoesNotExist_ReturnsFalseAndNull()
|
|
{
|
|
// Arrange
|
|
var dictionary = new Hashtable { { "otherKey", "value" } };
|
|
|
|
// Act
|
|
var result = dictionary.TryGetStringValue("key", out var value);
|
|
|
|
// Assert
|
|
result.Should().BeFalse();
|
|
value.Should().BeNull();
|
|
}
|
|
} |