private UpdateCollectionFake GenerateUpdateCollection() { int updateCount = _rnd.Next(3, 10); UpdateCollectionFake coll = new UpdateCollectionFake(); for (int i = 0; i < updateCount; i++) { var update = new Update3Fake(Guid.NewGuid().ToString(), _rnd.Next(2) == 0); update.Title = "Simulated update " + i; update.Description = "This is for test scenarios. No changes on the system when this update gets installed."; update.MinDownloadSize = _rnd.Next(1000, 1000000); update.MaxDownloadSize = _rnd.Next(1000, 100000) + update.MinDownloadSize; update.RecommendedHardDiskSpace = (int)update.MaxDownloadSize; update.IsDownloaded = false; update.IsInstalled = false; coll.Add(update); } return(coll); }
public WuApiSimulator Configure() { if (IsReady) { throw new InvalidOperationException("Simulation is already configured"); } _updates = GenerateUpdateCollection(); var uSearcher = new UpdateSearcherFake(); uSearcher.FakeSearchResult = CommonMocks.GetSearchResult(_updates, OperationResultCode.orcSucceeded); uSearcher.FakeSearchTimeMs = (_searchTimeMs == 0)?_rnd.Next(10000, 20000):_searchTimeMs; var uDownloader = new UpdateDownloaderFake(); uDownloader.FakeDownloadTimeMs = (_downloadTimeMs == 0) ? _rnd.Next(10000, 20000) : _downloadTimeMs; var uInstaller = new UpdateInstallerFake(); uInstaller.FakeInstallTimeMs = (_installTimeMs == 0) ? _rnd.Next(10000, 20000) : _installTimeMs; _uSession = new UpdateSessionFake(false); _uSession.Downloader = uDownloader; _uSession.Searcher = uSearcher; _uSession.Installer = uInstaller; IsReady = true; return(this); }