public void ShouldRemoveDataIfNotOfCorrectType() { // arrange ActionExecutingContext context = new ActionExecutingContext(); MockController c = new MockController(); context.Controller = c; c.TempData["Test"] = "DataValue"; MockImportAttribute attr = new MockImportAttribute("Test", typeof(int)); // act attr.OnActionExecuting(context); // assert Assert.AreEqual(null, attr.Model); Assert.IsFalse(c.TempData.ContainsKey("Test")); }
public void ShouldImportDataIfOfCorrectType() { // arrange ActionExecutingContext context = new ActionExecutingContext(); MockController c = new MockController(); context.Controller = c; c.TempData["Test"] = "DataValue"; MockImportAttribute attr = new MockImportAttribute("Test", typeof(string)); // act attr.OnActionExecuting(context); // assert Assert.AreNotEqual(null, attr.Model); Assert.AreEqual("DataValue", (string)attr.Model); }