From f3a5cc25ba71d64355c15a65d7b877cab7ec489d Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 00:41:53 +0200 Subject: [PATCH] Adds tests for saving the files Former-commit-id: 7893eb70f8315cf13da030fde6a4a3c9884f59aa --- .../ImageFactoryUnitTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index d868b2245..880871cc7 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -60,6 +60,45 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that the save method actually saves a file + /// + [Test] + public void TestSaveToDisk() + { + foreach (var fileName in ListInputFiles()) + { + var outputFileName = string.Format("./output/{0}", Path.GetFileName(fileName)); + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Save(outputFileName); + Assert.AreEqual(true, File.Exists(outputFileName)); + } + } + } + + /// + /// Tests that the save method actually writes to memory + /// + [Test] + public void TestSaveToMemory() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + using (var s = new MemoryStream()) + { + imageFactory.Save(s); + s.Seek(0, SeekOrigin.Begin); + Assert.AreEqual(true, s.Capacity > 0); + } + } + } + } + /// /// Tests that a filter is really applied by checking that the image is modified ///