Пример #1
0
        public void ReplaceMessageInheritsMessageId()
        {
            TestMessage context   = new TestMessage();
            TestMessage replacing = new TestMessage();

            context.ReplaceWith(replacing);

            replacing.Id.Should().Be(context.Id);
        }
Пример #2
0
        public void ReplaceMessageInheritsPredecessorIds()
        {
            TestMessage origin    = new TestMessage();
            TestMessage context   = new TestMessage(origin);
            TestMessage replacing = new TestMessage();

            context.ReplaceWith(replacing);

            replacing.ToMessageLog().Predecessors.Should().BeEquivalentTo(context.ToMessageLog().Predecessors);
        }
Пример #3
0
        public void ReplaceMessageInheritsMessageDomain()
        {
            TestMessage context = new TestMessage();

            MessageDomain.CreateNewDomainsFor(context);
            TestMessage replacing = new TestMessage();

            context.ReplaceWith(replacing);

            replacing.ToMessageLog().Domain.Should().Be(context.ToMessageLog().Domain);
        }
Пример #4
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);
            }
        }
Пример #5
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.");
        }