public void HasGetSet() { var value = new Person(); var entity = new InstitutionalAgreementContact { Person = value }; entity.ShouldNotBeNull(); entity.Person.ShouldEqual(value); }
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); }
public void InitializesCollection_ForMessages() { var person = new Person(); person.ShouldNotBeNull(); person.Messages.ShouldNotBeNull(); person.Messages.Count.ShouldEqual(0); }
public void HasGetSet() { var value = new User(); var entity = new Person { User = value }; entity.ShouldNotBeNull(); entity.User.ShouldEqual(value); }
public void InitializesCollection_ForAffiliations() { var person = new Person(); person.ShouldNotBeNull(); person.Affiliations.ShouldNotBeNull(); person.Affiliations.Count.ShouldEqual(0); }
public void MapsIsDisplayNameDerived() { var entity = new Person { IsDisplayNameDerived = true }; var model = Mapper.Map<UpdateNameForm>(entity); model.ShouldNotBeNull(); model.IsDisplayNameDerived.ShouldBeTrue(); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
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()); }
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(); }
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(); }
public void MapsDefaultEmail_ToNull_WhenPersonEmails_IsNull() { var entity = new Person(); var model = Mapper.Map<PersonInfoModel>(entity); model.ShouldNotBeNull(); model.DefaultEmail.ShouldBeNull(); }
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; }
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(); }
public static bool UserIsNotNull(Person entity) { return entity != null && entity.User != null; }
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(); }
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); }
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(); }
internal static EmailMessage GetMessage(this Person owner, int number) { return owner != null ? owner.Messages.ByNumber(number) : null; }
public void HasGetSet() { var value = new List<Affiliation> { new Affiliation(), new Affiliation() }; var entity = new Person { Affiliations = value }; entity.ShouldNotBeNull(); entity.Affiliations.ShouldEqual(value); }
internal static Affiliation GetAffiliation(this Person owner, int establishmentId) { return owner.Affiliations.ByEstablishmentId(establishmentId); }
public void HasGetSet() { var value = new List<EmailAddress> { new EmailAddress(), new EmailAddress() }; var entity = new Person { Emails = value }; entity.ShouldNotBeNull(); entity.Emails.ShouldEqual(value); }
public void HasGetSet() { var value = new EmailMessage[] { }; var entity = new Person { Messages = value }; entity.ShouldNotBeNull(); entity.Messages.ShouldEqual(value); entity.Messages.Count.ShouldEqual(0); }