本文整理汇总了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);
}
示例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);
}
示例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");
}
示例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"));
}
示例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'");
}