Last active
December 28, 2015 15:39
-
-
Save JayBazuzi/7522819 to your computer and use it in GitHub Desktop.
Unit test for running a custom MSBuild task.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void RequiredInputGetsLogged() | |
{ | |
var buildTarget = CreateBuildTarget(); | |
buildTarget.AddTask<TaskWithRequiredInput>().SetParameter("Foo", "hi"); | |
const string expected = @"Inputs: | |
Foo = hi | |
"; | |
AssertTargettOutput(expected, buildTarget); | |
} | |
private ProjectTargetElement CreateBuildTarget() | |
{ | |
var buildTarget = ProjectRootElement.Create().AddTarget("Build"); | |
return buildTarget; | |
} | |
private static void AssertTargettOutput(string expected, ProjectTargetElement projectTargetElement) | |
{ | |
var highImportanceStringLogger = new HighImportanceStringLogger(); | |
var success = new ProjectInstance(projectTargetElement.ContainingProject).Build(new[] { highImportanceStringLogger }); | |
Assert.IsTrue(success); | |
Assert.AreEqual(expected, highImportanceStringLogger.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment