public void Analyze_LoggerThrows_IsolationFramework_CallsWebService() { var mockWebService = Substitute.For <IWebService_CH5>(); var stubLogger = Substitute.For <ILogger>(); stubLogger.When(logger => logger.LogError(Arg.Any <string>())) .Do(info => { throw new Exception("fake exception"); }); var analyzer = new LogAnalyzer2_IMulti(stubLogger, mockWebService); analyzer.MinNameLength = 10; analyzer.Analyze("Short.txt"); mockWebService.Received() .Write(Arg.Is <string>(s => s.Contains("fake exception"))); }
public void Analyze_LoggerThrows_CallsWebService() { FakeWebService_CH5 mockWebService = new FakeWebService_CH5(); FakeLogger2 stubLogger = new FakeLogger2(); stubLogger.WillThrow = new Exception("fake exception"); var analyzer2 = new LogAnalyzer2_IMulti(stubLogger, mockWebService); analyzer2.MinNameLength = 8; string tooShortFileName = "abc.ext"; analyzer2.Analyze(tooShortFileName); Assert.That(mockWebService.MessageToWebService, Is.StringContaining("fake exception")); }