当前位置: 首页>>代码示例>>C#>>正文


C# TempDataDictionary.Load方法代码示例

本文整理汇总了C#中TempDataDictionary.Load方法的典型用法代码示例。如果您正苦于以下问题:C# TempDataDictionary.Load方法的具体用法?C# TempDataDictionary.Load怎么用?C# TempDataDictionary.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TempDataDictionary的用法示例。


在下文中一共展示了TempDataDictionary.Load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TempData_Load_CreatesEmptyDictionaryIfProviderReturnsNull

        public void TempData_Load_CreatesEmptyDictionaryIfProviderReturnsNull()
        {
            // Arrange
            var tempData = new TempDataDictionary(GetHttpContextAccessor(), new NullTempDataProvider());

            // Act
            tempData.Load();

            // Assert
            Assert.Empty(tempData);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:11,代码来源:TempDataDictionaryTest.cs

示例2: TempDataDictionaryCreatesEmptyDictionaryIfProviderReturnsNull

        public void TempDataDictionaryCreatesEmptyDictionaryIfProviderReturnsNull()
        {
            // Arrange
            TempDataDictionary tempDataDictionary = new TempDataDictionary();
            NullTempDataProvider provider = new NullTempDataProvider();

            // Act
            tempDataDictionary.Load(null /* controllerContext */, provider);

            // Assert
            Assert.AreEqual(tempDataDictionary.Count, 0);
        }
开发者ID:davidalmas,项目名称:Samples,代码行数:12,代码来源:TempDataDictionaryTest.cs

示例3: TempDataSavedWhenControllerThrows

        public void TempDataSavedWhenControllerThrows() {
            // Arrange
            BrokenController controller = new BrokenController() { ValidateRequest = false };
            Mock<HttpContextBase> mockContext = HttpContextHelpers.GetMockHttpContext();
            HttpSessionStateBase session = GetEmptySession();
            mockContext.Setup(o => o.Session).Returns(session);
            RouteData rd = new RouteData();
            rd.Values.Add("action", "Crash");
            controller.ControllerContext = new ControllerContext(mockContext.Object, rd, controller);

            // Assert
            ExceptionHelper.ExpectException<InvalidOperationException>(
                delegate {
                    ((IController)controller).Execute(controller.ControllerContext.RequestContext);
                });
            Assert.AreNotEqual(mockContext.Object.Session[SessionStateTempDataProvider.TempDataSessionStateKey], null);
            TempDataDictionary tempData = new TempDataDictionary();
            tempData.Load(controller.ControllerContext, controller.TempDataProvider);
            Assert.AreEqual(tempData["Key1"], "Value1");
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:20,代码来源:ControllerTest.cs

示例4: TempData_LoadAndSaveAreCaseInsensitive

        public void TempData_LoadAndSaveAreCaseInsensitive()
        {
            // Arrange
            var data = new Dictionary<string, object>();
            data["Foo"] = "Foo";
            data["Bar"] = "Bar";
            var provider = new TestTempDataProvider(data);
            var tempData = new TempDataDictionary(GetHttpContextAccessor(), provider);

            // Act
            tempData.Load();
            var value = tempData["FOO"];
            tempData.Save();

            // Assert
            Assert.False(tempData.ContainsKey("foo"));
            Assert.True(tempData.ContainsKey("bar"));
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:18,代码来源:TempDataDictionaryTest.cs

示例5: LoadAndSaveAreCaseInsensitive

        public void LoadAndSaveAreCaseInsensitive() {
            // Arrange
            Dictionary<string, object> data = new Dictionary<string, object>();
            data["Foo"] = "Foo";
            data["Bar"] = "Bar";
            TestTempDataProvider provider = new TestTempDataProvider(data);
            Mock<ControllerContext> controllerContext = new Mock<ControllerContext>();
            TempDataDictionary tempData = new TempDataDictionary();

            // Act
            tempData.Load(controllerContext.Object, provider);
            object value = tempData["FOO"];
            tempData.Save(controllerContext.Object, provider);

            // Assert
            Assert.IsFalse(tempData.ContainsKey("foo"), "tempData should not contain 'Foo'");
            Assert.IsTrue(tempData.ContainsKey("bar"), "tempData should contain 'Bar'");
        }
开发者ID:consumentor,项目名称:Server,代码行数:18,代码来源:TempDataDictionaryTest.cs


注:本文中的TempDataDictionary.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。