public void DeployTest() { Info MutantInfo = new Info(); MutantInfo.URL = "Test"; MutantInfo.Username = "******"; MutantInfo.Password = "******"; MutantInfo.WorkingDirectory = "Test"; string CurrentDirectory = Directory.GetCurrentDirectory(); using (StreamWriter file = File.CreateText(CurrentDirectory + @"\.credentials")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, MutantInfo); } ArtificerFactory artificerFactory = new ArtificerFactory(); Artificer selective = artificerFactory.GetArtificer("Selective"); TestLevelFactory testFactory = new TestLevelFactory(); ITestLevel none = testFactory.CreateTestLevel("None"); Deployment deployment = new Deployment(none, selective); try { deployment.Deploy(); } catch (Exception) { Console.WriteLine("Expected ex."); } }
public void CreateArtifactTest() { Info MutantInfo = new Info { URL = "Test", Username = "******", Password = "******", WorkingDirectory = Directory.GetCurrentDirectory() + "\\" }; string CurrentDirectory = Directory.GetCurrentDirectory(); using (StreamWriter file = File.CreateText(CurrentDirectory + @"\.credentials")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, MutantInfo); } ArtificerFactory Factory = new ArtificerFactory(); Artificer artificer = Factory.GetArtificer("Selective"); artificer.CreateArtifact(); Assert.IsTrue(Directory.Exists(@"deploy\artifacts")); }
public override int Run(string[] remainingArguments) { try { TestLevelFactory TestLevel = new TestLevelFactory(); ITestLevel tests = TestLevel.CreateTestLevel(TestType); ArtificerFactory ArtificerFactory = new ArtificerFactory(); Artificer artificer = ArtificerFactory.GetArtificer(ArtificeType); artificer.BaseCommit = BaseCommit; Deployment deployment = new Deployment(tests, artificer); deployment.Deploy(); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } return(0); }
public void CreateWithBaseCommit() { Info MutantInfo = new Info { URL = "Test", Username = "******", Password = "******", WorkingDirectory = @"C:\temp\MutantTests" }; if (Directory.Exists(MutantInfo.WorkingDirectory + @"\.git\")) { Console.WriteLine("Deleteing .git"); DeleteDirectory(MutantInfo.WorkingDirectory + @"\.git\"); } if (Directory.Exists(MutantInfo.WorkingDirectory + @"\src\")) { Console.WriteLine("Deleteing src"); DeleteDirectory(MutantInfo.WorkingDirectory + @"\src\"); } if (Directory.Exists(MutantInfo.WorkingDirectory + @"\deploy\")) { Console.WriteLine("Deleteing deploy"); DeleteDirectory(MutantInfo.WorkingDirectory + @"\deploy\"); } Directory.CreateDirectory(MutantInfo.WorkingDirectory); Directory.SetCurrentDirectory(MutantInfo.WorkingDirectory); using (StreamWriter file = File.CreateText(MutantInfo.WorkingDirectory + @"\.credentials")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, MutantInfo); } Collection <PSObject> results = new Collection <PSObject>(); results = RunPowershellCommand("git init", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git config user.name \"Alex Morrison\"", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git config user.email \"[email protected]\"", MutantInfo.WorkingDirectory); Directory.CreateDirectory(MutantInfo.WorkingDirectory + @"\src\classes"); File.Create(Directory.GetCurrentDirectory() + @"\src\package.xml"); using (File.Create(MutantInfo.WorkingDirectory + @"\src\classes\test1.cls")) { } using (File.Create(MutantInfo.WorkingDirectory + @"\src\classes\test1.cls-meta.xml")) { } results = RunPowershellCommand("git update-index --no-assume-unchanged " + MutantInfo.WorkingDirectory + @"\src\classes\test1.cls", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git add -f " + MutantInfo.WorkingDirectory + @"\src\classes\test1.cls", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git commit -m \"some\"", MutantInfo.WorkingDirectory); using (File.Create(MutantInfo.WorkingDirectory + @"\src\classes\test2.cls")) { } using (File.Create(MutantInfo.WorkingDirectory + @"\src\classes\test2.cls-meta.xml")) { } results = RunPowershellCommand("git update-index --no-assume-unchanged " + MutantInfo.WorkingDirectory + @"\src\classes\test2.cls", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git add -f " + MutantInfo.WorkingDirectory + @"\src\classes\test2.cls", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git commit -m \"testagain\"", MutantInfo.WorkingDirectory); results = RunPowershellCommand("git log --pretty=format:%H", MutantInfo.WorkingDirectory); string BaseCommit = results[1].ToString(); ArtificerFactory Factory = new ArtificerFactory(); Artificer artificer = Factory.GetArtificer("Selective"); artificer.BaseCommit = BaseCommit; artificer.CreateArtifact(); Assert.IsTrue(File.Exists(MutantInfo.WorkingDirectory + @"\deploy\artifacts\src\classes\test1.cls")); Assert.IsTrue(File.Exists(MutantInfo.WorkingDirectory + @"\deploy\artifacts\src\classes\test2.cls")); }