示例#1
0
        public void Analyze_TooShortFileName_CallsWebService()
        {
            FakeWebService mockService      = new FakeWebService();
            LogAnalyzer    log              = new LogAnalyzer(mockService);
            string         tooShortFileName = "abc.ext";

            log.Analyze(tooShortFileName);

            //StringAssert.Contains("Too short name: abc.ext", mockService.LastError);
        }
示例#2
0
        public void Analyze_WebServiceThrows_SendsEmail()
        {
            FakeWebService stubService = new FakeWebService();

            stubService.ToThrow = new Exception("fake exception");

            FakeEmailService mockEmail        = new FakeEmailService();
            LogAnalyzer22    log              = new LogAnalyzer22(mockEmail, stubService);
            string           tooShortFileName = "abc.ext";

            log.Analyze(tooShortFileName);

            StringAssert.Contains("*****@*****.**", mockEmail.email.To);
            StringAssert.Contains("fake exception", mockEmail.email.Body);
            StringAssert.Contains("can't log", mockEmail.email.Subject);
        }
示例#3
0
        public void Analyze_WebServiceThrows_SendsEmail2()
        {
            FakeWebService stubService = new FakeWebService();

            stubService.ToThrow = new Exception("fake exception");

            FakeEmailService mockEmail        = new FakeEmailService();
            LogAnalyzer22    log              = new LogAnalyzer22(mockEmail, stubService);
            string           tooShortFileName = "abc.ext";

            log.Analyze(tooShortFileName);
            EmailInfo expectedEmail = new EmailInfo
            {
                Body    = "fake exception",
                To      = "*****@*****.**",
                Subject = "can't log"
            };

            Assert.AreEqual(expectedEmail, mockEmail.email);
        }