public void Accepts_Null() { var viewPage = new AutoTypeViewPageTestingSubclass <TestViewData>(); viewPage.SetViewData(null); Assert.IsNull(viewPage.ViewData.Model); }
public void Accepts_Correct_Type_Without_Conversion() { var viewPage = new AutoTypeViewPageTestingSubclass <TestViewData>(); var data = new TestViewData(); viewPage.SetViewData(new ViewDataDictionary(data)); Assert.AreSame(data, viewPage.ViewData.Model, "ViewData was not set without conversion"); }
public void Accepts_IDictionary() { var viewPage = new AutoTypeViewPageTestingSubclass <TestViewData>(); var data = new ViewDataDictionary(); var uriValue = new Uri("http://www.google.com/"); data["StringValue"] = "hello"; data["BoolValue"] = true; data["UriValue"] = uriValue; data["NonExistentValue"] = new object(); viewPage.SetViewData(data); Assert.AreEqual("hello", viewPage.ViewData.Model.StringValue); Assert.AreEqual(true, viewPage.ViewData.Model.BoolValue); Assert.AreSame(uriValue, viewPage.ViewData.Model.UriValue); }
public void Accepts_Anonymous_Type() { var viewPage = new AutoTypeViewPageTestingSubclass <TestViewData>(); var uriValue = new Uri("http://www.google.com/"); viewPage.SetViewData(new ViewDataDictionary(new { StringValue = "nice", BoolValue = true, UriValue = uriValue, SomeOtherValue = new object(), SomeRandomNullValue = (object)null })); Assert.AreEqual("nice", viewPage.ViewData.Model.StringValue); Assert.AreEqual(true, viewPage.ViewData.Model.BoolValue); Assert.AreSame(uriValue, viewPage.ViewData.Model.UriValue); }