public void NoCommandsOrException()
 {
     var fakeClock = new Fakes.StubIClock();
     using (var changesReport = new ChangesReport(fakeClock))
     {
         Assert.IsFalse(changesReport.HasMessage);
     }
 }
 public void NoException()
 {
     var fakeClock = new Fakes.StubIClock();
     using (var errorReport = new ErrorReport(fakeClock))
     {
         Assert.IsFalse(errorReport.HasMessage);
     }
 }
        public void NoCommandsOrException()
        {
            var fakeClock = new Fakes.StubIClock();

            using (var changesReport = new ChangesReport(fakeClock))
            {
                Assert.IsFalse(changesReport.HasMessage);
            }
        }
        public void NoException()
        {
            var fakeClock = new Fakes.StubIClock();

            using (var errorReport = new ErrorReport(fakeClock))
            {
                Assert.IsFalse(errorReport.HasMessage);
            }
        }
        public void MailMessageRequestAttachment()
        {
            var fakeClock = new Fakes.StubIClock();
            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request = string.Format("{{ Id: \"{0}\", Message: \"message\" }}", Guid.NewGuid().ToString());
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }
        public void MailMessage()
        {
            var fakeClock = new Fakes.StubIClock();
            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request = string.Empty;
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.IsTrue(errorReport.HasMessage);
                Assert.IsNotNull(message);
                Assert.IsTrue(message.Body.Contains("Oops!"));
            }
        }
        public void MailMessageRequestAttachment()
        {
            var fakeClock = new Fakes.StubIClock();

            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request   = string.Format("{{ Id: \"{0}\", Message: \"message\" }}", Guid.NewGuid().ToString());
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }
        public void MailMessage()
        {
            var fakeClock = new Fakes.StubIClock();

            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request   = string.Empty;
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.IsTrue(errorReport.HasMessage);
                Assert.IsNotNull(message);
                Assert.IsTrue(message.Body.Contains("Oops!"));
            }
        }
        public void MailMessageWithException()
        {
            var fakeClock = new Fakes.StubIClock();
            using (var changesReport = new ChangesReport(fakeClock))
            {
                changesReport.Request = string.Empty;
                changesReport.Exception = new Exception("Oops!");

                var message = changesReport.ToMailMessage();

                Assert.IsTrue(changesReport.HasMessage);
                Assert.IsFalse(message.IsBodyHtml);
                Assert.IsTrue(message.Body.Contains("Oops!"));
                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }
        public void MailMessageWithException()
        {
            var fakeClock = new Fakes.StubIClock();

            using (var changesReport = new ChangesReport(fakeClock))
            {
                changesReport.Request   = string.Empty;
                changesReport.Exception = new Exception("Oops!");

                var message = changesReport.ToMailMessage();

                Assert.IsTrue(changesReport.HasMessage);
                Assert.IsFalse(message.IsBodyHtml);
                Assert.IsTrue(message.Body.Contains("Oops!"));
                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }
        public void MailMessageDuration()
        {
            var times = new DateTime[]
            {
                new DateTime(2015, 9, 2, 3, 0, 0, 0),
                new DateTime(2015, 9, 2, 3, 0, 1, 333)
            };
            int i = 0;
            var fakeClock = new Fakes.StubIClock()
            {
                UtcNowGet = () => { return times[i++]; }
            };
            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request = string.Empty;
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.IsTrue(message.Body.Contains("Took 1.33 seconds"));
            }
        }
        public void MailMessageWithNoException()
        {
            var fakeClock = new Fakes.StubIClock();
            var fakeExecutedCommands = new Fakes.StubIExecutedCommands()
            {
                ToString = () => { return "ExecutedCommands"; }
            };
            using (var changesReport = new ChangesReport(fakeClock))
            {
                changesReport.Request = string.Format("{{ Id: \"{0}\", Message: \"message\" }}", Guid.NewGuid().ToString());
                changesReport.ExecutedCommands = fakeExecutedCommands;

                var message = changesReport.ToMailMessage();

                Assert.IsTrue(changesReport.HasMessage);
                Assert.IsFalse(message.IsBodyHtml);
                Assert.IsTrue(message.Body.Contains("ExecutedCommands"));
                Assert.IsTrue(message.Body.Contains("0"));
                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }
        public void MailMessageDuration()
        {
            var times = new DateTime[]
            {
                new DateTime(2015, 9, 2, 3, 0, 0, 0),
                new DateTime(2015, 9, 2, 3, 0, 1, 333)
            };
            int i         = 0;
            var fakeClock = new Fakes.StubIClock()
            {
                UtcNowGet = () => { return(times[i++]); }
            };

            using (var errorReport = new ErrorReport(fakeClock))
            {
                errorReport.Request   = string.Empty;
                errorReport.Exception = new Exception("Oops!");

                var message = errorReport.ToMailMessage();

                Assert.IsTrue(message.Body.Contains("Took 1.33 seconds"));
            }
        }
        public void MailMessageWithNoException()
        {
            var fakeClock            = new Fakes.StubIClock();
            var fakeExecutedCommands = new Fakes.StubIExecutedCommands()
            {
                ToString = () => { return("ExecutedCommands"); }
            };

            using (var changesReport = new ChangesReport(fakeClock))
            {
                changesReport.Request          = string.Format("{{ Id: \"{0}\", Message: \"message\" }}", Guid.NewGuid().ToString());
                changesReport.ExecutedCommands = fakeExecutedCommands;

                var message = changesReport.ToMailMessage();

                Assert.IsTrue(changesReport.HasMessage);
                Assert.IsFalse(message.IsBodyHtml);
                Assert.IsTrue(message.Body.Contains("ExecutedCommands"));
                Assert.IsTrue(message.Body.Contains("0"));
                Assert.AreEqual(1, message.Attachments.Count);
                Assert.AreEqual(ErrorReport.ATTACHMENT_CONTENTTYPE, message.Attachments.Single().ContentType.MediaType);
                Assert.IsNotNull(message.Attachments.Single().ContentStream);
            }
        }