public void Controller_View_WithoutParameter_SetsResultNullViewNameAndNullViewDataModelAndSameTempData() { // Arrange var controller = new TestableController() { ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()), TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>()), }; // Act var actualViewResult = controller.View(); // Assert Assert.IsType <ViewResult>(actualViewResult); Assert.Null(actualViewResult.ViewName); Assert.Same(controller.ViewData, actualViewResult.ViewData); Assert.Same(controller.TempData, actualViewResult.TempData); Assert.Null(actualViewResult.ViewData.Model); }
public void Controller_View_WithoutParameter_SetsResultNullViewNameAndNullViewDataModelAndSameTempData() { // Arrange var controller = new TestableController() { ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()), TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of<ITempDataProvider>()), }; // Act var actualViewResult = controller.View(); // Assert Assert.IsType<ViewResult>(actualViewResult); Assert.Null(actualViewResult.ViewName); Assert.Same(controller.ViewData, actualViewResult.ViewData); Assert.Same(controller.TempData, actualViewResult.TempData); Assert.Null(actualViewResult.ViewData.Model); }
public void Controller_View_WithParameterViewNameAndViewModel_SetsResultViewNameAndViewDataModelAndSameTempData() { // Arrange var controller = new TestableController() { ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()), TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>()), }; var model = new object(); // Act var actualViewResult = controller.View("CustomViewName", model); // Assert Assert.IsType <ViewResult>(actualViewResult); Assert.Equal("CustomViewName", actualViewResult.ViewName); Assert.Same(controller.ViewData, actualViewResult.ViewData); Assert.Same(controller.TempData, actualViewResult.TempData); Assert.Same(model, actualViewResult.ViewData.Model); }
public void Controller_View_WithNullModelParameter_OverwritesViewDataModel() { // Arrange var controller = new TestableController() { ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()), TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>()), }; controller.ViewData.Model = new object(); // Act var actualViewResult = controller.View(model: null); // Assert Assert.IsType <ViewResult>(actualViewResult); Assert.Null(actualViewResult.ViewName); Assert.Same(controller.ViewData, actualViewResult.ViewData); Assert.Same(controller.TempData, actualViewResult.TempData); Assert.Null(actualViewResult.ViewData.Model); }
public void Controller_View_WithParameterViewNameAndViewModel_SetsResultViewNameAndViewDataModelAndSameTempData() { // Arrange var controller = new TestableController() { ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()), TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of<ITempDataProvider>()), }; var model = new object(); // Act var actualViewResult = controller.View("CustomViewName", model); // Assert Assert.IsType<ViewResult>(actualViewResult); Assert.Equal("CustomViewName", actualViewResult.ViewName); Assert.Same(controller.ViewData, actualViewResult.ViewData); Assert.Same(controller.TempData, actualViewResult.TempData); Assert.Same(model, actualViewResult.ViewData.Model); }