Esempio n. 1
0
        public void GivenLetterCorrespondenceIsBuild_WhenDeriving_ThenStatusIsSet()
        {
            var communication = new LetterCorrespondenceBuilder(this.Session)
                                .WithSubject("Hello world!")
                                .WithOwner(new PersonBuilder(this.Session).WithLastName("owner").Build())
                                .WithFromParty(new PersonBuilder(this.Session).WithLastName("originator").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);
        }
Esempio n. 2
0
        public void GivenLetterCorrespondenceIsBuild_WhenDeriving_ThenStatusIsSet()
        {
            var communication = new LetterCorrespondenceBuilder(this.DatabaseSession)
                .WithSubject("Hello world!")
                .WithOwner(new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build())
                .WithOriginator(new PersonBuilder(this.DatabaseSession).WithLastName("originator").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);
        }
Esempio n. 3
0
        public static LetterCorrespondenceBuilder WithDefaults(this LetterCorrespondenceBuilder @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);
        }
Esempio n. 4
0
        public void GivenLetterCorrespondence_WhenDeriving_ThenInvolvedPartiesAreDerived()
        {
            var owner      = new PersonBuilder(this.Session).WithLastName("owner").Build();
            var originator = new PersonBuilder(this.Session).WithLastName("originator").Build();
            var receiver   = new PersonBuilder(this.Session).WithLastName("receiver").Build();

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

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

            this.Session.Derive();

            Assert.Equal(3, communication.InvolvedParties.Count);
            Assert.Contains(owner, communication.InvolvedParties);
            Assert.Contains(originator, communication.InvolvedParties);
            Assert.Contains(receiver, communication.InvolvedParties);
        }
Esempio n. 5
0
        public void GivenLetterCorrespondence_WhenDeriving_ThenInvolvedPartiesAreDerived()
        {
            var owner = new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build();
            var originator = new PersonBuilder(this.DatabaseSession).WithLastName("originator").Build();
            var receiver = new PersonBuilder(this.DatabaseSession).WithLastName("receiver").Build();

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

            var communication = new LetterCorrespondenceBuilder(this.DatabaseSession)
                .WithSubject("Hello world!")
                .WithOwner(owner)
                .WithOriginator(originator)
                .WithReceiver(receiver)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(3, communication.InvolvedParties.Count);
            Assert.Contains(owner, communication.InvolvedParties);
            Assert.Contains(originator, communication.InvolvedParties);
            Assert.Contains(receiver, communication.InvolvedParties);
        }
Esempio n. 6
0
        public void Edit()
        {
            var organisations = new Organisations(this.Session).Extent();
            var organisation  = organisations.First(v => v.PartyName.Equals("Acme0"));

            var allors   = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA");
            var employee = allors.ActiveEmployees.First(v => v.FirstName.Equals("first"));

            var organisationAddress = new PostalAddressBuilder(this.Session)
                                      .WithAddress1("Haverwerf 15")
                                      .WithPostalBoundary(new PostalBoundaryBuilder(this.Session).WithLocality("city").WithPostalCode("1111").WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE")).Build())
                                      .Build();

            organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(this.Session).WithContactMechanism(organisationAddress).Build());

            var employeeAddress = new PostalAddressBuilder(this.Session)
                                  .WithAddress1("home sweet home")
                                  .WithPostalBoundary(new PostalBoundaryBuilder(this.Session).WithLocality("suncity").WithPostalCode("0000").WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE")).Build())
                                  .Build();

            employee.AddPartyContactMechanism(new PartyContactMechanismBuilder(this.Session).WithContactMechanism(employeeAddress).Build());

            var editCommunicationEvent = new LetterCorrespondenceBuilder(this.Session)
                                         .WithSubject("dummy")
                                         .WithFromParty(employee)
                                         .WithToParty(organisation)
                                         .WithPostalAddress(organisationAddress)
                                         .Build();

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

            var before = new LetterCorrespondences(this.Session).Extent().ToArray();

            var organisationOverviewPage = this.organisationListPage.Select(organisation);

            var page = organisationOverviewPage.SelectLetterCorrespondence(editCommunicationEvent);

            page.EventState.Set(new CommunicationEventStates(this.Session).InProgress.Name)
            .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment.Name)
            .FromParty.Set(organisation.PartyName)
            .ToParty.Set(employee.PartyName)
            .PostalAddress.Set("Haverwerf 15 1111 city Belgium")
            .Subject.Set("new subject")
            .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 23))
            .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23))
            .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 24))
            .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 24))
            .Comment.Set("new comment")
            .Save.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new LetterCorrespondences(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length);

            Assert.Equal(new CommunicationEventStates(this.Session).InProgress, editCommunicationEvent.CommunicationEventState);
            Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, editCommunicationEvent.EventPurposes);
            Assert.Equal(organisation, editCommunicationEvent.FromParty);
            Assert.Equal(employee, editCommunicationEvent.ToParty);
            Assert.Equal(organisationAddress, editCommunicationEvent.PostalAddress);
            Assert.Equal("new subject", editCommunicationEvent.Subject);
            //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date);
            //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date);
            //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date);
            //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date);
            Assert.Equal("new comment", editCommunicationEvent.Comment);
        }
        public void Edit()
        {
            var person = new People(this.Session).Extent().First;

            var allors   = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA");
            var employee = allors.ActiveEmployees.First();

            var address = new PostalAddressBuilder(this.Session)
                          .WithAddress1("Haverwerf 15")
                          .WithLocality("city")
                          .WithPostalCode("1111")
                          .WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE"))
                          .Build();

            person.AddPartyContactMechanism(new PartyContactMechanismBuilder(this.Session).WithContactMechanism(address).Build());

            var employeeAddress = new PostalAddressBuilder(this.Session)
                                  .WithAddress1("home sweet home")
                                  .WithLocality("suncity")
                                  .WithPostalCode("0000")
                                  .WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE"))
                                  .Build();

            employee.AddPartyContactMechanism(new PartyContactMechanismBuilder(this.Session).WithContactMechanism(employeeAddress).Build());

            var editCommunicationEvent = new LetterCorrespondenceBuilder(this.Session)
                                         .WithSubject("dummy")
                                         .WithFromParty(employee)
                                         .WithToParty(person)
                                         .WithPostalAddress(address)
                                         .Build();

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

            var before = new LetterCorrespondences(this.Session).Extent().ToArray();

            var postalAddress = (PostalAddress)person.PartyContactMechanisms.First(v => v.ContactMechanism.GetType().Name == typeof(PostalAddress).Name).ContactMechanism;

            this.personListPage.Table.DefaultAction(person);
            var personOverview = new PersonOverviewComponent(this.personListPage.Driver);

            var communicationEventOverview = personOverview.CommunicationeventOverviewPanel.Click();

            communicationEventOverview.Table.DefaultAction(editCommunicationEvent);

            var letterCorrespondenceEditComponent = new LetterCorrespondenceEditComponent(this.Driver);

            letterCorrespondenceEditComponent
            .CommunicationEventState.Select(new CommunicationEventStates(this.Session).InProgress)
            .EventPurposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment)
            .FromParty.Select(person)
            .ToParty.Select(employee)
            .FromPostalAddress.Select(postalAddress)
            .Subject.Set("new subject")
            .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 23))
            .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23))
            .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 24))
            .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 24))
            .Comment.Set("new comment")
            .SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new LetterCorrespondences(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length);

            Assert.Equal(new CommunicationEventStates(this.Session).InProgress, editCommunicationEvent.CommunicationEventState);
            Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, editCommunicationEvent.EventPurposes);
            Assert.Equal(person, editCommunicationEvent.FromParty);
            Assert.Equal(employee, editCommunicationEvent.ToParty);
            Assert.Equal(postalAddress, editCommunicationEvent.PostalAddress);
            Assert.Equal("new subject", editCommunicationEvent.Subject);
            Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, editCommunicationEvent.ScheduledStart.Value.ToUniversalTime().Date);
            Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, editCommunicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date);
            Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, editCommunicationEvent.ActualStart.Value.Date.ToUniversalTime().Date);
            Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, editCommunicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date);
            Assert.Equal("new comment", editCommunicationEvent.Comment);
        }