public void executes_postman_generatetask() { // Arrange var mock = new Mock<IBuildEngine>(); var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase); var assemblyFilePath = codeBase.LocalPath; var task = new GenerateTask { AssemblyFilePath = assemblyFilePath, OutputDirectory = @".\", BuildEngine = mock.Object }; File.Delete(task.OutputFilePath); // Act var actual = task.Execute(); // Assert actual.Should().BeTrue(); File.Exists(task.OutputFilePath).Should().BeTrue(); AssertOutputFile(task.OutputFilePath); }
public void throws_filenotfoundexception_when_no_assembly_file_found() { // Arrange var mock = new Mock<IBuildEngine>(); GenerateTask task = new GenerateTask { AssemblyFilePath = "c:\badpath\file.dll", OutputDirectory = @".\", BuildEngine = mock.Object }; // Act/Assert Assert.That(() => task.Execute(), Throws.TypeOf<FileNotFoundException>()); }
public void throws_filenotfoundexception_when_no_xml_doc_file_found() { // Arrange var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase); var assemblyFilePath = codeBase.LocalPath; var mock = new Mock<IBuildEngine>(); GenerateTask task = new GenerateTask { AssemblyFilePath = assemblyFilePath, OutputDirectory = @".\", BuildEngine = mock.Object }; var xmlFile = task.AssemblyFilePath.Replace(Resources.DllFileExtension, Resources.XmlFileExtension); var tmpFile = @"tmp.xml"; File.Move(xmlFile, tmpFile); // Act/Assert Assert.That(() => task.Execute(), Throws.TypeOf<FileNotFoundException>()); File.Move(tmpFile, xmlFile); }
public void throws_argumentnullexception_when_assemblyfilepath_unspecified() { // Arrange var mock = new Mock<IBuildEngine>(); GenerateTask task = new GenerateTask { BuildEngine = mock.Object }; // Act/Assert Assert.That(() => task.Execute(), Throws.TypeOf<ArgumentNullException>()); }