public void Group_WithPprintableFile_PrintReturnsTrue() { var printCommandGroup = new PrintCommandGroup(); printCommandGroup.ProcessWrapperFactory = new MockProcessWrapperFactory(true); const string printer = "SomePrinter"; printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test.txt"), printer)); Assert.IsTrue(printCommandGroup.PrintAll()); }
public void Group_WithUnprintableFile_PrintThrowsException() { var printCommandGroup = new PrintCommandGroup(); printCommandGroup.ProcessWrapperFactory = new MockProcessWrapperFactory(true); const string printer = "SomePrinter"; printCommandGroup.Add(new PrintCommand(TempFileHelper.CreateTempFile("PrintCommandGroup", "test.invalid"), printer)); Assert.Throws <InvalidOperationException>(() => printCommandGroup.PrintAll()); }
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); }
public void Group_WithEmptyList_PrintReturnsTrue() { var printCommandGroup = new PrintCommandGroup(); Assert.IsTrue(printCommandGroup.PrintAll()); }