public void performing_updates_has_information_about_failure_modules_operations_throws() { ModulesOperations.Setup(x => x.LoadModules(It.IsAny <IModuleDiscovery>())) .Throws(new Exception("Can not discovery moduels")); var moduleManifests = new List <ModuleManifest> { new ModuleManifest(), }; // preapre stub module manifest NomadUpdater.PrepareUpdate(moduleManifests); ModulesRepository.Setup(x => x.GetModule(It.IsAny <string>())) .Returns(new ModulePackage() { ModuleManifest = moduleManifests[0] }); NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); // wait till end to get the information about failure NomadUpdater.UpdateFinished.WaitOne(); Assert.AreEqual(UpdaterStatus.Invalid, NomadUpdater.Status); }
public void performing_updates_uses_packager_on_n_packages_exactly_n_times(int times) { int n = times; IList <ModuleManifest> modulePackages = new List <ModuleManifest>(); for (int i = 0; i < n; i++) { modulePackages.Add(new ModuleManifest() { ModuleName = "Test" + i }); } // provide the proper packages per modules ModulesRepository.Setup(x => x.GetModule(It.IsAny <string>())) .Returns <string>(name => new ModulePackage() { ModuleManifest = modulePackages .Where(x => x.ModuleName.Equals(name)) .Select(x => x).Single() }); NomadUpdater.PrepareUpdate(modulePackages); NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); NomadUpdater.UpdateFinished.WaitOne(); ModulePackager.Verify(x => x.PerformUpdates(PluginsDir, It.IsAny <ModulePackage>()), Times.Exactly(n), string.Format("One package should be invoked {0} times.", n)); }
public void performing_updates_has_information_about_success() { NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); NomadUpdater.UpdateFinished.WaitOne(); Assert.AreEqual(UpdaterStatus.Idle, NomadUpdater.Status); }
public void performing_updates_unload_modules() { NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); NomadUpdater.UpdateFinished.WaitOne(); ModulesOperations.Verify(x => x.UnloadModules(), Times.Exactly(1)); }
public void performing_updates_has_information_about_failure_packager_throws() { ModulePackager.Setup( x => x.PerformUpdates(It.IsAny <String>(), It.IsAny <ModulePackage>())) .Throws(new Exception("Can not pacakge this")); var manifest = new ModuleManifest() { ModuleName = "AlaMaKota" }; var moduleManifests = new List <ModuleManifest> { manifest, }; ModulesRepository.Setup(x => x.GetModule(It.IsAny <string>())) .Returns(new ModulePackage() { ModuleManifest = manifest }); // preapre stub module manifest NomadUpdater.PrepareUpdate(moduleManifests); ModulesRepository.Setup(x => x.GetModule(It.IsAny <string>())) .Returns(new ModulePackage() { ModuleManifest = moduleManifests[0] }); NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); // wait till end to get the information about failure NomadUpdater.UpdateFinished.WaitOne(); Assert.AreEqual(UpdaterStatus.Invalid, NomadUpdater.Status); }