Пример #1
0
        public void CantGetTheSameSectionTwice()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section", "key", "1");
            Assert.Equal("1", httpContext.GetDynamicSection("section"));
            Assert.Equal(string.Empty, httpContext.GetDynamicSection("section"));
        }
Пример #2
0
        public void SectionsAreNotRemoved()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section", "key", "1");
            Assert.Equal("1", httpContext.GetDynamicSection("*", remove: false));
            Assert.Equal("1", httpContext.GetDynamicSection("*", remove: true));
            Assert.Equal(string.Empty, httpContext.GetDynamicSection("section"));
        }
Пример #3
0
        public void RegistrationsShouldNotOverwritePreviousValuesWithTheSameKeyIfTheyAreInDistinctSections()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section1", "key", "1");
            httpContext.RegisterBlock("section2", "key", "2");
            Assert.Equal("1", httpContext.GetDynamicSection("section1"));
            Assert.Equal("2", httpContext.GetDynamicSection("section2"));
        }
Пример #4
0
        public void NullKeysAreConvertedToEmptyStringKeys()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section", key: null, content: "content");
            Assert.Equal("content", httpContext.GetDynamicSection("section"));
        }
Пример #5
0
        public void RegistrationsWithDistinctKeysAreStored()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section", "key1", "1");
            httpContext.RegisterBlock("section", "key2", "2");
            Assert.Equal("12", httpContext.GetDynamicSection("section"));
        }
Пример #6
0
        public void UsingAsteriskReturnsAllSectionsContents()
        {
            var httpContext = new DefaultHttpContext();

            httpContext.RegisterBlock("section1", "key1", "0");
            httpContext.RegisterBlock("section1", "key1", "1");
            httpContext.RegisterBlock("section1", "key2", "2");
            httpContext.RegisterBlock("section2", "key3", "3");
            Assert.Equal("123", httpContext.GetDynamicSection("*"));
        }
Пример #7
0
        public void EmptyStringIsReturnedIfNoBlockIsRegistered()
        {
            var httpContext = new DefaultHttpContext();

            Assert.Equal(string.Empty, httpContext.GetDynamicSection("*"));
        }