コード例 #1
0
        public void GetValueProvider_ReturnsValue_IfKeyIsPresent()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary<string, object>
            {
                { "test-key", "test-value" }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("test-key");

            // Assert
            Assert.Equal("test-value", (string)result);
        }
コード例 #2
0
        public void ContainsPrefix_ReturnsNullValue_IfKeyIsPresent()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary<string, object>
            {
                { "test-key", null }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("test-key");

            // Assert
            Assert.Equal(string.Empty, (string)result);
        }
コード例 #3
0
        public void ContainsPrefix_ReturnsNullValue_IfKeyIsPresent()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary <string, object>
            {
                { "test-key", null }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("test-key");

            // Assert
            Assert.Equal(string.Empty, (string)result);
        }
コード例 #4
0
        public void GetValueProvider_ReturnsNull_WhenKeyIsNotFound()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary<string, object>
            {
                { "test-key", "value" }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("not-test-key");

            // Assert
            Assert.Equal(ValueProviderResult.None, result);
        }
コード例 #5
0
        public void GetValueProvider_ReturnsValue_IfKeyIsPresent()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary <string, object>
            {
                { "test-key", "test-value" }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("test-key");

            // Assert
            Assert.Equal("test-value", (string)result);
        }
コード例 #6
0
        public void GetValueProvider_ReturnsNull_WhenKeyIsNotFound()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary <string, object>
            {
                { "test-key", "value" }
            });
            var provider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = provider.GetValue("not-test-key");

            // Assert
            Assert.Equal(ValueProviderResult.None, result);
        }
コード例 #7
0
        public void GetValue_DoesNotReturnAValue_ForAKeyPrefix()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary <string, object>
            {
                { "bar.baz", 2 },
            });

            var valueProvider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = valueProvider.GetValue("bar");

            // Assert
            Assert.Equal(ValueProviderResult.None, result);
        }
コード例 #8
0
        public void GetValue_ReturnsCorrectValue_ForKnownKeys(string prefix, string expectedValue)
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary <string, object>
            {
                { "bar", 1 },
                { "bar.baz", 2 },
            });

            var valueProvider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = valueProvider.GetValue(prefix);

            // Assert
            Assert.Equal(expectedValue, (string)result);
        }
コード例 #9
0
        public void GetValue_ReturnsCorrectValue_ForKnownKeys(string prefix, string expectedValue)
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary<string, object>
            {
                { "bar", 1 },
                { "bar.baz", 2 },
            });

            var valueProvider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = valueProvider.GetValue(prefix);

            // Assert
            Assert.Equal(expectedValue, (string)result);
        }
コード例 #10
0
        public void GetValue_DoesNotReturnAValue_ForAKeyPrefix()
        {
            // Arrange
            var values = new RouteValueDictionary(new Dictionary<string, object>
            {
                { "bar.baz", 2 },
            });

            var valueProvider = new RouteValueProvider(BindingSource.Query, values);

            // Act
            var result = valueProvider.GetValue("bar");

            // Assert
            Assert.Equal(ValueProviderResult.None, result);
        }