public void TooFewRetriesThrows() { 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 engine = new MockEngine(true /* log to console */); t.BuildEngine = engine; t.SourceFiles = new ITaskItem[] { new TaskItem("c:\\source") }; t.DestinationFiles = new ITaskItem[] { new TaskItem("c:\\destination") }; t.Retries = 1; CopyFunctor copyFunctor = new CopyFunctor(3, true /* throw */); bool result = t.Execute(copyFunctor.Copy); Assert.AreEqual(false, result); engine.AssertLogContains("MSB3026"); engine.AssertLogContains("MSB3027"); }
public void SuccessAfterOneRetryContinueToNextFile() { 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 engine = new MockEngine(true /* log to console */); t.BuildEngine = engine; t.SourceFiles = new ITaskItem[] { new TaskItem("c:\\source"), new TaskItem("c:\\source2") }; t.DestinationFiles = new ITaskItem[] { new TaskItem("c:\\destination"), new TaskItem("c:\\destination2") }; t.Retries = 1; t.RetryDelayMilliseconds = 1; // Can't really test the delay, but at least try passing in a value CopyFunctor copyFunctor = new CopyFunctor(2, false /* do not throw on failure */); bool result = t.Execute(copyFunctor.Copy); Assert.AreEqual(true, result); engine.AssertLogContains("MSB3026"); engine.AssertLogDoesntContain("MSB3027"); Assert.AreEqual(copyFunctor.FilesCopiedSuccessfully[0].Name, "c:\\source"); Assert.AreEqual(copyFunctor.FilesCopiedSuccessfully[1].Name, "c:\\source2"); }