本文整理汇总了C#中Microsoft.Build.UnitTests.MockEngine.AssertLogDoesntContainMessageFromResource方法的典型用法代码示例。如果您正苦于以下问题:C# MockEngine.AssertLogDoesntContainMessageFromResource方法的具体用法?C# MockEngine.AssertLogDoesntContainMessageFromResource怎么用?C# MockEngine.AssertLogDoesntContainMessageFromResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.UnitTests.MockEngine
的用法示例。
在下文中一共展示了MockEngine.AssertLogDoesntContainMessageFromResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyToDestinationFolder
public void CopyToDestinationFolder()
{
string sourceFile = FileUtilities.GetTemporaryFile();
string temp = Path.GetTempPath();
string destFolder = Path.Combine(temp, "2A333ED756AF4dc392E728D0F864A398");
string destFile = Path.Combine(destFolder, Path.GetFileName(sourceFile));
try
{
using (StreamWriter sw = new StreamWriter(sourceFile, true)) // HIGHCHAR: Test writes in UTF8 without preamble.
sw.Write("This is a source temp file.");
// Don't create the dest folder, let task do that
ITaskItem[] sourceFiles = new ITaskItem[] { new TaskItem(sourceFile) };
Copy t = new Copy();
t.RetryDelayMilliseconds = 1; // speed up tests!
// Allow the task's default (false) to have a chance
if (useHardLinks)
{
t.UseHardlinksIfPossible = useHardLinks;
}
MockEngine me = new MockEngine();
t.BuildEngine = me;
t.SourceFiles = sourceFiles;
t.DestinationFolder = new TaskItem(destFolder);
t.SkipUnchangedFiles = true;
bool success = t.Execute();
Assert.IsTrue(success, "success");
Assert.IsTrue(File.Exists(destFile), "destination exists");
string destinationFileContents;
using (StreamReader sr = new StreamReader(destFile))
destinationFileContents = sr.ReadToEnd();
if (!useHardLinks)
{
Microsoft.Build.UnitTests.MockEngine.GetStringDelegate resourceDelegate = new Microsoft.Build.UnitTests.MockEngine.GetStringDelegate(AssemblyResources.GetString);
me.AssertLogDoesntContainMessageFromResource(resourceDelegate, "Copy.HardLinkComment", sourceFile, destFile);
}
else
{
Microsoft.Build.UnitTests.MockEngine.GetStringDelegate resourceDelegate = new Microsoft.Build.UnitTests.MockEngine.GetStringDelegate(AssemblyResources.GetString);
me.AssertLogContainsMessageFromResource(resourceDelegate, "Copy.HardLinkComment", sourceFile, destFile);
}
Assert.IsTrue
(
destinationFileContents == "This is a source temp file.",
"Expected the destination file to contain the contents of source file."
);
Assert.AreEqual(1, t.DestinationFiles.Length);
Assert.AreEqual(1, t.CopiedFiles.Length);
Assert.AreEqual(destFile, t.DestinationFiles[0].ItemSpec);
Assert.AreEqual(destFile, t.CopiedFiles[0].ItemSpec);
((MockEngine)t.BuildEngine).AssertLogDoesntContain("MSB3026"); // Didn't do retries
}
finally
{
Helpers.DeleteFiles(sourceFile, destFile);
}
}