public void CanSaveOrUpdateValidPublisher() { // Establish Context Publisher validPublisher = PublisherInstanceFactory.CreateValidTransientPublisher(); // Act ActionConfirmation confirmation = publisherManagementService.SaveOrUpdate(validPublisher); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(validPublisher); }
public void CanShowPublisher() { // Establish Context Publisher publisher = PublisherInstanceFactory.CreateValidTransientPublisher(); publisherManagementService.Expect(r => r.Get(1)) .Return(publisher); // Act ViewResult result = publishersController.Show(1).AssertViewRendered(); // Assert result.ViewData.Model.ShouldNotBeNull(); (result.ViewData.Model as Publisher).ShouldNotBeNull(); (result.ViewData.Model as Publisher).ShouldEqual(publisher); }
public void CanGetPublisher() { // Establish Context Publisher publisherToExpect = PublisherInstanceFactory.CreateValidTransientPublisher(); publisherRepository.Expect(r => r.Get(1)) .Return(publisherToExpect); // Act Publisher publisherRetrieved = publisherManagementService.Get(1); // Assert publisherRetrieved.ShouldNotBeNull(); publisherRetrieved.ShouldEqual(publisherToExpect); }
public void CanCreateFormViewModelForPublisher() { // Establish Context PublisherFormViewModel viewModelToExpect = new PublisherFormViewModel(); Publisher publisher = PublisherInstanceFactory.CreateValidTransientPublisher(); publisherRepository.Expect(r => r.Get(1)) .Return(publisher); // Act PublisherFormViewModel viewModelRetrieved = publisherManagementService.CreateFormViewModelFor(1); // Assert viewModelRetrieved.ShouldNotBeNull(); viewModelRetrieved.Publisher.ShouldNotBeNull(); viewModelRetrieved.Publisher.ShouldEqual(publisher); }
public void CanGetAllPublishers() { // Establish Context IList <Publisher> publishersToExpect = new List <Publisher>(); Publisher publisher = PublisherInstanceFactory.CreateValidTransientPublisher(); publishersToExpect.Add(publisher); publisherRepository.Expect(r => r.GetAll()) .Return(publishersToExpect); // Act IList <Publisher> publishersRetrieved = publisherManagementService.GetAll(); // Assert publishersRetrieved.ShouldNotBeNull(); publishersRetrieved.Count.ShouldEqual(1); publishersRetrieved[0].ShouldNotBeNull(); publishersRetrieved[0].ShouldEqual(publisher); }
public void CanUpdateWithValidPublisherFromForm() { // Establish Context Publisher validPublisherFromForm = PublisherInstanceFactory.CreateValidTransientPublisher(); // Intentionally empty to ensure successful transfer of values Publisher publisherFromDb = new Publisher(); publisherRepository.Expect(r => r.Get(1)) .Return(publisherFromDb); // Act ActionConfirmation confirmation = publisherManagementService.UpdateWith(validPublisherFromForm, 1); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(publisherFromDb); confirmation.Value.ShouldEqual(validPublisherFromForm); }