Наследование: RevisableEntity
 public void HasGetSet()
 {
     var value = new Person();
     var entity = new InstitutionalAgreementContact { Person = value };
     entity.ShouldNotBeNull();
     entity.Person.ShouldEqual(value);
 }
Пример #2
0
            public void MapsEmails_OrderingByValue_AfterDefaultAndConfirmed()
            {
                var entity = new Person
                {
                    Emails = new[]
                    {
                        new EmailAddress { IsConfirmed = false, Value = "*****@*****.**" },
                        new EmailAddress { IsConfirmed = false, Value = "*****@*****.**" },
                        new EmailAddress { IsConfirmed = false, Value = "*****@*****.**" },
                        new EmailAddress { IsConfirmed = true, Value = "*****@*****.**" },
                        new EmailAddress { IsConfirmed = true, Value = "*****@*****.**" },
                        new EmailAddress { IsDefault = true, Value = "*****@*****.**"},
                    }
                };

                var model = Mapper.Map<MyHomeInfo>(entity);

                model.ShouldNotBeNull();
                model.Emails.Length.ShouldEqual(6);
                model.Emails.First().IsDefault.ShouldBeTrue();
                model.Emails.First().Value.ShouldEqual("*****@*****.**");
                model.Emails.Skip(1).First().IsConfirmed.ShouldBeTrue();
                model.Emails.Skip(1).First().Value.ShouldEqual("*****@*****.**");
                model.Emails.Skip(2).First().IsConfirmed.ShouldBeTrue();
                model.Emails.Skip(2).First().Value.ShouldEqual("*****@*****.**");
                model.Emails.Skip(3).First().IsConfirmed.ShouldBeFalse();
                model.Emails.Skip(3).First().Value.ShouldEqual("*****@*****.**");
                model.Emails.Skip(4).First().IsConfirmed.ShouldBeFalse();
                model.Emails.Skip(4).First().Value.ShouldEqual("*****@*****.**");
                model.Emails.Skip(5).First().IsConfirmed.ShouldBeFalse();
                model.Emails.Skip(5).First().Value.ShouldEqual("*****@*****.**");
            }
            public void CreatesAffiliation_WithEstablishmentId()
            {
                Affiliation outEntity = null;
                const int personId = 13;
                const int establishmentId = 13;
                var person = new Person
                {
                    RevisionId = personId,
                };
                var command = new CreateAffiliationCommand
                {
                    PersonId = personId,
                    EstablishmentId = establishmentId,
                };
                var entities = new Mock<ICommandEntities>(MockBehavior.Strict).Initialize();
                entities.Setup(m => m.Get<Person>()).Returns(new[] { person }.AsQueryable);
                entities.Setup(m => m.Create(It.Is(AffiliationBasedOn(command))))
                    .Callback((Entity entity) => outEntity = (Affiliation)entity);
                var handler = new CreateAffiliationHandler(entities.Object);

                handler.Handle(command);

                outEntity.ShouldNotBeNull();
                outEntity.EstablishmentId.ShouldEqual(command.EstablishmentId);
            }
Пример #4
0
            public void InitializesCollection_ForMessages()
            {
                var person = new Person();

                person.ShouldNotBeNull();
                person.Messages.ShouldNotBeNull();
                person.Messages.Count.ShouldEqual(0);
            }
Пример #5
0
            public void HasGetSet()
            {
                var value = new User();
                var entity = new Person { User = value };
                entity.ShouldNotBeNull();
                entity.User.ShouldEqual(value);

            }
Пример #6
0
            public void InitializesCollection_ForAffiliations()
            {
                var person = new Person();

                person.ShouldNotBeNull();
                person.Affiliations.ShouldNotBeNull();
                person.Affiliations.Count.ShouldEqual(0);
            }
Пример #7
0
            public void MapsIsDisplayNameDerived()
            {
                var entity = new Person { IsDisplayNameDerived = true };

                var model = Mapper.Map<UpdateNameForm>(entity);

                model.ShouldNotBeNull();
                model.IsDisplayNameDerived.ShouldBeTrue();
            }
Пример #8
0
            public void MapsSalutation()
            {
                const string value = "test";
                var entity = new Person { Salutation = value };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.Salutation.ShouldNotBeNull();
                model.Salutation.ShouldEqual(entity.Salutation);
            }
Пример #9
0
            public void MapsLastName()
            {
                const string value = "test";
                var entity = new Person { LastName = value };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.LastName.ShouldNotBeNull();
                model.LastName.ShouldEqual(entity.LastName);
            }
Пример #10
0
            public void MapsSuffix()
            {
                const string value = "test";
                var entity = new Person { Suffix = value };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.Suffix.ShouldNotBeNull();
                model.Suffix.ShouldEqual(entity.Suffix);
            }
Пример #11
0
            public void MapsMiddleName()
            {
                const string value = "test";
                var entity = new Person { MiddleName = value };

                var model = Mapper.Map<UpdateNameForm>(entity);

                model.ShouldNotBeNull();
                model.MiddleName.ShouldNotBeNull();
                model.MiddleName.ShouldEqual(entity.MiddleName);
            }
Пример #12
0
            public void MapsEntityId()
            {
                var value = Guid.NewGuid();
                var entity = new Person { EntityId = value };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.EntityId.ShouldNotEqual(Guid.Empty);
                model.EntityId.ShouldEqual(entity.EntityId);
            }
Пример #13
0
            public void ReturnsExistingAffiliation_WhenAlreadyAffiliated()
            {
                var establishment = new Establishment();
                var affiliation = new Affiliation { Establishment = establishment };
                var person = new Person
                {
                    Affiliations = new List<Affiliation> { affiliation }
                };

                var result = person.AffiliateWith(establishment);

                result.ShouldEqual(affiliation);
            }
Пример #14
0
        public static bool ValueMatchesPerson(string value, IQueryEntities entities,
            IEnumerable<Expression<Func<Person, object>>> eagerLoad, out Person person)
        {
            if (entities == null)
            {
                person = null;
                return false;
            }

            person = entities.Query<Person>().EagerLoad(entities, eagerLoad).ByEmail(value);

            // return true (valid) if there is an entity
            return person != null;
        }
Пример #15
0
        public static bool IdMatchesEntity(int id, IQueryEntities entities,
            IEnumerable<Expression<Func<Person, object>>> eagerLoad, out Person entity)
        {
            if (id < 0)
            {
                entity = null;
                return false;
            }

            entity = entities.Query<Person>()
                .EagerLoad(entities, eagerLoad).By(id);

            // return true (valid) if there is an entity
            return entity != null;
        }
            public void ExecutesCreate_OnAffiliationEntity()
            {
                const int personId = 13;
                var person = new Person { RevisionId = personId, };
                var command = new CreateAffiliationCommand
                {
                    PersonId = personId,
                };
                var entities = new Mock<ICommandEntities>(MockBehavior.Strict).Initialize();
                entities.Setup(m => m.Get<Person>()).Returns(new[] { person }.AsQueryable);
                entities.Setup(m => m.Create(It.Is(AffiliationBasedOn(command))));
                var handler = new CreateAffiliationHandler(entities.Object);

                handler.Handle(command);

                entities.Verify(m => m.Create(It.Is(AffiliationBasedOn(command))), Times.Once());
            }
Пример #17
0
            public void MapsEmails_OrderingConfirmed_AboveOthers()
            {
                var entity = new Person
                {
                    Emails = new[]
                    {
                        new EmailAddress { IsConfirmed = false },
                        new EmailAddress { IsConfirmed = false },
                        new EmailAddress { IsConfirmed = true },
                    }
                };

                var model = Mapper.Map<MyHomeInfo>(entity);

                model.ShouldNotBeNull();
                model.Emails.Length.ShouldEqual(3);
                model.Emails.First().IsConfirmed.ShouldBeTrue();
            }
Пример #18
0
            public void MapsEmails_OrderingDefaultAtTop()
            {
                var entity = new Person
                {
                    Emails = new[]
                    {
                        new EmailAddress { IsDefault = false },
                        new EmailAddress { IsDefault = false },
                        new EmailAddress { IsDefault = true },
                    }
                };

                var model = Mapper.Map<MyHomeInfo>(entity);

                model.ShouldNotBeNull();
                model.Emails.Length.ShouldEqual(3);
                model.Emails.First().IsDefault.ShouldBeTrue();
            }
Пример #19
0
            public void MapsDefaultEmail_ToNull_WhenPersonEmails_IsNull()
            {
                var entity = new Person();

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.DefaultEmail.ShouldBeNull();
            }
Пример #20
0
 public static bool IsNotAlreadyAffiliatedWithEstablishment(Person person, int establishmentId)
 {
     // return true (valid) if person does not have matching affiliation
     return person != null && person.GetAffiliation(establishmentId) == null;
 }
Пример #21
0
 public static bool IdMatchesEntity(int id, IQueryEntities entities, out Person entity)
 {
     return IdMatchesEntity(id, entities, null, out entity);
 }
            public void CreatesAffiliation_WithNotIsDefault_WhenPersonAlreadyHasDefaultAffiliation()
            {
                Affiliation outEntity = null;
                const int personId = 13;
                var person = new Person
                {
                    RevisionId = personId,
                    Affiliations = new Collection<Affiliation>
                    {
                        new Affiliation { IsDefault = true, }
                    }
                };
                var command = new CreateAffiliationCommand
                {
                    PersonId = personId,
                };
                var entities = new Mock<ICommandEntities>(MockBehavior.Strict).Initialize();
                entities.Setup(m => m.Get<Person>()).Returns(new[] { person }.AsQueryable);
                entities.Setup(m => m.Create(It.Is(AffiliationBasedOn(command))))
                    .Callback((Entity entity) => outEntity = (Affiliation)entity);
                var handler = new CreateAffiliationHandler(entities.Object);

                handler.Handle(command);

                outEntity.ShouldNotBeNull();
                outEntity.IsDefault.ShouldBeFalse();
            }
Пример #23
0
 public static bool UserIsNotNull(Person entity)
 {
     return entity != null && entity.User != null;
 }
Пример #24
0
            public void MapsDefaultEmail_ToNull_WhenPersonEmails_ContainsNoDefaultEmail()
            {
                var entity = new Person
                {
                    Emails = new[]
                    {
                        new EmailAddress(),
                        new EmailAddress(),
                        new EmailAddress(),
                    }
                };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.DefaultEmail.ShouldBeNull();
            }
Пример #25
0
            public void MapsDefaultEmail_ToDefaultEmail_WhenPersonEmails_ContainsDefaultEmail()
            {
                const string value = "*****@*****.**";
                var entity = new Person
                {
                    Emails = new[]
                    {
                        new EmailAddress(),
                        new EmailAddress
                        {
                            IsDefault = true,
                            Value = value,
                        },
                        new EmailAddress(),
                    }
                };

                var model = Mapper.Map<PersonInfoModel>(entity);

                model.ShouldNotBeNull();
                model.DefaultEmail.ShouldNotBeNull();
                model.DefaultEmail.ShouldEqual(value);
            }
Пример #26
0
 public static bool ValueMatchesPerson(string value, IQueryEntities entities, out Person person)
 {
     return ValueMatchesPerson(value, entities, null, out person);
 }
 internal ScenarioOptions(SendConfirmEmailMessageCommand command)
 {
     Command = command;
     Person = new Person
     {
         RevisionId = 6,
         Emails = new[]
         {
             new EmailAddress
             {
                 Value = command.EmailAddress,
             },
         },
     };
     EmailMessage = new EmailMessage
     {
         ToPerson = Person,
         Number = 7,
     };
     EmailTemplate = new EmailTemplate();
 }
Пример #28
0
 internal static EmailMessage GetMessage(this Person owner, int number)
 {
     return owner != null
         ? owner.Messages.ByNumber(number)
         : null;
 }
Пример #29
0
            public void HasGetSet()
            {
                var value = new List<Affiliation> { new Affiliation(), new Affiliation() };
                var entity = new Person { Affiliations = value };
                entity.ShouldNotBeNull();
                entity.Affiliations.ShouldEqual(value);

            }
Пример #30
0
 internal static Affiliation GetAffiliation(this Person owner, int establishmentId)
 {
     return owner.Affiliations.ByEstablishmentId(establishmentId);
 }
Пример #31
0
            public void HasGetSet()
            {
                var value = new List<EmailAddress> { new EmailAddress(), new EmailAddress() };
                var entity = new Person { Emails = value };
                entity.ShouldNotBeNull();
                entity.Emails.ShouldEqual(value);

            }
Пример #32
0
 public void HasGetSet()
 {
     var value = new EmailMessage[] { };
     var entity = new Person { Messages = value };
     entity.ShouldNotBeNull();
     entity.Messages.ShouldEqual(value);
     entity.Messages.Count.ShouldEqual(0);
 }