public Download ( |
||
address | ||
tmpFileName | string | |
dontStartUpdate | bool | |
fileName | string | |
checkSum | string | |
return | void |
public void Download(Uri address, string tmpFileName, bool dontStartUpdate, string fileName, string checkSum)
{
_tmpFileName = tmpFileName;
if(_file.Exists(_tmpFileName))
{
_file.Delete(_tmpFileName);
}
_dontStartUpdate = dontStartUpdate;
_webClient.DownloadFileAsync(address, tmpFileName, tmpFileName);
_webClient.DownloadFileCompleted += (o, args) =>
{
if(!args.Cancelled && null == args.Error && PerformCheckSum(tmpFileName, checkSum))
{
_file.Move(tmpFileName, fileName);
OnDownloadFileCompleted(args, fileName);
}
else
{
_file.Delete(tmpFileName);
ProgressDialog.Close();
}
};
ProgressDialog.Show();
IsBusyDownloading = true;
}
// ReSharper disable InconsistentNaming public void ProgressFileDownloader_UnitTest_Download_AsyncDownloadStartedAndProgressDialogShown() // ReSharper restore InconsistentNaming { //init var mockWebClient = new Mock<IDev2WebClient>(); mockWebClient.Setup(c => c.DownloadFileAsync(It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<string>())).Verifiable(); var mockProgressDialog = new Mock<IProgressDialog>(); mockProgressDialog.Setup(c => c.Show()).Verifiable(); ProgressFileDownloader.GetProgressDialogViewModel = (x, y) => mockProgressDialog.Object; var testProgressFileDownloader = new ProgressFileDownloader(mockWebClient.Object, new Mock<IFile>().Object,new Mock<ICryptoProvider>().Object); //exe testProgressFileDownloader.Download(It.IsAny<Uri>(), It.IsAny<string>(), false,It.IsAny<string>(), ""); //assert mockWebClient.Verify(c => c.DownloadFileAsync(It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<string>())); }