示例#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]);
        }
示例#2
0
 public void SetUp()
 {
     stream = new MemoryStream();
       sut = new StreamLogger(stream) { SystemClock = () => new DateTime(2000, 1, 2, 3, 4, 5) };
 }