public void ProjectIsDirtyWhenAddingAssembly() { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly(); project.AddAssembly(assembly); Assert.True(project.IsDirty); }
public void AddedAssemblyIsPartOfAssemblyList() { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly(); project.AddAssembly(assembly); Assert.Contains(assembly, project.Assemblies); }
public void ProjectIsDirtyWhenRemovingAssembly() { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly(); project.AddAssembly(assembly); project.IsDirty = false; project.RemoveAssembly(assembly); Assert.True(project.IsDirty); }
// ReSharper disable PossibleMultipleEnumeration /// <summary> /// Executes the specified input streams. /// </summary> /// <param name="inputStreams">The input streams.</param> /// <returns>IEnumerable<PvcStream>.</returns> public override IEnumerable<PvcStream> Execute(IEnumerable<PvcStream> inputStreams) { var unit = new XunitProject(); foreach (var testAssembly in inputStreams.Select(x => x.OriginalSourcePath).Where(File.Exists)) { unit.AddAssembly(new XunitProjectAssembly { AssemblyFilename = testAssembly, ShadowCopy = true }); } unit.RunTestProject(_displaySuccess, _displayFailureStack); return inputStreams; }
public void ProjectIsMarkedCleanWhenSaved() { using (TempFile tempFile = new TempFile()) { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly { AssemblyFilename = @"C:\FooBar" }; project.AddAssembly(assembly); project.SaveAs(tempFile.Filename); Assert.False(project.IsDirty); } }
public void NullFilenameThrows() { XunitProject project = new XunitProject(); project.AddAssembly(new XunitProjectAssembly { AssemblyFilename = "foo" }); Assert.Throws<ArgumentNullException>(() => project.SaveAs(null)); }
public void FilenameIsUpdated() { using (TempFile tempFile = new TempFile()) { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly { AssemblyFilename = @"C:\FooBar" }; project.AddAssembly(assembly); project.SaveAs(tempFile.Filename); Assert.Equal(tempFile.Filename, project.Filename); } }
public void SaveAcceptanceTest() { string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <xunit> <assemblies> <assembly filename=""C:\AssemblyFilename"" config-filename=""C:\ConfigFilename"" shadow-copy=""true""> <output type=""xml"" filename=""C:\XmlFilename"" /> <output type=""html"" filename=""C:\HtmlFilename"" /> </assembly> <assembly filename=""C:\AssemblyFilename2"" config-filename=""C:\ConfigFilename2"" shadow-copy=""false""> <output type=""xml"" filename=""C:\XmlFilename2"" /> <output type=""html"" filename=""C:\HtmlFilename2"" /> </assembly> </assemblies> </xunit>"; using (TempFile tempFile = new TempFile()) { XunitProject project = new XunitProject { Filename = tempFile.Filename }; XunitProjectAssembly assembly1 = new XunitProjectAssembly(); assembly1.AssemblyFilename = @"C:\AssemblyFilename"; assembly1.ConfigFilename = @"C:\ConfigFilename"; assembly1.ShadowCopy = true; assembly1.Output.Add("xml", @"C:\XmlFilename"); assembly1.Output.Add("html", @"C:\HtmlFilename"); project.AddAssembly(assembly1); XunitProjectAssembly assembly2 = new XunitProjectAssembly(); assembly2.AssemblyFilename = @"C:\AssemblyFilename2"; assembly2.ConfigFilename = @"C:\ConfigFilename2"; assembly2.ShadowCopy = false; assembly2.Output.Add("xml", @"C:\XmlFilename2"); assembly2.Output.Add("html", @"C:\HtmlFilename2"); project.AddAssembly(assembly2); project.Save(); Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename)); } }
public void InvalidFilenameThrows() { XunitProject project = new XunitProject { Filename = @"C:\\" + Guid.NewGuid() + "\\" + Guid.NewGuid() }; project.AddAssembly(new XunitProjectAssembly { AssemblyFilename = "foo" }); Assert.Throws<DirectoryNotFoundException>(() => project.Save()); }
public void FilenamesAreRelativeToTheProjectLocation() { string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <xunit> <assemblies> <assembly filename=""C:\AssemblyFilename"" config-filename=""ConfigFilename"" shadow-copy=""true"" /> </assemblies> </xunit>"; using (TempFile tempFile = new TempFile()) { string directory = Path.GetDirectoryName(tempFile.Filename); XunitProject project = new XunitProject { Filename = tempFile.Filename }; project.AddAssembly( new XunitProjectAssembly { AssemblyFilename = @"C:\AssemblyFilename", ConfigFilename = Path.Combine(directory, "ConfigFilename") }); project.Save(); Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename)); } }
public void AssemblyFilenameOnly() { string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <xunit> <assemblies> <assembly filename=""C:\AssemblyFilename"" shadow-copy=""true"" /> </assemblies> </xunit>"; using (TempFile tempFile = new TempFile()) { XunitProject project = new XunitProject { Filename = tempFile.Filename }; project.AddAssembly( new XunitProjectAssembly { AssemblyFilename = @"C:\AssemblyFilename" }); project.Save(); Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename)); } }
public void NullAssemblyThrows() { XunitProject project = new XunitProject(); Assert.Throws<ArgumentNullException>(() => project.AddAssembly(null)); }
public void RemovesAssemblyFromAssembliesList() { XunitProject project = new XunitProject(); XunitProjectAssembly assembly = new XunitProjectAssembly(); project.AddAssembly(assembly); project.RemoveAssembly(assembly); Assert.DoesNotContain(assembly, project.Assemblies); }
public IEnumerable<AutoTest.TestRunners.Shared.Results.TestResult> Run(RunSettings settings) { var logger = new XUnitLogger(); XunitProject project = new XunitProject(); var runner = settings.Assembly; // Set assembly externally as XUnit screws up the casing logger.SetCurrentAssembly(runner.Assembly); XunitProjectAssembly assembly = new XunitProjectAssembly { AssemblyFilename = runner.Assembly, ConfigFilename = null, ShadowCopy = false }; project.AddAssembly(assembly); foreach (XunitProjectAssembly asm in project.Assemblies) { using (ExecutorWrapper wrapper = new ExecutorWrapper(asm.AssemblyFilename, asm.ConfigFilename, asm.ShadowCopy)) { try { var xunitRunner = new TestRunner(wrapper, logger); //Run all tests if (runner.Tests.Count() == 0 && runner.Members.Count() == 0 && runner.Namespaces.Count() == 0) xunitRunner.RunAssembly(); //Run tests if (runner.Tests.Count() > 0) { foreach (var test in runner.Tests) xunitRunner.RunTest(test.Substring(0, test.LastIndexOf(".")), test.Substring(test.LastIndexOf(".") + 1, test.Length - (test.LastIndexOf(".") + 1))); } //Run members if (runner.Members.Count() > 0) { foreach (var member in runner.Members) xunitRunner.RunClass(member); } //Run namespaces if (runner.Namespaces.Count() > 0) { var loadedAssembly = Assembly.LoadFrom(runner.Assembly); var types = loadedAssembly.GetExportedTypes(); loadedAssembly = null; foreach (var ns in runner.Namespaces) { foreach (Type type in types) if (ns == null || type.Namespace == ns) xunitRunner.RunClass(type.FullName); } } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } } return logger.Results; }
public void SaveAcceptanceTest() { string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine + @"<xunit2>" + Environment.NewLine + @" <assembly filename=""C:\AssemblyFilename"" config-filename=""C:\ConfigFilename"" shadow-copy=""true"" />" + Environment.NewLine + @" <assembly filename=""C:\AssemblyFilename2"" config-filename=""C:\ConfigFilename2"" shadow-copy=""false"" />" + Environment.NewLine + @" <output type=""xml"" filename=""C:\XmlFilename"" />" + Environment.NewLine + @" <output type=""html"" filename=""C:\HtmlFilename"" />" + Environment.NewLine + @"</xunit2>"; using (var tempFile = new TempFile()) { var project = new XunitProject { Filename = tempFile.Filename }; project.Output.Add("xml", @"C:\XmlFilename"); project.Output.Add("html", @"C:\HtmlFilename"); project.AddAssembly(new XunitProjectAssembly() { AssemblyFilename = @"C:\AssemblyFilename", ConfigFilename = @"C:\ConfigFilename", ShadowCopy = true }); project.AddAssembly(new XunitProjectAssembly() { AssemblyFilename = @"C:\AssemblyFilename2", ConfigFilename = @"C:\ConfigFilename2", ShadowCopy = false }); project.Save(); Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename)); } }
public void AssemblyFilenameOnly() { string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine + @"<xunit2>" + Environment.NewLine + @" <assembly filename=""C:\AssemblyFilename"" shadow-copy=""true"" />" + Environment.NewLine + @"</xunit2>"; using (var tempFile = new TempFile()) { var project = new XunitProject { Filename = tempFile.Filename }; project.AddAssembly(new XunitProjectAssembly { AssemblyFilename = @"C:\AssemblyFilename" }); project.Save(); Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename)); } }