Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }