public void Execute_Ok_MultipleProjectGenConfig() { var projectName = "Test"; string projectFile = $@"TestProject\{projectName}.csproj"; DestinationPath = @".\TestData\tmp\TestProject"; OutputPath = @".\TestData\tmp\"; ProjectName = projectName; GenContext.Current = this; Directory.CreateDirectory(GenContext.Current.DestinationPath); File.Copy(Path.Combine(Environment.CurrentDirectory, $"TestData\\{projectFile}"), Path.Combine(GenContext.Current.OutputPath, projectFile), true); Dictionary <string, string> testArgs = new Dictionary <string, string>(); testArgs.Add("files", "0"); List <FakeCreationPath> testPrimaryOutputs = new List <FakeCreationPath>(); testPrimaryOutputs.Add(new FakeCreationPath() { Path = projectFile }); IPostAction templateDefinedPostAction = new FakeTemplateDefinedPostAction(GenerateTestCertificatePostAction.Id, testArgs, true); var postAction = new GenerateTestCertificatePostAction("TestTemplate", "TestUser", templateDefinedPostAction, testPrimaryOutputs as IReadOnlyList <ICreationPath>, new Dictionary <string, string>()); postAction.Execute(); var expectedCertFilePath = Path.Combine(GenContext.Current.DestinationPath, $"{projectName}_TemporaryKey.pfx"); Assert.True(File.Exists(expectedCertFilePath)); Fs.SafeDeleteDirectory(DestinationPath); }
public void Execute_Ok() { GenContext.Bootstrap(new UnitTestsTemplatesSource(), new FakeGenShell()); var projectName = "test"; ProjectName = projectName; OutputPath = @".\TestData\tmp"; GenContext.Current = this; Directory.CreateDirectory(GenContext.Current.OutputPath); File.Copy(Path.Combine(Environment.CurrentDirectory, "TestData\\TestProject\\Test.csproj"), Path.Combine(GenContext.Current.OutputPath, "Test.csproj"), true); var postAction = new GenerateTestCertificatePostAction("TestUser"); postAction.Execute(); var certFilePath = Path.Combine(GenContext.Current.OutputPath, $"{projectName}_TemporaryKey.pfx"); Assert.True(File.Exists(certFilePath)); File.Delete(certFilePath); }
public void BadInstantiation_NoContinueOnError() { ProjectName = "test4"; Assert.Throws <Exception>(() => { Dictionary <string, string> testArgs = new Dictionary <string, string>(); testArgs.Add("myArg", "myValue"); IPostAction inventedIdPostAction = new FakeTemplateDefinedPostAction(Guid.NewGuid(), testArgs, false); var postAction = new GenerateTestCertificatePostAction("TestTemplate", "TestUser", inventedIdPostAction, null, new Dictionary <string, string>()); }); }
public void BadInstantiation_ContinueOnError() { ProjectName = "test3"; Dictionary <string, string> testArgs = new Dictionary <string, string>(); testArgs.Add("myArg", "myValue"); IPostAction inventedIdPostAction = new FakeTemplateDefinedPostAction(Guid.NewGuid(), testArgs, true); var postAction = new GenerateTestCertificatePostAction("TestTemplate", "TestUser", inventedIdPostAction, null, new Dictionary <string, string>()); Assert.True(postAction.ContinueOnError); Assert.NotEqual(inventedIdPostAction.ActionId, GenerateTestCertificatePostAction.Id); Assert.Null(postAction.Args); }
public void GenerateTestCertificate_Execute_Ok_SingleProjectGenConfigs() { var projectName = "Test"; var projectFile = $"{projectName}.csproj"; var destinationPath = @".\TestData\temp\TestProject"; var generationOutputPath = @".\TestData\temp\TestProject"; GenContext.Bootstrap(new LocalTemplatesSource(), new FakeGenShell(Platforms.Uwp, ProgrammingLanguages.CSharp), Platforms.Uwp, ProgrammingLanguages.CSharp); GenContext.Current = new FakeContextProvider { DestinationPath = destinationPath, GenerationOutputPath = generationOutputPath, }; Directory.CreateDirectory(generationOutputPath); var sourceFile = Path.Combine(Environment.CurrentDirectory, $"TestData\\TestProject\\{projectFile}"); var destFile = Path.Combine(generationOutputPath, projectFile); File.Copy(sourceFile, destFile, true); var testArgs = new Dictionary <string, string> { { "files", "0" }, }; var testPrimaryOutputs = new List <FakeCreationPath>() { new FakeCreationPath() { Path = projectFile }, }; var templateDefinedPostAction = new FakeTemplateDefinedPostAction(new Guid(GenerateTestCertificatePostAction.Id), testArgs, true); var postAction = new GenerateTestCertificatePostAction("TestTemplate", "TestUser", templateDefinedPostAction, testPrimaryOutputs as IReadOnlyList <ICreationPath>, new Dictionary <string, string>(), destinationPath); postAction.Execute(); var expectedCertFilePath = Path.Combine(generationOutputPath, $"{projectName}_TemporaryKey.pfx"); Assert.True(File.Exists(expectedCertFilePath)); Fs.SafeDeleteDirectory(generationOutputPath); }