Beispiel #1
0
        public void TestFailoverMechanism()
        {
            var stream = new MemoryStream();
              var logger = new StreamLogger(stream);
              logger.SystemClock = () => new DateTime(2000, 1, 1, 14, 15, 16);
              var guard = new FailGuard(logger);

              var success = false;
              guard.Attempt(
            () => { throw new Exception("Call failed."); },
            () => { success = true; });

              Assert.IsTrue(success);
              var lines = stream.GetLines();
              Assert.AreEqual("[2000.01.01 14:15:16 E] Call failed.", lines[0]);
              Assert.AreEqual("[2000.01.01 14:15:16 D] Success.", lines[1]);
        }
Beispiel #2
0
 public void SetUp()
 {
     logger = new Mock<Logger>();
       sut = new FailGuard(logger.Object);
 }