public void PassingTest() { string code = @" using Xunit; public class MockTest { [Fact] public void TestMethod() { } } "; using (MockAssembly mockAssembly = new MockAssembly()) { mockAssembly.Compile(code); xunit task = new xunit { Assembly = new TaskItem(mockAssembly.FileName), BuildEngine = new StubBuildEngine() }; task.Execute(); Assert.Equal(0, task.ExitCode); } }
public void InvalidAssemblyName() { xunit task = new xunit { Assembly = new TaskItem(Guid.NewGuid().ToString()), BuildEngine = new StubBuildEngine() }; task.Execute(); Assert.Equal(-1, task.ExitCode); }
public void ConsoleRunnerPreservesCurrentDirectoryForXmlOutput() { string code = @" using System.IO; using Xunit; public class ChangeDirectoryTests { [Fact] public void ChangeDirectory() { Directory.SetCurrentDirectory(Path.GetTempPath()); } } "; using (MockAssembly mockAssembly = new MockAssembly()) { mockAssembly.Compile(code); string workingDirectory = Directory.GetCurrentDirectory(); string xmlFilename = Path.GetFileName(mockAssembly.FileName) + ".xml"; string fullPathName = Path.Combine(workingDirectory, xmlFilename); xunit task = new xunit { Assembly = new TaskItem(mockAssembly.FileName), Xml = new TaskItem(xmlFilename), BuildEngine = new StubBuildEngine() }; task.Execute(); Assert.True(File.Exists(fullPathName)); File.Delete(fullPathName); } }