Exemple #1
0
        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);
        }
Exemple #3
0
        public void GivenPhoneCommunicationIsBuild_WhenDeriving_ThenStatusIsSet()
        {
            var communication = new PhoneCommunicationBuilder(this.Session)
                                .WithSubject("Hello world!")
                                .WithOwner(new PersonBuilder(this.Session).WithLastName("owner").Build())
                                .WithFromParty(new PersonBuilder(this.Session).WithLastName("caller").Build())
                                .WithToParty(new PersonBuilder(this.Session).WithLastName("receiver").Build())
                                .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 GivenPhoneCommunicationIsBuild_WhenDeriving_ThenStatusIsSet()
        {
            var communication = new PhoneCommunicationBuilder(this.DatabaseSession)
                .WithSubject("Hello world!")
                .WithOwner(new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build())
                .WithCaller(new PersonBuilder(this.DatabaseSession).WithLastName("caller").Build())
                .WithReceiver(new PersonBuilder(this.DatabaseSession).WithLastName("receiver").Build())
                .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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public void GivenPhoneCommunication_WhenDeriving_ThenInvolvedPartiesAreDerived()
        {
            var owner    = new PersonBuilder(this.Session).WithLastName("owner").Build();
            var caller   = new PersonBuilder(this.Session).WithLastName("caller").Build();
            var receiver = new PersonBuilder(this.Session).WithLastName("receiver").Build();

            this.Session.Derive();
            this.Session.Commit();

            var communication = new PhoneCommunicationBuilder(this.Session)
                                .WithSubject("Hello world!")
                                .WithOwner(owner)
                                .WithFromParty(caller)
                                .WithToParty(receiver)
                                .Build();

            this.Session.Derive();

            Assert.Equal(3, communication.InvolvedParties.Count);
            Assert.Contains(owner, communication.InvolvedParties);
            Assert.Contains(caller, communication.InvolvedParties);
            Assert.Contains(receiver, communication.InvolvedParties);
        }
        public void GivenPhoneCommunication_WhenDeriving_ThenInvolvedPartiesAreDerived()
        {
            var owner = new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build();
            var caller = new PersonBuilder(this.DatabaseSession).WithLastName("caller").Build();
            var receiver = new PersonBuilder(this.DatabaseSession).WithLastName("receiver").Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var communication = new PhoneCommunicationBuilder(this.DatabaseSession)
                .WithSubject("Hello world!")
                .WithOwner(owner)
                .WithCaller(caller)
                .WithReceiver(receiver)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(3, communication.InvolvedParties.Count);
            Assert.Contains(owner, communication.InvolvedParties);
            Assert.Contains(caller, communication.InvolvedParties);
            Assert.Contains(receiver, communication.InvolvedParties);
        }