public void ShouldMakeNewParentAddressIfNoneExists()
        {
            var source = new EditableParentAddressModelBuilder().WithAddress("123 Model Rd").Build();
            var target = new ParentBuilder().Build();
            var mapper = new EditableParentAddressModelToParentMapper();
            mapper.Map(source, target);

            target.ParentAddresses.First().StreetNumberName.ShouldBe(source.Address);
            target.ParentAddresses.First().ApartmentRoomSuiteNumber.ShouldBe(source.Address2);
            target.ParentAddresses.First().City.ShouldBe(source.City);
            target.ParentAddresses.First().PostalCode.ShouldBe(source.PostalCode);
            target.ParentAddresses.First().StateAbbreviationTypeId.ShouldBe((int)source.State);
        }
        public void ShouldMapStudentToProfileModelWithDifferentParentAddress()
        {
            SetupWithDownloaderReturning("");

            var parent = new ParentBuilder().WithAddress().WithPhoneNumber().Build();
            var student = new StudentBuilder().WithParent(parent, false).Build();
            var profileModel = new ProfileModel();

            _mapper.Map(student, profileModel);

            NativeStudentPropertiesShouldBeMapped(student, profileModel);
            NativeParentPropertiesShouldBeMapped(parent, profileModel.EditProfileParentModel);
            ParentAddressShouldBeMapped(parent, profileModel);
            StudentParentAssociationShouldBeMapped(student, profileModel);
        }
示例#3
0
        public StudentBuilder WithParent(Parent parent=null, bool livesWith = true)
        {
            if (parent == null)
                parent = new ParentBuilder().WithAddress().WithPhoneNumber().Build();

            var studentParentAssociation = new StudentParentAssociation
            {
                RelationTypeId = PrimaryParentRelationType,
                LivesWith = livesWith,
                Parent = parent,
            };

            _studentParentAssociations.Add(studentParentAssociation);
            parent.StudentParentAssociations.Add(studentParentAssociation);
            return this;
        }
        public void GetByUSIShouldReturnFirstMatchingParentWithDependencies()
        {
            var mockDbContext = new Mock<INglDbContext>();
            var repo = new ParentRepository(mockDbContext.Object);
            const int parentUSI = 3;
            var parentBuilder = new ParentBuilder();
            var parents = new List<Parent> { parentBuilder.WithUSI(1).Build(), parentBuilder.WithUSI(parentUSI).Build(), parentBuilder.WithUSI(2).Build() }.AsQueryable();
            var mockSet = new Mock<IDbSet<Parent>>();
            mockSet.As<IQueryable<Parent>>().Setup(m => m.Provider).Returns(parents.Provider);
            mockSet.As<IQueryable<Parent>>().Setup(m => m.Expression).Returns(parents.Expression);
            mockDbContext.Setup(dbContext => dbContext.Set<Parent>()).Returns(mockSet.Object);

            var returnedParent = repo.GetByUSI(parentUSI);

            Assert.Equal(parentUSI, returnedParent.ParentUSI);
        }
        public void ShouldNotCreateEmailIfNoEmailExistedButBlankEmailInEditProfileModel()
        {
            var entity = new ParentBuilder().WithPhoneNumber().Build();
            entity.StudentParentAssociations.Add(new StudentParentAssociation());
            var model = new EditProfileParentModelBuilder().WithBlankEmail().Build();
            var mapper = new EditProfileParentModelToParentMapper(new EditableParentAddressModelToParentMapper());

            mapper.Map(model, entity);

            entity.FirstName.ShouldBe(model.FirstName);
            entity.LastSurname.ShouldBe(model.LastName);
            entity.ParentElectronicMails.ShouldBeEmpty();
            entity.ParentTelephones.First().TelephoneNumber.ShouldBe(model.TelephoneNumber);
            entity.ParentTelephones.First().TelephoneNumberTypeId.ShouldBe((int)TelephoneNumberTypeEnum.Emergency1);
            entity.SexTypeId.ShouldBe((int)model.Sex);
        }
        public void ShouldMap()
        {
            var entity = new ParentBuilder().WithEmail().WithPhoneNumber().Build();
            entity.StudentParentAssociations.Add(new StudentParentAssociation());
            var model = new EditProfileParentModelBuilder().Build();
            var mapper = new EditProfileParentModelToParentMapper(new EditableParentAddressModelToParentMapper());

            mapper.Map(model, entity);

            entity.FirstName.ShouldBe(model.FirstName);
            entity.LastSurname.ShouldBe(model.LastName);
            entity.ParentElectronicMails.First().ElectronicMailAddress.ShouldBe(model.EmailAddress);
            entity.ParentElectronicMails.First().ElectronicMailTypeId.ShouldBe((int)ElectronicMailTypeEnum.HomePersonal);
            entity.ParentTelephones.First().TelephoneNumber.ShouldBe(model.TelephoneNumber);
            entity.ParentTelephones.First().TelephoneNumberTypeId.ShouldBe((int) TelephoneNumberTypeEnum.Emergency1);
            entity.SexTypeId.ShouldBe((int) model.Sex);
        }
示例#7
0
        public StudentBuilder WithParent(Parent parent = null, bool livesWith = true)
        {
            if (parent == null)
            {
                parent = new ParentBuilder().WithAddress().WithPhoneNumber().Build();
            }

            var studentParentAssociation = new StudentParentAssociation
            {
                RelationTypeId = PrimaryParentRelationType,
                LivesWith      = livesWith,
                Parent         = parent,
            };

            _studentParentAssociations.Add(studentParentAssociation);
            parent.StudentParentAssociations.Add(studentParentAssociation);
            return(this);
        }