public void AddAdminField_post_updates_temp_data_and_redirects() { var expectedPromptModel = new AddAdminFieldViewModel(); var initialTempData = new AddAdminFieldData(expectedPromptModel); controller.TempData.Set(initialTempData); // When var result = controller.AddAdminField(1); // Then AssertAddTempDataIsExpected(expectedPromptModel); result.As <ViewResult>().Model.Should().BeOfType <AddAdminFieldViewModel>(); }
public void AddAdminField_save_redirects_to_index() { // Given var model = new AddAdminFieldViewModel(1, "Test"); const string action = "save"; var initialTempData = new AddAdminFieldTempData { AdminFieldId = model.AdminFieldId, OptionsString = model.OptionsString }; A.CallTo( () => multiPageFormService.GetMultiPageFormData <AddAdminFieldTempData>( MultiPageFormDataFeature.AddAdminField, controller.TempData ) ).Returns(initialTempData); A.CallTo( () => courseAdminFieldsService.AddAdminFieldToCourse( 100, 1, "Test" ) ).Returns(true); // When var result = controller.AddAdminField(100, model, action); // Then A.CallTo( () => multiPageFormService.ClearMultiPageFormData( MultiPageFormDataFeature.AddAdminField, controller.TempData ) ).MustHaveHappenedOnceExactly(); result.Should().BeRedirectToActionResult().WithActionName("Index"); }