public void ProgressFileDownloader_Download_Completed_HasNoError_ExpectSuccessAndShutDown()
{
//------------Setup for test--------------------------
var webClient = new Mock<IDev2WebClient>();
var file = new Mock<IFile>();
var crytpto = new Mock<ICryptoProvider>();
var progressNotifier = new Mock<IProgressNotifier>();
ProgressFileDownloader.GetProgressDialogViewModel = (x, y) => progressNotifier.Object;
var ax = new ProgressFileDownloader(webClient.Object, file.Object, crytpto.Object);
var stream = new MemoryStream();
stream.WriteByte(1);
stream.WriteByte(2);
stream.WriteByte(3);
crytpto.Setup(a => a.ComputeHash(It.IsAny<Stream>())).Returns(new byte[] { 0, 1, 2 });
file.Setup(a => a.Open("bob", FileMode.Open)).Returns(new MemoryStream());
bool shutdown = false;
//------------Execute Test---------------------------
ax.Download(new Uri("http://bob"), "dave", false, "moo", "012");
ax.ShutDownAction = s => shutdown = true;
webClient.Raise(a => a.DownloadFileCompleted += null, new AsyncCompletedEventArgs(null, false, "moo"));
//------------Assert Results-------------------------
file.Verify(a => a.Move("dave", "moo"));
Assert.IsTrue(shutdown);
Assert.IsFalse(ax.IsBusyDownloading);
}