public void GivenPhoneCommunication_WhenDeriving_ThenRequiredRelationsMustExist() { var receiver = new PersonBuilder(this.Session).WithLastName("receiver").Build(); var caller = new PersonBuilder(this.Session).WithLastName("caller").Build(); this.Session.Derive(); this.Session.Commit(); var builder = new PhoneCommunicationBuilder(this.Session); builder.WithToParty(receiver); builder.WithFromParty(caller); builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithSubject("Phonecall"); var communication = builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); Assert.Equal(communication.CommunicationEventState, new CommunicationEventStates(this.Session).Scheduled); Assert.Equal(communication.CommunicationEventState, communication.LastCommunicationEventState); }
public void GivenPhoneCommunication_WhenDeriving_ThenRequiredRelationsMustExist() { var builder = new PhoneCommunicationBuilder(this.DatabaseSession); var communication = builder.Build(); this.DatabaseSession.Derive(); Assert.IsTrue(communication.Strategy.IsDeleted); this.DatabaseSession.Rollback(); builder.WithSubject("Phonecall"); communication = builder.Build(); this.DatabaseSession.Derive(); Assert.IsTrue(communication.Strategy.IsDeleted); this.DatabaseSession.Rollback(); builder.WithReceiver(new PersonBuilder(this.DatabaseSession).WithLastName("receiver").Build()); builder.WithCaller(new PersonBuilder(this.DatabaseSession).WithLastName("caller").Build()); communication = builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); Assert.AreEqual(communication.CurrentCommunicationEventStatus.CommunicationEventObjectState, new CommunicationEventObjectStates(this.DatabaseSession).Scheduled); Assert.AreEqual(communication.CurrentObjectState, new CommunicationEventObjectStates(this.DatabaseSession).Scheduled); Assert.AreEqual(communication.CurrentObjectState, communication.LastObjectState); }
public static PhoneCommunicationBuilder WithDefaults(this PhoneCommunicationBuilder @this, Organisation internalOrganisation) { var faker = @this.Session.Faker(); var administrator = (Person) new UserGroups(@this.Session).Administrators.Members.First; @this.WithDescription(faker.Lorem.Sentence(20)); @this.WithSubject(faker.Lorem.Sentence(5)); @this.WithFromParty(internalOrganisation.ActiveEmployees.First); @this.WithToParty(internalOrganisation.ActiveCustomers.First); @this.WithEventPurpose(new CommunicationEventPurposes(@this.Session).Meeting); @this.WithOwner(administrator); @this.WithActualStart(DateTime.UtcNow); return(@this); }