public void When_Robot_Does_Exist_View_Edit_Form() { // arrange var retrievedRobot = new Robot(); RobotRepository.Expect(call => call.Get(42)).Return(retrievedRobot); // act var actionResult = RobotController.Edit(42); // assert var viewModel = actionResult .AssertViewRendered() .WithViewData<Robot>(); Assert.That(viewModel, Is.SameAs(retrievedRobot)); }
public void Given_Good_Robot_Id_Redirected_To_Detail_View() { // arrange var robotResult = new Robot(); RobotRepository.Expect(call => call.Get(42)).Return(robotResult); // act var actionResult = RobotController.Details(42); // assert var viewData = actionResult .AssertViewRendered() .ForView("") .WithViewData<Robot>(); Assert.That(viewData, Is.SameAs(robotResult)); }
public ActionResult Edit(Robot robot) { robotRepository.Save(robot); return RedirectToAction<RobotController>(c => c.List()); }