Exemplo n.º 1
0
        public void ReplaceMessageInheritsMessageId()
        {
            TestMessage context   = new TestMessage();
            TestMessage replacing = new TestMessage();

            context.ReplaceWith(replacing);

            replacing.Id.Should().Be(context.Id);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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.");
        }