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 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 EmptyProjectThrows() { using (var tempFile = new TempFile()) { var project = new XunitProject { Filename = tempFile.Filename }; Assert.Throws <InvalidOperationException>(() => project.Save()); } }
public void InvalidFilenameThrows() { var project = new XunitProject { Filename = @"C:\\" + Guid.NewGuid() + "\\" + Guid.NewGuid() }; project.AddAssembly(new XunitProjectAssembly { AssemblyFilename = "foo" }); Assert.Throws <DirectoryNotFoundException>(() => project.Save()); }
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 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)); } }