示例#1
0
        public void GivenPhoneCommunication_WhenCallerIsDeleted_ThenCommunicationEventIsDeleted()
        {
            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();

            new PhoneCommunicationBuilder(this.Session)
            .WithSubject("Hello world!")
            .WithOwner(owner)
            .WithFromParty(originator)
            .WithToParty(receiver)
            .Build();

            this.Session.Derive();

            Assert.Equal(1, this.Session.Extent <PhoneCommunication>().Count);

            originator.Delete();
            this.Session.Derive();

            Assert.Equal(0, this.Session.Extent <PhoneCommunication>().Count);
        }
示例#2
0
        public void GivenLetterCorrespondence_WhenOriginatorIsDeleted_ThenCommunicationEventIsDeleted()
        {
            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();

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

            this.Session.Derive();

            Assert.Single(this.Session.Extent <LetterCorrespondence>());

            originator.Delete();
            this.Session.Derive();

            Assert.Equal(0, this.Session.Extent <LetterCorrespondence>().Count);
        }
示例#3
0
        public void GivenEmailCommunication_WhenOriginatorIsDeleted_ThenCommunicationEventIsDeleted()
        {
            var personalEmailAddress = new ContactMechanismPurposes(this.Session).PersonalEmailAddress;

            var originatorEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var originatorContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(originatorEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var originator        = new PersonBuilder(this.Session).WithLastName("originator").WithPartyContactMechanism(originatorContact).Build();

            var addresseeEmail   = new EmailAddressBuilder(this.Session).WithElectronicAddressString("*****@*****.**").Build();
            var addresseeContact = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(addresseeEmail).WithContactPurpose(personalEmailAddress).WithUseAsDefault(true).Build();
            var addressee        = new PersonBuilder(this.Session).WithLastName("addressee").WithPartyContactMechanism(addresseeContact).Build();

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

            var communication = new EmailCommunicationBuilder(this.Session)
                                .WithSubject("Hello")
                                .WithDescription("Hello world!")
                                .WithFromParty(originator)
                                .WithToParty(addressee)
                                .WithFromEmail(originatorEmail)
                                .WithToEmail(addresseeEmail)
                                .Build();

            this.Session.Derive();

            Assert.Single(this.Session.Extent <EmailCommunication>());

            originator.Delete();
            this.Session.Derive();

            Assert.Equal(0, this.Session.Extent <EmailCommunication>().Count);
        }
示例#4
0
        public void WhenDeletingUserThenLoginShouldAlsoBeDeleted()
        {
            var user = new PersonBuilder(this.Session).WithUserName("User").WithLastName("User").Build();
            var login = new LoginBuilder(this.Session).WithUser(user).WithProvider("MyProvider").WithKey("XXXYYYZZZ").Build();

            this.Session.Derive();

            user.Delete();

            this.Session.Derive();

            Assert.IsTrue(login.Strategy.IsDeleted);
        }
        public void WhenDeletingUserThenLoginShouldAlsoBeDeleted()
        {
            var user  = new PersonBuilder(this.Session).WithUserName("User").WithLastName("User").Build();
            var login = new LoginBuilder(this.Session).WithUser(user).WithProvider("MyProvider").WithKey("XXXYYYZZZ").Build();

            this.Session.Derive();

            user.Delete();

            this.Session.Derive();

            Assert.IsTrue(login.Strategy.IsDeleted);
        }
        public void GivenPartyContactMechanism_WhenPartyIsDeleted_ThenPartyContactMechanismIsDeleted()
        {
            var contactMechanism      = new TelecommunicationsNumberBuilder(this.Session).WithAreaCode("0495").WithContactNumber("493499").WithDescription("cellphone").Build();
            var partyContactMechanism = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(contactMechanism).Build();
            var party = new PersonBuilder(this.Session).WithLastName("party").WithPartyContactMechanism(partyContactMechanism).Build();

            this.Session.Derive();
            var countBefore = this.Session.Extent <PartyContactMechanism>().Count;

            party.Delete();
            this.Session.Derive();

            Assert.Equal(countBefore - 1, this.Session.Extent <PartyContactMechanism>().Count);
        }
示例#7
0
        public void GivenEmployement_WhenDeletingEmployee_ThenCurrentEmployeesShouldBeUpdated()
        {
            var now = this.Session.Now();

            var acme = new OrganisationBuilder(this.Session).WithName("Acme").Build();
            var john = new PersonBuilder(this.Session).WithFirstName("John").WithLastName("Doe").Build();

            new EmploymentBuilder(this.Session).WithEmployer(acme).WithEmployee(john).WithFrom(now.Subtract(TimeSpan.FromDays(1))).Build();

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

            john.Delete();

            this.Session.Derive();

            Assert.Empty(acme.CurrentEmployees);
        }
        public void GivenFaceToFaceCommunication_WhenParticipantIsDeleted_ThenCommunicationEventIsDeleted()
        {
            var participant1 = new PersonBuilder(this.Session).WithLastName("participant1").Build();
            var participant2 = new PersonBuilder(this.Session).WithLastName("participant2").Build();

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

            new FaceToFaceCommunicationBuilder(this.Session)
            .WithSubject("subject")
            .WithFromParty(participant1)
            .WithToParty(participant2)
            .WithActualStart(DateTime.UtcNow)
            .Build();

            this.Session.Derive();

            Assert.Equal(1, this.Session.Extent <FaceToFaceCommunication>().Count);

            participant2.Delete();
            this.Session.Derive();

            Assert.Equal(0, this.Session.Extent <FaceToFaceCommunication>().Count);
        }