public void Should_GoToDetailsViewAndCallSaveMethodOfIRepository_WhenRequestedEditWith2Parameters() { // arrange var savedClient = new Person { Id = 1, Role = PersonRole.Client }; var repository = Substitute.For<IRepository>(); var clientController = new ClientsController(repository); // act var viewResult = clientController.Edit(1, savedClient); // assert //viewResult.ViewName.Should().Be("Details"); repository.Received().Save(savedClient); }
public void ShouldNot_ReturnNullAnd_ShouldCallMethodGetOfIRepository_WhenRequestedEditWith1Parameter() { // arrange var returnedClient = new Person { Id = 3, Role = PersonRole.Client }; var repository = Substitute.For<IRepository>(); repository.Get<Person>(3).Returns(returnedClient); var clientController = new ClientsController(repository); // act var viewModel = clientController.Edit(3).Model as Person; // assert viewModel.Should().NotBeNull(); repository.Received().Get<Person>(3); }