Пример #1
0
        public void TaskStartedAndTaskFinished()
        {
            string expected = @"<task name=""testtask""><duration>321</duration></task>";

            _log = CreateXmlLogger(CreateDateTimeProvider(321));

            TaskBuildEventArgs args = new TaskBuildEventArgs(new TestTask(), Stopwatch.StartNew());

            _log.TaskStarted(this, args);
            _log.TaskFinished(this, args);
            Assert.AreEqual(expected, _log.ToString());
        }
Пример #2
0
        public void BuildStartedAndBuildFinished()
        {
            string expected = "<buildresults project=\"testproject\"><duration>123</duration></buildresults>";

            _log = CreateXmlLogger(CreateDateTimeProvider(123));

            BuildEventArgs args = new BuildEventArgs(CreateProject());

            _log.BuildStarted(this, args);
            _log.BuildFinished(this, args);
            Assert.AreEqual(expected, _log.ToString());
        }
Пример #3
0
        public void TargetStartedAndTargetFinished()
        {
            string expected = @"<target name=""foo""><duration>123</duration></target>";

            _log = CreateXmlLogger(CreateDateTimeProvider(123));

            TargetBuildEventArgs args = CreateBuildEventArgsWithTarget("foo");

            _log.TargetStarted(this, args);
            _log.TargetFinished(this, args);
            Assert.AreEqual(expected, _log.ToString());
        }
Пример #4
0
        public void Write()
        {
            string baseMessage      = "this is a typical message.";
            string formattedMessage = "[foo] " + baseMessage;

            BuildEventArgs args = CreateBuildEventArgs(formattedMessage, Level.Info);

            _log.MessageLogged(this, args);

            string expected = string.Format(CultureInfo.InvariantCulture, "<message level=\"Info\"><![CDATA[{0}]]></message>", baseMessage);

            Assert.AreEqual(expected, _log.ToString());

            string unformattedMessage = "message:";

            _log = CreateXmlLogger();

            args.Message = unformattedMessage;
            _log.MessageLogged(this, args);
            expected = string.Format(CultureInfo.InvariantCulture, "<message level=\"Info\"><![CDATA[{0}]]></message>", unformattedMessage);
            Assert.AreEqual(expected, _log.ToString());

            unformattedMessage = "message with no tag in front.";
            _log         = CreateXmlLogger();
            args.Message = unformattedMessage;
            _log.MessageLogged(this, args);
            expected = string.Format(CultureInfo.InvariantCulture, "<message level=\"Info\"><![CDATA[{0}]]></message>", unformattedMessage);
            Assert.AreEqual(expected, _log.ToString());

            unformattedMessage = "BUILD SUCCESSFUL";
            _log         = CreateXmlLogger();
            args.Message = unformattedMessage;
            _log.MessageLogged(this, args);
            expected = string.Format(CultureInfo.InvariantCulture, "<message level=\"Info\"><![CDATA[{0}]]></message>", unformattedMessage);
            Assert.AreEqual(expected, _log.ToString());
        }