public void PrintCommand_GivenValidPrintOnlyFile_PrintsSuccessfully() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.ini"); var printCommand = new PrintCommand(tempFile, _printerHelper.GetDefaultPrinter(), new FileAssoc(), _printerHelper, _timeOut); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.IsFalse(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidPrintOnlyFile_HasCorrectStartInfo() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.ini"); var printCommand = new PrintCommand(tempFile, _printerHelper.GetDefaultPrinter(), new FileAssoc(), _printerHelper, _timeOut); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); StringAssert.Contains(tempFile, factory.LastMock.StartInfo.Arguments); }
public void PrintCommand_WithProcessNotFinishing_GetsKilled() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); var printCommand = new PrintCommand(tempFile, "SomePrinter", new FileAssoc()); var factory = new MockProcessWrapperFactory(false); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsFalse(printCommand.Successful); Assert.IsTrue(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidTextFile_PrintsSuccessfully() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); var printCommand = new PrintCommand(tempFile, "SomePrinter", new FileAssoc()); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); Assert.IsFalse(factory.LastMock.WasKilled); }
public void PrintCommand_GivenValidPrintOnlyFile_HasCorrectStartInfo() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.ini"); var printerHelper = new PrinterHelper(); var printCommand = new PrintCommand(tempFile, printerHelper.GetDefaultPrinter(), new FileAssoc()); 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() { var tempFile = TempFileHelper.CreateTempFile("PrintCommand", "test.txt"); const string printer = "SomePrinter"; var printCommand = new PrintCommand(tempFile, printer, new FileAssoc(), _printerHelper, _timeOut); var factory = new MockProcessWrapperFactory(true); printCommand.ProcessWrapperFactory = factory; printCommand.Print(); Assert.IsTrue(printCommand.Successful); StringAssert.Contains("\"" + printer + "\"", factory.LastMock.StartInfo.Arguments); }
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, new FileAssoc(), _printerHelper, _timeout.Seconds)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test.invalid"), printer, new FileAssoc(), _printerHelper, _timeout.Seconds)); try { printCommandGroup.PrintAll(_timeout); } catch (InvalidOperationException) { } Assert.IsEmpty(factory.CreatedMocks); }
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, new FileAssoc(), _printerHelper, _timeout.Seconds)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test2.txt"), printer, new FileAssoc(), _printerHelper, _timeout.Seconds)); printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test3.txt"), printer, new FileAssoc(), _printerHelper, _timeout.Seconds)); printCommandGroup.PrintAll(_timeout); 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); }