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); }
public void finds_manifest_in_multi_level_tree() { // module name const string moduleName = "moduleName"; // create sub folder const string folderName = "folderName"; string folderPathCreated = Path.Combine(_testDirectory, folderName); Directory.CreateDirectory(folderPathCreated); // create name for manifest string pathToManifest = Path.Combine(folderPathCreated, "SOME_ITCHY_NAME" + ModuleManifest.ManifestFileNameSuffix); // put manifest there var manifest = new ModuleManifest() { ModuleName = moduleName }; var data = XmlSerializerHelper.Serialize(manifest); File.WriteAllBytes(pathToManifest, data); // create package with manifest of the same name var package = GetPackageWithName(moduleName); // run test var folderPathResolved = _moduleFinder.FindDirectoryForPackage(_testDirectory, package); // assert that path to sub folder has been returned Assert.AreEqual(folderPathResolved, folderPathCreated, "The path to folder was not found properly"); }
public void publishes_avaliable_modules_message_when_everything_is_ok() { const string assembly = "test_assembly.dll"; var moduleInfo = new ModuleInfo(assembly); var moduleManifest = new ModuleManifest { ModuleName = assembly, ModuleVersion = new Version("0.0.0.0") }; var updateManifest = new ModuleManifest { ModuleName = assembly, ModuleVersion = new Version("0.0.0.1") }; ModuleDiscovery.Setup(x => x.GetModules()).Returns(new List<ModuleInfo> { moduleInfo }); // FIXME: this should use internal manifest factory ModuleManifestFactory.Setup(x => x.GetManifest(It.Is<ModuleInfo>(y => y == moduleInfo))) .Returns(moduleManifest); EventAggregator.Setup(x => x.Publish(It.IsAny<NomadAvailableUpdatesMessage>())) .Callback<NomadAvailableUpdatesMessage>(msg => { Assert.AreEqual(1, msg.AvailableUpdates. Count); Assert.AreEqual(updateManifest, msg.AvailableUpdates. First()); }) .Returns(null) .Verifiable("Message was not published"); ModulesRepository .Setup(x => x.GetAvailableModules()) .Returns(new AvailableModules { Manifests = new List<ModuleManifest> {updateManifest} }) .Verifiable("Get Avaliable modules has not been called"); NomadUpdater.CheckUpdates(); ModulesRepository.Verify(); EventAggregator.Verify(); }
public IModuleInfo GenerateModuleInfo() { AssemblyName asmName = AssemblyName.GetAssemblyName(AssemblyFilePath); var manifest = new ModuleManifest { ModuleName = asmName.Name, ModuleVersion = new Version(asmName.Version), }; // get the moduleInfo but so called virtual implementation ModuleInfo = new ModuleInfo { Manifest = manifest, ModuleData = File.ReadAllBytes(AssemblyFilePath), }; return ModuleInfo; }
public void discovers_all_assemblies_from_given_directory_and_ignores_other_files() { var manifestFactoryMock = new Mock<IModuleManifestFactory>(MockBehavior.Loose); var manifest = new ModuleManifest(); manifestFactoryMock.Setup(x => x.GetManifest(It.IsAny<ModuleInfo>())).Returns(manifest); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"IntegrationTests\DirectoryModuleDiscovery\"); var expectedModules = new[] { new ModuleInfo(Path.Combine(path, "a.dll"),manifestFactoryMock.Object), new ModuleInfo(Path.Combine(path, "b.dll"),manifestFactoryMock.Object), }; var discovery = new Nomad.Modules.Discovery.SimpleDirectoryModuleDiscovery(path); Assert.That(discovery.GetModules().ToArray(), Is.EquivalentTo(expectedModules), "Discovered modules differ from expected"); }
public void set_up() { _moduleName = "test_module.dll"; var moduleVersion = new Nomad.Utils.Version("0.1.1.0"); _moduleManifest = new ModuleManifest { ModuleName = _moduleName, ModuleVersion = moduleVersion }; // sick creating of dependency checker IEnumerable<ModuleInfo> outter = new List<ModuleInfo>(); DependencyChecker.Setup( x => x.CheckModules(It.IsAny<IEnumerable<ModuleInfo>>(), It.IsAny<IEnumerable<ModuleInfo>>(), out outter)) .Returns(true); }
private static string AddManifestFile() { // generate manifest for SimplestModulePossible file var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible1.dll", @"Modules\Simple"); _manifest = builder.CreateAndPublish(); return @"Modules\Simple\SimplestModulePossible1.dll" + ModuleManifest.ManifestFileNameSuffix; }
public WebModulePackageInfo(ModuleManifest manifest, string url) { Manifest = manifest; Url = url; }
public void set_up() { _simpleManifest = new ModuleManifest(); _moduleManifestMock = new Mock<IModuleManifestFactory>(MockBehavior.Loose); _moduleManifestMock.Setup(x => x.GetManifest(It.IsAny<ModuleInfo>())).Returns( _simpleManifest); _dependencyMock = new Mock<IDependencyChecker>(MockBehavior.Loose); _dependencyMock.Setup(x => x.SortModules(It.IsAny<IEnumerable<ModuleInfo>>())) .Returns<IEnumerable<ModuleInfo>>(e => e); _moduleFilterMock = new Mock<IModuleFilter>(MockBehavior.Loose); _moduleFilterMock.Setup(x => x.Matches(It.IsAny<ModuleInfo>())).Returns(true); }