public void CustomBuildErrorEventIsPreserved() { // Create a custom build event args that derives from MSBuild's BuildErrorEventArgs. // Set a custom field on this event (FXCopRule). MyCustomBuildErrorEventArgs fxcopError = new MyCustomBuildErrorEventArgs("Your code failed."); fxcopError.FXCopRule = "CodeViolation"; // Log the custom event args. (Pretend that the task actually did this.) _taskHost.LogErrorEvent(fxcopError); // Make sure our custom logger received the actual custom event and not some fake. Assert.True(_customLogger.LastError is MyCustomBuildErrorEventArgs); // "Expected Custom Error Event" // Make sure the special fields in the custom event match what we originally logged. fxcopError = _customLogger.LastError as MyCustomBuildErrorEventArgs; Assert.Equal("Your code failed.", fxcopError.Message); Assert.Equal("CodeViolation", fxcopError.FXCopRule); }
public void CustomBuildErrorEventIsPreserved() { MyCustomLogger myLogger = new MyCustomLogger(); engine.RegisterLogger(myLogger); // Create a custom build event args that derives from MSBuild's BuildErrorEventArgs. // Set a custom field on this event (FXCopRule). MyCustomBuildErrorEventArgs fxcopError = new MyCustomBuildErrorEventArgs("Your code is lame."); fxcopError.FXCopRule = "CodeLamenessViolation"; // Log the custom event args. (Pretend that the task actually did this.) engineProxy.LogErrorEvent(fxcopError); engine.LoggingServices.ProcessPostedLoggingEvents(); // Make sure our custom logger received the actual custom event and not some fake. Assertion.Assert("Expected Custom Error Event", myLogger.lastError is MyCustomBuildErrorEventArgs); // Make sure the special fields in the custom event match what we originally logged. fxcopError = myLogger.lastError as MyCustomBuildErrorEventArgs; Assertion.AssertEquals("Your code is lame.", fxcopError.Message); Assertion.AssertEquals("CodeLamenessViolation", fxcopError.FXCopRule); }
public void CustomBuildErrorEventIsPreserved() { // Create a custom build event args that derives from MSBuild's BuildErrorEventArgs. // Set a custom field on this event (FXCopRule). MyCustomBuildErrorEventArgs fxcopError = new MyCustomBuildErrorEventArgs("Your code failed."); fxcopError.FXCopRule = "CodeViolation"; // Log the custom event args. (Pretend that the task actually did this.) _taskHost.LogErrorEvent(fxcopError); // Make sure our custom logger received the actual custom event and not some fake. Assert.IsTrue(_customLogger.LastError is MyCustomBuildErrorEventArgs, "Expected Custom Error Event"); // Make sure the special fields in the custom event match what we originally logged. fxcopError = _customLogger.LastError as MyCustomBuildErrorEventArgs; Assert.AreEqual("Your code failed.", fxcopError.Message); Assert.AreEqual("CodeViolation", fxcopError.FXCopRule); }