public void CreateDomainSwitchesDomainForMessageHierarchy()
        {
            TestMessage          message1  = new TestMessage();
            TestMessageDecorator decorator = TestMessageDecorator.Decorate(message1);

            MessageDomain.CreateNewDomainsFor(message1);

            Assert.AreEqual(message1.MessageDomain, decorator.MessageDomain, "Whole hierarchy should have the new domain.");
        }
Example #2
0
        public void ReplaceMessageInheritsChild()
        {
            TestMessage          child     = new TestMessage();
            TestMessageDecorator context   = TestMessageDecorator.Decorate(child);
            TestMessageDecorator replacing = TestMessageDecorator.Decorate(null);

            context.ReplaceWith(replacing);

            replacing.ToMessageLog().Child.Id.Should().Be(child.Id);
        }
Example #3
0
        public void ReplaceMessageReplacesParentConnection()
        {
            TestMessage          context   = new TestMessage();
            TestMessageDecorator decorator = TestMessageDecorator.Decorate(context);
            TestMessage          replacing = new TestMessage();

            context.ReplaceWith(replacing);

            replacing.HeadMessage.Should().Be(decorator);
            decorator.DescendantsAndSelf.Should().Contain(replacing);
            foreach (Message descendant in decorator.DescendantsAndSelf)
            {
                descendant.Should().NotBeSameAs(context);
            }
        }
Example #4
0
        public void ReplaceMessageChangesDescendantsOfWholeHierarchy()
        {
            TestMessage          context   = new TestMessage();
            TestMessageDecorator decorator = TestMessageDecorator.Decorate(context);
            TestMessageDecorator head      = TestMessageDecorator.Decorate(decorator);
            TestMessage          replacing = new TestMessage();

            context.ReplaceWith(replacing);

            bool found = false;

            foreach (Message descendant in head.DescendantsAndSelf)
            {
                found |= ReferenceEquals(descendant, replacing);
            }

            found.Should().BeTrue("the head message should now the new child message.");
        }