public void CanSaveOrUpdateValidAgency() { // Establish Context Agency validAgency = AgencyInstanceFactory.CreateValidTransientAgency(); // Act ActionConfirmation confirmation = _agencyManagementService.SaveOrUpdate(validAgency); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(validAgency); }
public void CanShowAgency() { // Establish Context Agency agency = AgencyInstanceFactory.CreateValidTransientAgency(); _agencyManagementService.Expect(r => r.Get(1)) .Return(agency); // Act ViewResult result = _agenciesController.Show(1).AssertViewRendered(); // Assert result.ViewData.Model.ShouldNotBeNull(); (result.ViewData.Model as Agency).ShouldNotBeNull(); (result.ViewData.Model as Agency).ShouldEqual(agency); }
public void CanGetAgency() { // Establish Context Agency agencyToExpect = AgencyInstanceFactory.CreateValidTransientAgency(); _agencyRepository.Expect(r => r.Get(1)) .Return(agencyToExpect); // Act Agency agencyRetrieved = _agencyManagementService.Get(1); // Assert agencyRetrieved.ShouldNotBeNull(); agencyRetrieved.ShouldEqual(agencyToExpect); }
public void CanCreateFormViewModelForAgency() { // Establish Context var viewModelToExpect = new AgencyFormViewModel(); Agency agency = AgencyInstanceFactory.CreateValidTransientAgency(); _agencyRepository.Expect(r => r.Get(1)) .Return(agency); // Act AgencyFormViewModel viewModelRetrieved = _agencyManagementService.CreateFormViewModelFor(1); // Assert viewModelRetrieved.ShouldNotBeNull(); viewModelRetrieved.Agency.ShouldNotBeNull(); viewModelRetrieved.Agency.ShouldEqual(agency); }
public void CanUpdateWithValidAgencyFromForm() { // Establish Context Agency validAgencyFromForm = AgencyInstanceFactory.CreateValidTransientAgency(); // Intentionally empty to ensure successful transfer of values var agencyFromDb = new Agency(); _agencyRepository.Expect(r => r.Get(1)) .Return(agencyFromDb); // Act ActionConfirmation confirmation = _agencyManagementService.UpdateWith(validAgencyFromForm, 1); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(agencyFromDb); confirmation.Value.ShouldEqual(validAgencyFromForm); }
public void CanGetAllAgencies() { // Establish Context IList <Agency> agenciesToExpect = new List <Agency>(); Agency agency = AgencyInstanceFactory.CreateValidTransientAgency(); agenciesToExpect.Add(agency); _agencyRepository.Expect(r => r.GetAll()) .Return(agenciesToExpect); // Act IList <Agency> agenciesRetrieved = _agencyManagementService.GetAll(); // Assert agenciesRetrieved.ShouldNotBeNull(); agenciesRetrieved.Count.ShouldEqual(1); agenciesRetrieved[0].ShouldNotBeNull(); agenciesRetrieved[0].ShouldEqual(agency); }