예제 #1
0
        public void IsReadOnlyTest()
        {
            // Given
            var sut = new ReadOnlyDictionaryValuesAdapter <int, string, int>(new Dictionary <int, int>(),
                                                                             v => v.ToString(CultureInfo.InvariantCulture));

            // When
            var result = ((ICollection <KeyValuePair <int, string> >)sut).IsReadOnly;

            // Then
            result.Should().BeTrue();
        }
예제 #2
0
        public void ContainsShouldReturnFalseIfNotContainsTest(int key)
        {
            // Given
            var sut = new ReadOnlyDictionaryValuesAdapter <int, string?, int>(
                new Dictionary <int, int> {
                { 0, 0 }
            },
                v => v.ToString(CultureInfo.InvariantCulture));

            // When
            var result =
                ((ICollection <KeyValuePair <int, string?> >)sut).Contains(new KeyValuePair <int, string?>(key, null));

            // Then
            result.Should().BeFalse();
        }
예제 #3
0
        public void TryGetValueTest(int key, bool expectedResult, string expectedValue)
        {
            // Given
            var sut = new ReadOnlyDictionaryValuesAdapter <int, string, int>(
                new Dictionary <int, int> {
                { 0, 1 }
            },
                v => v.ToString(CultureInfo.InvariantCulture));

            // When
            var result = sut.TryGetValue(key, out var value);

            // Then
            using (new AssertionScope())
            {
                result.Should().Be(expectedResult);
                value.Should().Be(expectedValue);
            }
        }