public void TryMap_Should_Return_False_If_Mapping_Not_Defined() { var mappings = new ValueMappingCollection(); mappings.TryMap(1, typeof(string), out var destinationValue).Should().BeFalse(); mappings.Add(2, "two"); mappings.TryMap(1, typeof(string), out destinationValue).Should().BeFalse(); }
public void Clear_Should_Clear_The_Collection() { var mappings = new ValueMappingCollection(); mappings.Add(1, "one"); mappings.TryMap(1, typeof(string), out var destinationValue).Should().BeTrue(); destinationValue.Should().Be("one"); mappings.Clear(); mappings.TryMap(1, typeof(string), out destinationValue).Should().BeFalse(); }
public void TryMap_Should_Use_The_Given_Comparer() { var mappings = new ValueMappingCollection(); mappings.Add("a", 1); mappings.Add("A", 101); mappings.Add("b", 2, StringComparer.OrdinalIgnoreCase); mappings.TryMap("a", typeof(int), out var destinationValue).Should().BeTrue(); destinationValue.Should().Be(1); mappings.TryMap("A", typeof(int), out destinationValue).Should().BeTrue(); destinationValue.Should().Be(101); mappings.TryMap("b", typeof(int), out destinationValue).Should().BeTrue(); destinationValue.Should().Be(2); mappings.TryMap("B", typeof(int), out destinationValue).Should().BeTrue(); destinationValue.Should().Be(2); }
public void TryMap_Should_Use_Last_Defined_Mapping() { var mappings = new ValueMappingCollection(); mappings.Add(1, "one"); mappings.Add(1, "uno"); mappings.TryMap(1, typeof(string), out var destinationValue).Should().BeTrue(); destinationValue.Should().Be("uno"); }
public void TryMap_Should_Return_True_If_Mapping_Defined() { var mappings = new ValueMappingCollection(); mappings.Add(1, "one"); mappings.Add(2, "two"); mappings.TryMap(2, typeof(string), out var destinationValue).Should().BeTrue(); destinationValue.Should().Be("two"); }