public void it_should_not_map_deleted_properties_to_the_director_or_partner_view_model()
        {
            var input = new DirectorOrPartner();

            AddPersonData(input);

            foreach (var restraintOrder in input.RestraintOrders)
            {
                restraintOrder.Deleted = true;
            }

            foreach (var unspentConviction in input.UnspentConvictions)
            {
                unspentConviction.Deleted = true;
            }

            foreach (var offenceAwaitingTrial in input.OffencesAwaitingTrial)
            {
                offenceAwaitingTrial.Deleted = true;
            }

            var result = this.mapper.Map <DirectorOrPartnerViewModel>(input);

            Assert.AreEqual(0, result.RestraintOrdersViewModel.RestraintOrders.Count());
            Assert.AreEqual(0, result.UnspentConvictionsViewModel.UnspentConvictions.Count());
            Assert.AreEqual(0, result.OffencesAwaitingTrialViewModel.OffencesAwaitingTrial.Count());
        }
        public void it_should_map_the_is_previous_authority_view_model_to_the_director_or_partner_entity()
        {
            var input = new IsPreviousPrincipalAuthorityViewModel {
                IsPreviousPrincipalAuthority = true
            };
            var result = new DirectorOrPartner();

            this.mapper.Map(input, result);

            Assert.IsNotNull(result.IsPreviousPrincipalAuthority);
            Assert.AreEqual(true, result.IsPreviousPrincipalAuthority);
        }
        public void it_should_not_map_a_deleted_director_or_partner_entity_to_the_director_or_partner_collection_view_model()
        {
            var input  = new List <DirectorOrPartner>();
            var person = new DirectorOrPartner {
                Deleted = true
            };

            input.Add(person);

            var result = this.mapper.Map <DirectorOrPartnerCollectionViewModel>(input);

            Assert.AreEqual(0, result.DirectorsOrPartners.Count());
        }
예제 #4
0
        public void it_unlinks_the_principal_authority_from_a_director()
        {
            const int dopId = 1;
            var       dop   = new DirectorOrPartner {
                Id = dopId, PrincipalAuthority = new PrincipalAuthority()
            };

            repository.GetById <DirectorOrPartner>(dopId).Returns(dop);

            var pdh = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider);

            pdh.UnlinkPrincipalAuthorityFromDirectorOrPartner(dopId);

            repository.Received(1).Upsert(Arg.Is <DirectorOrPartner>(d => d.PrincipalAuthority == null));
        }
예제 #5
0
        public void Validate()
        {
            OrganisationDetails?.Validate();
            PrincipalAuthority?.Validate();
            AlternativeBusinessRepresentatives?.Validate();
            DirectorOrPartner?.Validate();
            NamedIndividuals?.Validate();
            Organisation?.Validate();

            IsValid = OrganisationDetails != null && OrganisationDetails.IsValid &&
                      PrincipalAuthority != null && PrincipalAuthority.IsValid &&
                      AlternativeBusinessRepresentatives != null && AlternativeBusinessRepresentatives.IsValid &&
                      DirectorOrPartner != null && DirectorOrPartner.IsValid &&
                      NamedIndividuals != null && NamedIndividuals.IsValid &&
                      Organisation != null && Organisation.IsValid;
        }
        public void it_should_map_the_director_or_partner_entity_to_the_director_or_partner_view_model()
        {
            var input = new DirectorOrPartner
            {
                IsPreviousPrincipalAuthority = true
            };

            AddPersonData(input);

            var result = this.mapper.Map <DirectorOrPartnerViewModel>(input);

            AssertPerson(input, result);

            Assert.AreEqual(input.IsPreviousPrincipalAuthority, result.IsPreviousPrincipalAuthority.IsPreviousPrincipalAuthority);
            Assert.AreEqual(input.RequiresVisa, result.RightToWorkViewModel.RequiresVisa);
            Assert.AreEqual(input.VisaDescription, result.RightToWorkViewModel.VisaDescription);
        }
        public void it_should_map_director_or_partner_entities_and_principal_authority_entities_to_the_director_or_partner_collection_view_model()
        {
            var dop = new DirectorOrPartner();

            AddPersonData(dop);

            var pa = new PrincipalAuthority();

            AddPersonData(pa);
            pa.IsDirector = true;

            var input = new Licence
            {
                DirectorOrPartners = new List <DirectorOrPartner>
                {
                    dop
                },
                PrincipalAuthorities = new List <PrincipalAuthority>
                {
                    pa
                },
                NumberOfDirectorsOrPartners = 1
            };

            var output = new DirectorOrPartnerCollectionViewModel();
            var result = this.mapper.Map(input, output);

            Assert.AreEqual(1, result.NumberOfDirectorsOrPartners);

            foreach (var dopVm in result.DirectorsOrPartners)
            {
                AssertPerson(dop, dopVm);
                Assert.AreEqual(dop.RequiresVisa, dopVm.RightToWorkViewModel.RequiresVisa);
                Assert.AreEqual(dop.VisaDescription, dopVm.RightToWorkViewModel.VisaDescription);
            }
        }
        public static bool HasPrincipalAuthoritySelected(DirectorOrPartner directorOrPartner)
        {
            var hasPrincipalAuthoritySelected = directorOrPartner?.Licence?.DirectorOrPartners?.Any(x => x.IsPreviousPrincipalAuthority.HasValue && x.IsPreviousPrincipalAuthority.Value);

            return(hasPrincipalAuthoritySelected ?? false);
        }
 public static IsPreviousPrincipalAuthorityViewModel IsPreviousPrincipalAuthorityResolver(DirectorOrPartner dop)
 {
     return(new IsPreviousPrincipalAuthorityViewModel
     {
         IsPreviousPrincipalAuthority = dop.IsPreviousPrincipalAuthority,
         YesNo = YesNoList
     });
 }