public void CompleteDoesNothingIfAlreadyClosed()
 {
     var action = 0;
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteEndDocument()).Callback(() => action++);
     writerMock.Setup(w => w.Close()).Callback(() => action++);
     writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
     writerMock.MockWriteElementString("status", "Success");
     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
             });
     context.Complete();
     context.Complete();
     Assert.AreEqual(2, action);
 }
        public void CompleteDoesNothingIfAlreadyClosed()
        {
            var action     = 0;
            var writerMock = new Mock <XmlWriter>(MockBehavior.Strict);

            writerMock.Setup(w => w.WriteEndDocument()).Callback(() => action++);
            writerMock.Setup(w => w.Close()).Callback(() => action++);
            writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
            writerMock.MockWriteElementString("status", "Success");
            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
            });

            context.Complete();
            context.Complete();
            Assert.AreEqual(2, action);
        }
 public void CompleteClosesWriter()
 {
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteEndDocument()).Verifiable();
     writerMock.Setup(w => w.Close()).Verifiable();
     writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
     writerMock.MockWriteElementString("status", "Success");
     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
             });
     Assert.IsFalse(context.IsCompleted);
     context.Complete();
     writerMock.Verify();
     Assert.IsTrue(context.IsCompleted);
 }
        public void CompleteClosesWriter()
        {
            var writerMock = new Mock <XmlWriter>(MockBehavior.Strict);

            writerMock.Setup(w => w.WriteEndDocument()).Verifiable();
            writerMock.Setup(w => w.Close()).Verifiable();
            writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
            writerMock.MockWriteElementString("status", "Success");
            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
            });

            Assert.IsFalse(context.IsCompleted);
            context.Complete();
            writerMock.Verify();
            Assert.IsTrue(context.IsCompleted);
        }