public void StartChildStartsANewChildContext()
        {
            var writerMock = new Mock <XmlWriter>(MockBehavior.Strict);

            writerMock.Setup(w => w.WriteStartElement(null, "task", null)).Verifiable();
            writerMock.MockWriteAttributeString("name", "TestComment");
            writerMock.MockWriteAttributeString("type", "Comment");
            writerMock.MockWriteElementString("start", "2010-01-01T12:01:01");
            var clockMock = new Mock <IClock>(MockBehavior.Strict);

            clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
            var task    = new Comment("TestComment");
            var context = new TaskExecutionContext(
                new TaskExecutionParameters
            {
                XmlWriter = writerMock.Object,
                Clock     = clockMock.Object
            });
            var child = context.StartChild(task);

            Assert.IsNotNull(child);
            Assert.AreSame(context, child.Parent);
            Assert.AreSame(context.ModificationSets, child.ModificationSets);
            writerMock.Verify();
        }
        public void CompleteClosesElementIfChild()
        {
            var writerMock = new Mock <XmlWriter>(MockBehavior.Loose);

            writerMock.Setup(w => w.WriteEndElement()).Verifiable();
            writerMock.Setup(w => w.WriteEndDocument()).Throws(new AssertionException("WriteEndDocument called"));
            var clockMock = new Mock <IClock>(MockBehavior.Strict);

            clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
            var context = new TaskExecutionContext(
                new TaskExecutionParameters
            {
                XmlWriter = writerMock.Object,
                Clock     = clockMock.Object
            });
            var child = context.StartChild(new Comment());

            child.Complete();
            writerMock.Verify();
        }
 public void StartChildStartsANewChildContext()
 {
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteStartElement(null, "task", null)).Verifiable();
     writerMock.MockWriteAttributeString("name", "TestComment");
     writerMock.MockWriteAttributeString("type", "Comment");
     writerMock.MockWriteElementString("start", "2010-01-01T12:01:01");
     var clockMock = new Mock<IClock>(MockBehavior.Strict);
     clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
     var task = new Comment("TestComment");
     var context = new TaskExecutionContext(
         new TaskExecutionParameters
             {
                 XmlWriter = writerMock.Object,
                 Clock = clockMock.Object
             });
     var child = context.StartChild(task);
     Assert.IsNotNull(child);
     Assert.AreSame(context, child.Parent);
     Assert.AreSame(context.ModificationSets, child.ModificationSets);
     writerMock.Verify();
 }
 public void CompleteClosesElementIfChild()
 {
     var writerMock = new Mock<XmlWriter>(MockBehavior.Loose);
     writerMock.Setup(w => w.WriteEndElement()).Verifiable();
     writerMock.Setup(w => w.WriteEndDocument()).Throws(new AssertionException("WriteEndDocument called"));
     var clockMock = new Mock<IClock>(MockBehavior.Strict);
     clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
     var context = new TaskExecutionContext(
         new TaskExecutionParameters
             {
                 XmlWriter = writerMock.Object,
                 Clock = clockMock.Object
             });
     var child = context.StartChild(new Comment());
     child.Complete();
     writerMock.Verify();
 }