public void GivenCurrentUserIsKnown_WhenAccessingFaceToFaceCommunicationWithOwner_ThenOwnerSecurityTokenIsApplied() { Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("user"), new string[0]); var user = new PersonBuilder(this.DatabaseSession).WithLastName("user").WithUserName("user").Build(); var owner = new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build(); var participant1 = new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build(); var participant2 = new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithOwner(owner) .WithSubject("subject") .WithParticipant(participant1) .WithParticipant(participant2) .WithActualStart(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(2, communication.SecurityTokens.Count); Assert.Contains(Singleton.Instance(this.DatabaseSession).DefaultSecurityToken, communication.SecurityTokens); Assert.Contains(owner.OwnerSecurityToken, communication.SecurityTokens); }
public void GivenCommunicationEvent_WhenInProgress_ThenCurrentObjectStateIsInProgress() { var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build()) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build()) .WithSubject("Hello") .WithActualStart(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(new CommunicationEventObjectStates(this.DatabaseSession).InProgress, communication.CurrentObjectState); }
public void GivenCommunicationEvent_WhenInPast_ThenCurrencObjectStateIsCompleted() { var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build()) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build()) .WithSubject("Hello") .WithActualStart(DateTime.UtcNow.AddHours(-2)) .WithActualEnd(DateTime.UtcNow.AddHours(-1)) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(new CommunicationEventObjectStates(this.DatabaseSession).Completed, communication.CurrentObjectState); }
public void GivenCurrentUserIsUnknown_WhenAccessingFaceToFaceCommunicationWithoutOwner_ThenDefaultSecurityTokenIsApplied() { var participant1 = new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build(); var participant2 = new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithSubject("subject") .WithParticipant(participant1) .WithParticipant(participant2) .WithActualStart(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(1, communication.SecurityTokens.Count); Assert.Contains(Singleton.Instance(this.DatabaseSession).DefaultSecurityToken, communication.SecurityTokens); }
public void GivenFaceToFaceCommunication_WhenDeriving_ThenInvolvedPartiesAreDerived() { var owner = new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build(); var participant1 = new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build(); var participant2 = new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithOwner(owner) .WithSubject("subject") .WithParticipant(participant1) .WithParticipant(participant2) .WithActualStart(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(3, communication.InvolvedParties.Count); Assert.Contains(participant1, communication.InvolvedParties); Assert.Contains(participant2, communication.InvolvedParties); Assert.Contains(owner, communication.InvolvedParties); communication.AddParticipant(owner); this.DatabaseSession.Derive(true); Assert.AreEqual(3, communication.InvolvedParties.Count); }
public void GivenFaceToFaceCommunicationIsBuild_WhenDeriving_ThenStatusIsSet() { var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithOwner(new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build()) .WithSubject("subject") .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build()) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build()) .WithActualStart(DateTime.UtcNow) .Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); Assert.AreEqual(communication.CurrentCommunicationEventStatus.CommunicationEventObjectState, new CommunicationEventObjectStates(this.DatabaseSession).InProgress); Assert.AreEqual(communication.CurrentObjectState, new CommunicationEventObjectStates(this.DatabaseSession).InProgress); Assert.AreEqual(communication.CurrentObjectState, communication.LastObjectState); }
public void GivenFaceToFaceCommunication_WhenConfirmed_ThenCurrentCommunicationEventStatusMustBeDerived() { var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build()) .WithParticipant(new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build()) .WithSubject("Hello") .WithActualStart(DateTime.UtcNow) .Build(); this.DatabaseSession.Derive(true); Assert.AreEqual(1, communication.CommunicationEventStatuses.Count); Assert.AreEqual(new CommunicationEventObjectStates(this.DatabaseSession).InProgress, communication.CurrentCommunicationEventStatus.CommunicationEventObjectState); communication.Close(); this.DatabaseSession.Derive(true); Assert.AreEqual(2, communication.CommunicationEventStatuses.Count); Assert.AreEqual(new CommunicationEventObjectStates(this.DatabaseSession).Completed, communication.CurrentCommunicationEventStatus.CommunicationEventObjectState); }