Exemplo n.º 1
0
        public void CreateAgency_NullAgencyType_CreatesAnAgency()
        {
            var agencyRepository = new Mock<IAgencyRepository>();
            var agencyFactory = new AgencyFactory(agencyRepository.Object);

            AgencyProfile agencyProfileWithoutAgencyType = new AgencyProfileBuilder().WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfileWithoutAgencyType);
        }
Exemplo n.º 2
0
        public void CreateAgency_NullAgencyType_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);

            AgencyProfile agencyProfileWithoutAgencyType = new AgencyProfileBuilder().WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfileWithoutAgencyType);
        }
Exemplo n.º 3
0
        public void CreateAgency_WhitespaceLegalName_CreatesAnAgency()
        {
            var agencyRepository = new Mock<IAgencyRepository>();
            var agencyFactory = new AgencyFactory(agencyRepository.Object);
            var agencyType = new Mock<AgencyType>();

            AgencyProfile agencyProfileWithWhitespaceLegalName =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName("   "));

            agencyFactory.CreateAgency(agencyProfileWithWhitespaceLegalName);
        }
Exemplo n.º 4
0
        public void CreateAgency_WhitespaceLegalName_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var agencyType       = new Mock <AgencyType>();

            AgencyProfile agencyProfileWithWhitespaceLegalName =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName("   "));

            agencyFactory.CreateAgency(agencyProfileWithWhitespaceLegalName);
        }
Exemplo n.º 5
0
        public void CreateAgency_WithValidArguments_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var agencyType       = new Mock <AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            var agency = agencyFactory.CreateAgency(agencyProfile);

            Assert.IsNotNull(agency);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A <see cref="Agatha.Common.Response"/></returns>
        public override Response Handle(CreateNewAgencyRequest request)
        {
            var legalName     = request.AgencyName;
            var agencyType    = _mappingHelper.MapLookupField <AgencyType> (request.AgencyType);
            var agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType).WithAgencyName(
                    new AgencyNameBuilder().WithLegalName(legalName).Build());

            var agency    = _agencyFactory.CreateAgency(agencyProfile);
            var agencyDto = Mapper.Map <Agency, AgencyDisplayNameDto> (agency);

            var response = CreateTypedResponse();

            response.DataTransferObject = agencyDto;

            return(response);
        }
Exemplo n.º 7
0
        public void CreateAgency_WithValidArguments_AgencyIsMadePersistent()
        {
            bool isPersistent = false;

            var agencyRepository = new Mock <IAgencyRepository>();

            agencyRepository.Setup(a => a.MakePersistent(It.IsAny <Agency>())).Callback(() => isPersistent = true);
            var agencyFactory = new AgencyFactory(agencyRepository.Object);

            var agencyType = new Mock <AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfile);

            Assert.IsTrue(isPersistent);
        }
Exemplo n.º 8
0
        public void CreateAgency_WithValidArguments_AgencyIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var agencyRepository = new Mock<IAgencyRepository>();
                var agencyFactory = new AgencyFactory(agencyRepository.Object);
                var agencyType = new Mock<AgencyType>();

                AgencyProfile agencyProfileWithoutDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

                var agency = agencyFactory.CreateAgency(agencyProfileWithoutDisplayName);

                AgencyProfile agencyProfileWithDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(LegalName).WithDisplayName("My Agency Display Name"));

                agency.ReviseAgencyProfile(agencyProfileWithDisplayName);
            }
        }
Exemplo n.º 9
0
        public void CreateAgency_WithValidArguments_AgencyIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var agencyRepository = new Mock <IAgencyRepository>();
                var agencyFactory    = new AgencyFactory(agencyRepository.Object);
                var agencyType       = new Mock <AgencyType>();

                AgencyProfile agencyProfileWithoutDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

                var agency = agencyFactory.CreateAgency(agencyProfileWithoutDisplayName);

                AgencyProfile agencyProfileWithDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(LegalName).WithDisplayName("My Agency Display Name"));

                agency.ReviseAgencyProfile(agencyProfileWithDisplayName);
            }
        }
Exemplo n.º 10
0
        public void CreateAgency_WithValidArguments_AgencyIsMadePersistent()
        {
            bool isPersistent = false;

            var agencyRepository = new Mock<IAgencyRepository>();

            agencyRepository.Setup(a => a.MakePersistent(It.IsAny<Agency>())).Callback(() => isPersistent = true);
            var agencyFactory = new AgencyFactory(agencyRepository.Object);

            var agencyType = new Mock<AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfile);

            Assert.IsTrue(isPersistent);
        }
Exemplo n.º 11
0
        public void CreateAgency_WithValidArguments_CreatesAnAgency()
        {
            var agencyRepository = new Mock<IAgencyRepository>();
            var agencyFactory = new AgencyFactory(agencyRepository.Object);
            var agencyType = new Mock<AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            var agency = agencyFactory.CreateAgency(agencyProfile);

            Assert.IsNotNull(agency);
        }