public void GetValueProvider() { // Arrange Dictionary <string, object> backingStore = new Dictionary <string, object>( StringComparer.OrdinalIgnoreCase ) { { "foo", "fooValue" }, { "bar.baz", "barBazValue" } }; MockSessionState session = new MockSessionState(backingStore); Mock <ControllerContext> mockControllerContext = new Mock <ControllerContext>(); mockControllerContext.Setup(o => o.HttpContext.Session).Returns(session); SessionValueProviderFactory factory = new SessionValueProviderFactory(); // Act IValueProvider provider = factory.GetValueProvider(mockControllerContext.Object); // Assert Assert.True(provider.ContainsPrefix("bar")); Assert.Equal("fooValue", provider.GetValue("foo").AttemptedValue); Assert.Equal(CultureInfo.InvariantCulture, provider.GetValue("foo").Culture); }
public void GetValueProvider() { // Arrange Dictionary<string, object> backingStore = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase) { { "foo", "fooValue" }, { "bar.baz", "barBazValue" } }; MockSessionState session = new MockSessionState(backingStore); Mock<ControllerContext> mockControllerContext = new Mock<ControllerContext>(); mockControllerContext.Setup(o => o.HttpContext.Session).Returns(session); SessionValueProviderFactory factory = new SessionValueProviderFactory(); // Act IValueProvider provider = factory.GetValueProvider(mockControllerContext.Object); // Assert Assert.True(provider.ContainsPrefix("bar")); Assert.Equal("fooValue", provider.GetValue("foo").AttemptedValue); Assert.Equal(CultureInfo.InvariantCulture, provider.GetValue("foo").Culture); }