Ejemplo n.º 1
0
        public void TestLoggingOnMethod()
        {
            var b = new Beer();

            //reset logger
            Logger.Reset();
            //make sure the logger is at count == 0
            Assert.AreEqual(Logger.Log.Count, 0);

            //drink beer :)
            b.Drink();

			//the log must contain correct info
			Assert.AreEqual("Before Logging.UnitTest.Target.Beer.Drink()", Logger.Log[0]);
			Assert.AreEqual("After Logging.UnitTest.Target.Beer.Drink()", Logger.Log[3]);
			
			//make sure the beer is alright
            Assert.IsTrue(b.Empty);
            Assert.IsFalse(b.Full);
            Assert.IsFalse(b.Dropped);

            //The number of log messages must be ok
            Assert.AreEqual(Logger.Log.Count, 12);

        }
Ejemplo n.º 2
0
        public void TestLoggingOnCtor()
        {
            Logger.Reset();
            //make sure the logger is at count == 0
            Assert.AreEqual(Logger.Log.Count, 0);
            //Create a new beer. yay
            var b = new Beer();

			//the log must contain correct info
			Assert.AreEqual("Before Logging.UnitTest.Target.Beer..ctor()", Logger.Log[0]);
			Assert.AreEqual("After Logging.UnitTest.Target.Beer..ctor()", Logger.Log[7]);
			
			//make sure the beer is alright
            Assert.IsTrue(b.Full);
            Assert.IsFalse(b.Dropped);
            Assert.IsFalse(b.Empty);

            //The number of log messages must be ok
            Assert.AreEqual(Logger.Log.Count, 16);
        }