private void PrepareModulesTestDirectories(string testPath, string moduleAPath, string moduleBPath) { if (Directory.Exists(testPath)) { Directory.Delete(testPath, true); } Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = moduleAPath; compiler.OutputName = Path.Combine(moduleAPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputDirectory = moduleBPath; compiler.OutputName = Path.Combine(moduleBPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", moduleAPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", moduleBPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(moduleAPath, @"a.dll"), Path.Combine(testPath, "c.dll")); }
private static void GenerateManifestUsingApi(string assemblyName, string path) { var builder = new ManifestBuilder(@"TUTORIAL_ISSUER", @"..\..\KEY_FILE.xml", assemblyName, path); builder.CreateAndPublish(); }
private void SignUsedModules() { var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible1.dll", @"Modules\Simple\"); builder.CreateAndPublish(); builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible2.dll", @"Modules\Simple\"); builder.CreateAndPublish(); }
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); }
/// <summary> /// Wrapps the generating manifest with values that should be provided. Provides access to <paramref name="configuration"/>. /// </summary> /// <param name="modulePath"></param> /// <param name="keyLocation"></param> /// <param name="configuration"></param> /// <returns></returns> public string GenerateManifestForModule(string modulePath, string keyLocation, ManifestBuilderConfiguration configuration) { string directory = Path.GetFullPath(Path.GetDirectoryName(modulePath)); var builder = new ManifestBuilder("TEST_ISSUER_COMPILER", keyLocation, Path.GetFileName(modulePath), directory, KeyStorage.Nomad, string.Empty, configuration); builder.CreateAndPublish(); return(modulePath + ModuleManifest.ManifestFileNameSuffix); }
public void discovers_all_proper_modules_with_manifests_ignores_others_assemblies() { // make another folder string testPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"IntegrationTests\DirectoryModuleDiscovery2\"); if (Directory.Exists(testPath)) { Directory.Delete(testPath, true); } Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = testPath; compiler.OutputName = Path.Combine(testPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputName = Path.Combine(testPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", testPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", testPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(testPath, @"a.dll"), Path.Combine(testPath, "c.dll")); var expectedModules = new[] { new ModuleInfo(Path.Combine(testPath, "a.dll")), new ModuleInfo(Path.Combine(testPath, "b.dll")), }; var discovery = new Nomad.Modules.Discovery.DirectoryModuleDiscovery(testPath, SearchOption.TopDirectoryOnly); Assert.That(discovery.GetModules().ToArray(), Is.EquivalentTo(expectedModules), "Discovered modules differ from expected"); }
private static void BuildModule() { // some remarkable constancies, we are using sample module from psake build const string issuerName = @"TEST_ISSUER"; const string issuerXmlPath = @"TEST_XML_KEY_FILE.xml"; const string assemblyName = @"Modules\Simple\SimplestModulePossible1.dll"; // get the key file KeysGeneratorProgram.Main(new[] { Path.Combine(FolderPath, issuerXmlPath) }); // get the assembly file into test folder File.Copy(assemblyName, Path.Combine(FolderPath, Path.GetFileName(assemblyName)), true); // NOTE: we are using here default builder configuration for simplicity of the test var manifestBuilder = new ManifestBuilder(issuerName, Path.Combine(FolderPath, issuerXmlPath), Path.GetFileName(assemblyName), FolderPath, KeyStorage.Nomad, string.Empty, ManifestBuilderConfiguration.Default); manifestBuilder.CreateAndPublish(); }
protected void SignModule(string name, string path) { var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, name, path); builder.CreateAndPublish(); }
public void discovers_all_proper_modules_with_manifests_ignores_others_assemblies() { // make another folder string testPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"IntegrationTests\DirectoryModuleDiscovery2\"); if (Directory.Exists(testPath)) Directory.Delete(testPath, true); Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = testPath; compiler.OutputName = Path.Combine(testPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputName = Path.Combine(testPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", testPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", testPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(testPath, @"a.dll"), Path.Combine(testPath, "c.dll")); var expectedModules = new[] { new ModuleInfo(Path.Combine(testPath, "a.dll")), new ModuleInfo(Path.Combine(testPath, "b.dll")), }; var discovery = new Nomad.Modules.Discovery.DirectoryModuleDiscovery(testPath,SearchOption.TopDirectoryOnly); Assert.That(discovery.GetModules().ToArray(), Is.EquivalentTo(expectedModules), "Discovered modules differ from expected"); }
private void PrepareModulesTestDirectories(string testPath, string moduleAPath, string moduleBPath) { if (Directory.Exists(testPath)) Directory.Delete(testPath, true); Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = moduleAPath; compiler.OutputName = Path.Combine(moduleAPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputDirectory = moduleBPath; compiler.OutputName = Path.Combine(moduleBPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", moduleAPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", moduleBPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(moduleAPath, @"a.dll"), Path.Combine(testPath, "c.dll")); }
/// <summary> /// Wrapps the generating manifest with values that should be provided. Provides access to <paramref name="configuration"/>. /// </summary> /// <param name="modulePath"></param> /// <param name="keyLocation"></param> /// <param name="configuration"></param> /// <returns></returns> public string GenerateManifestForModule(string modulePath, string keyLocation, ManifestBuilderConfiguration configuration) { string directory = Path.GetFullPath(Path.GetDirectoryName(modulePath)); var builder = new ManifestBuilder("TEST_ISSUER_COMPILER", keyLocation, Path.GetFileName(modulePath), directory, KeyStorage.Nomad, string.Empty, configuration); builder.CreateAndPublish(); return modulePath + ModuleManifest.ManifestFileNameSuffix; }
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; }
private static void BuildModule() { // some remarkable constancies, we are using sample module from psake build const string issuerName = @"TEST_ISSUER"; const string issuerXmlPath = @"TEST_XML_KEY_FILE.xml"; const string assemblyName = @"Modules\Simple\SimplestModulePossible1.dll"; // get the key file KeysGeneratorProgram.Main(new[] { Path.Combine(FolderPath, issuerXmlPath) }); // get the assembly file into test folder File.Copy(assemblyName, Path.Combine(FolderPath, Path.GetFileName(assemblyName)),true); // NOTE: we are using here default builder configuration for simplicity of the test var manifestBuilder = new ManifestBuilder(issuerName, Path.Combine(FolderPath, issuerXmlPath), Path.GetFileName(assemblyName), FolderPath, KeyStorage.Nomad, string.Empty, ManifestBuilderConfiguration.Default); manifestBuilder.CreateAndPublish(); }