Ejemplo n.º 1
0
        public void WriteLineTest()
        {
            ILogWriter supersededWriter = new TestLogWriter();

            LogAccumulator.DisposalCallback disposalCallback = null;
            LogAccumulator target  = new LogAccumulator(supersededWriter, disposalCallback);
            string         message = "Hello";

            target.WriteLine(message);

            PrivateObject privateObj = new PrivateObject(target);

            Assert.AreEqual(message + Environment.NewLine, privateObj.GetFieldOrProperty("accumulatedMessages").ToString());

            target.WriteLine(message);
            Assert.AreEqual(message + Environment.NewLine + message + Environment.NewLine, privateObj.GetFieldOrProperty("accumulatedMessages").ToString());
        }
Ejemplo n.º 2
0
        public void DiscardTest()
        {
            var supersededWriter = new TestLogWriter();

            LogAccumulator.DisposalCallback disposalCallback = null;
            LogAccumulator target = new LogAccumulator(supersededWriter, disposalCallback);

            string message = "Hello";

            target.WriteLine(message);

            target.Discard();

            var actual = supersededWriter.Output.ToString().Replace(Environment.NewLine, "$n");

            Assert.AreEqual("", actual, "(Note: $n replaces new line characters)");

            PrivateObject privateObj = new PrivateObject(target);

            Assert.AreEqual("", privateObj.GetFieldOrProperty("accumulatedMessages").ToString());
        }