protected void SetUp() { _log = CreateXmlLogger(); _tempDir = TempDir.Create("NAnt.Tests.XmlLoggerTest"); }
private XmlLogger CreateXmlLogger(DateTimeProvider dtProvider) { XmlLogger logger = new XmlLogger(new StopWatchStack(dtProvider)); logger.OutputWriter = new StringWriter(); return logger; }
public void TaskStartedAndTaskFinished() { string expected = @"<task name=""testtask""><duration>321</duration></task>"; _log = CreateXmlLogger(CreateDateTimeProvider(321)); BuildEventArgs args = new BuildEventArgs(new TestTask()); _log.TaskStarted(this, args); _log.TaskFinished(this, args); Assert.AreEqual(expected, _log.ToString()); }
public void TargetStartedAndTargetFinished() { string expected = @"<target name=""foo""><duration>123</duration></target>"; _log = CreateXmlLogger(CreateDateTimeProvider(123)); BuildEventArgs args = CreateBuildEventArgsWithTarget("foo"); _log.TargetStarted(this, args); _log.TargetFinished(this, args); Assert.AreEqual(expected, _log.ToString()); }
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()); }
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()); }