public void TerminatedDomainParentsForgetChildren() { TestMessage message = new TestMessage(); MessageDomain.CreateNewDomainsFor(message); MessageDomain.TerminateDomainsOf(message); message.MessageDomain.Parent.Children.Should().NotContain(message.MessageDomain); }
public void TerminatedDomainsDoNotPropagate() { TestMessage message1 = new TestMessage(); TestMessage message2 = new TestMessage(); MessageDomain.CreateNewDomainsFor(message1); MessageDomain.TerminateDomainsOf(message1); TestMessage nextMessage = new TestMessage(message1); Assert.AreEqual(nextMessage.MessageDomain, message2.MessageDomain, "Propagate parent message domain of terminated domains."); }
public void CreatingNewDomainsIgnoreTerminatedDomains() { TestMessage message1 = new TestMessage(); MessageDomain.CreateNewDomainsFor(message1); TestMessage message2 = new TestMessage(message1); MessageDomain.TerminateDomainsOf(message1); MessageDomain.CreateNewDomainsFor(message2); Assert.AreEqual(message2.MessageDomain.Parent, MessageDomain.DefaultMessageDomain, "Terminated domains should be skipped when creating new domains."); }
public void DontPropagateDomainForTerminatedSiblingDomainIfParentIsStillSibling() { TestMessage message1 = new TestMessage(); TestMessage message2 = new TestMessage(); MessageDomain.CreateNewDomainsFor(new [] { message1, message2 }); MessageDomain.CreateNewDomainsFor(message2); MessageDomain.TerminateDomainsOf(message2); Assert.Throws <InvalidOperationException>(() => new TestMessage(new[] { message1, message2 }), "Exception should be thrown to indicate error."); }
public void PropagateDomainForTerminatedSiblingDomain() { TestMessage message1 = new TestMessage(); TestMessage message2 = new TestMessage(); MessageDomain.CreateNewDomainsFor(new [] { message1, message2 }); MessageDomain.TerminateDomainsOf(message2); TestMessage message3 = new TestMessage(new [] { message1, message2 }); Assert.AreEqual(message1.MessageDomain, message3.MessageDomain, "Non terminated domain should have been used."); }
public void MessageIsDisposedIfRemovedFromCollectorByDomainTermination() { MessageCollector <TestMessage, DisposableMessage> collector = new(); DisposableMessage message = new(); MessageDomain.CreateNewDomainsFor(message); message.SetUserCount(1); collector.Push(message); message.Used(); MessageDomain.TerminateDomainsOf(message); message.IsDisposed.Should().BeTrue("the it was removed from the collector."); }
public void TerminateDomainsSetsTheTerminatedFlag() { TestMessage message1 = new TestMessage(); TestMessage message2 = new TestMessage(); MessageDomain.CreateNewDomainsFor(new[] { message1, message2 }); Assert.IsFalse(message1.MessageDomain.IsTerminated, "message1.MessageDomain.IsTerminated"); Assert.IsFalse(message2.MessageDomain.IsTerminated, "message2.MessageDomain.IsTerminated"); MessageDomain.TerminateDomainsOf(new[] { message1, message2 }); Assert.IsTrue(message1.MessageDomain.IsTerminated, "message1.MessageDomain.IsTerminated"); Assert.IsTrue(message2.MessageDomain.IsTerminated, "message2.MessageDomain.IsTerminated"); }
protected override InterceptionAction InterceptCore(Message messageData) { if (messageData.Is <ModifyModel>()) { if (messageData.MessageDomain.Root.Is <ModifyModel>()) { if (messageData.Get <ModifyModel>() == messageData.MessageDomain.Root.Get <ModifyModel>()) { //Already its own domain return(InterceptionAction.Continue); } MessageDomain.TerminateDomainsOf(messageData); } MessageDomain.CreateNewDomainsFor(messageData); } else { MessageDomain.TerminateDomainsOf(messageData); } return(InterceptionAction.Continue); }
private void OnAggregated(IReadOnlyCollection <FileGenerated> set) { MessageDomain.TerminateDomainsOf(set); OnMessage(new FilesGenerated(set.Select(f => f.Result).ToArray(), set)); }
private void OnAggregated(IReadOnlyCollection <TemplateLoaded> messages) { MessageDomain.TerminateDomainsOf(messages); OnMessage(new TemplatesLoaded(messages.ToDictionary(m => m.Name, m => m.Content), messages)); }