public void ReturnsValidValidationResults(string deployRoot, long freeSpace, ValidatorState expectedResult, string resultMessage)
        {
            //Arrange
            Task task = Substitute.For <Task>("", 0, null, new List <InstallParam>(), new Dictionary <string, string>());

            task.LocalParams.Returns(new List <InstallParam>());
            InstallParam deployRootParam = new InstallParam("DeployRoot", deployRoot);

            task.LocalParams.Add(deployRootParam);

            List <Task> tasks = Substitute.For <List <Task> >();

            tasks.Add(task);

            DiskSpaceValidator val = Substitute.ForPartsOf <DiskSpaceValidator>();

            val.GetHardDriveFreeSpace(string.Empty).ReturnsForAnyArgs(freeSpace);

            val.Data["HardDriveWarningLimit"] = "5368709120";
            val.Data["HardDriveErrorLimit"]   = "3221225472";
            val.Data["DeployRoot"]            = "DeployRoot";
            //Act
            IEnumerable <ValidationResult> results = val.Evaluate(tasks);

            //Assert
            Assert.Contains(results, r => r.State == expectedResult && r.Message == resultMessage);
        }
Exemple #2
0
 // Token: 0x060001EA RID: 490 RVA: 0x0000B528 File Offset: 0x00009728
 public void StartDownloading()
 {
     try
     {
         using (DiskSpaceValidator diskSpaceValidator = new DiskSpaceValidator(500000000L, Environment.GetEnvironmentVariable("windir"), new Action <object>(this.UpdateDownloadUpdatesStatusBox)))
         {
             if (!diskSpaceValidator.Validate())
             {
                 throw new LanguagePackBundleLoadException(Strings.NotEnoughDiskSpace);
             }
         }
         List <DownloadFileInfo> downloadFileInfoFromXml = LanguagePackXmlHelper.GetDownloadFileInfoFromXml(this.localXMLVersioningPath, false);
         if (downloadFileInfoFromXml != null && downloadFileInfoFromXml.Count > 0)
         {
             if (Directory.Exists(this.downloadToDirectory))
             {
                 Directory.Delete(this.downloadToDirectory, true);
             }
             Directory.CreateDirectory(this.downloadToDirectory);
             this.webFileDownloader.StartDownloading(downloadFileInfoFromXml, this.downloadToDirectory);
         }
         else
         {
             this.UpdateDownloadUpdatesStatusBox(new LanguagePackBundleLoadException(Strings.InvalidLocalLPVersioningXML(this.localXMLVersioningPath)));
         }
     }
     catch (LanguagePackBundleLoadException message)
     {
         this.UpdateDownloadUpdatesStatusBox(message);
     }
     catch (LPVersioningValueException message2)
     {
         this.UpdateDownloadUpdatesStatusBox(message2);
     }
 }