public void PrintCommand_WithProcessNotFinishing_GetsKilled() { string tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); var printCommand = new PrintCommand(tempFile, "SomePrinter"); var factory = new MockProcessWrapperFactory(false); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsFalse(printCommand.Successful); Assert.IsTrue(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidTextFile_PrintsSuccessfully() { string tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); var printCommand = new PrintCommand(tempFile, "SomePrinter"); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.IsFalse(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidPrintOnlyFile_PrintsSuccessfully() { string tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.ini"); var printerHelper = new PrinterHelper(); var printCommand = new PrintCommand(tempFile, printerHelper.GetDefaultPrinter()); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.IsFalse(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidPrintOnlyFile_HasCorrectStartInfo() { string tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.ini"); var printerHelper = new PrinterHelper(); var printCommand = new PrintCommand(tempFile, printerHelper.GetDefaultPrinter()); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.AreEqual(tempFile, factory.LastMock.StartInfo.FileName); Assert.IsNullOrEmpty(factory.LastMock.StartInfo.Arguments); }
public void PrintCommand_GivenValidTextFile_HasCorrectStartInfo() { string tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); const string printer = "SomePrinter"; var printCommand = new PrintCommand(tempFile, printer); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.AreEqual(tempFile, factory.LastMock.StartInfo.FileName); Assert.AreEqual("\"" + printer + "\"", factory.LastMock.StartInfo.Arguments); }
public void Group_WithManyFiles_PrintsEveryFile() { var printCommandGroup = new PrintCommandGroup(); var factory = new MockProcessWrapperFactory(true); printCommandGroup.ProcessWrapperFactory = factory; const string printer = "SomePrinter"; printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test1.txt"), printer)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test2.txt"), printer)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test3.txt"), printer)); printCommandGroup.PrintAll(); foreach (var mock in factory.CreatedMocks) { Assert.IsTrue(mock.WasStarted, "Print Process was not started for " + mock.StartInfo.FileName); } Assert.AreEqual(printCommandGroup.Count(), factory.CreatedMocks.Count); }
public void Group_WithManyFilesAndOneUnprintableFile_PrintThrowsExceptionWithoutPrintingOneFile() { var printCommandGroup = new PrintCommandGroup(); var factory = new MockProcessWrapperFactory(true); printCommandGroup.ProcessWrapperFactory = factory; const string printer = "SomePrinter"; printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test.txt"), printer)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test.invalid"), printer)); try { printCommandGroup.PrintAll(); } catch (InvalidOperationException) { } Assert.IsEmpty(factory.CreatedMocks); }