상속: IThumbnailService
예제 #1
0
		// Analysis disable once InconsistentNaming
		public void IsValid_ReturnsFalse_IfFileDoesNotExist ()
		{
			var fileSystem = new FileSystemMock ();
			var pixbuf = PixbufMock.CreatePixbuf (fileUri, fileMTime + 1);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.IsValid (fileUri, pixbuf);

			Assert.IsFalse (result);
		}
예제 #2
0
		// Analysis disable once InconsistentNaming
		public void IsValid_ReturnsTrue_IfPixbufIsValid ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			var pixbuf = PixbufMock.CreatePixbuf (fileUri, fileMTime);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.IsValid (fileUri, pixbuf);

			Assert.IsTrue (result);
		}
예제 #3
0
		// Analysis disable once InconsistentNaming
		public void IsValid_ReturnsFalse_IfPixbufIsNull ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.IsValid (fileUri, null);

			Assert.IsFalse (result);
		}
예제 #4
0
		// Analysis disable once InconsistentNaming
		public void IsValid_ReturnsFalse_IfFileUriIsDifferent ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			var pixbuf = PixbufMock.CreatePixbuf (new SafeUri ("file:///some-uri"), fileMTime);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.IsValid (fileUri, pixbuf);

			Assert.IsFalse (result);
		}
예제 #5
0
		// Analysis disable once InconsistentNaming
		public void LoadThumbnail_IgnoresExceptionsOnDeletingThumbnails ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (largeThumbnailUri, 0, thumbnail);
			fileSystem.FileMock.Setup (m => m.Read (largeThumbnailUri)).Throws<Exception> ();
			fileSystem.FileMock.Setup (m => m.Delete (largeThumbnailUri)).Throws<Exception> ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.LoadThumbnail (largeThumbnailUri);

			Assert.IsNull (result);
			fileSystem.FileMock.Verify (file => file.Delete (largeThumbnailUri), Times.Once ());
		}
예제 #6
0
		// Analysis disable once InconsistentNaming
		public void GetThumbnailPath_ReturnsPathForNormalThumbnail ()
		{
			var fileSystem = new FileSystemMock ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.GetThumbnailPath (fileUri, ThumbnailSize.Normal);

			Assert.AreEqual (normalThumbnailUri, result);
		}
예제 #7
0
		// Analysis disable once InconsistentNaming
		public void LoadThumbnail_ReturnsNull_IfThumbnailDoesNotExist ()
		{
			var fileSystem = new FileSystemMock ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.LoadThumbnail (largeThumbnailUri);

			Assert.IsNull (result);
		}
예제 #8
0
		// Analysis disable once InconsistentNaming
		public void LoadThumbnail_ReturnsPixbuf_IfThumbnailExists ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (largeThumbnailUri, 0, thumbnail);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.LoadThumbnail (largeThumbnailUri);

			Assert.IsNotNull (result);
		}
예제 #9
0
		// Analysis disable once InconsistentNaming
		public void DeleteThumbnail_DoesNotDeleteThumbnails_IfNotExist ()
		{
			var fileSystem = new FileSystemMock ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			thumbnailService.DeleteThumbnails (fileUri);

			fileSystem.FileMock.Verify (m => m.Delete (largeThumbnailUri), Times.Never ());
			fileSystem.FileMock.Verify (m => m.Delete (normalThumbnailUri), Times.Never ());
		}
예제 #10
0
		// Analysis disable once InconsistentNaming
		public void DeleteThumbnail_IgnoresExceptionsOnDeletingThumbnails ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (largeThumbnailUri);
			fileSystem.SetFile (normalThumbnailUri);
			fileSystem.FileMock.Setup (m => m.Delete (largeThumbnailUri)).Throws<Exception> ();
			fileSystem.FileMock.Setup (m => m.Delete (normalThumbnailUri)).Throws<Exception> ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			thumbnailService.DeleteThumbnails (fileUri);

			fileSystem.FileMock.Verify (m => m.Delete (largeThumbnailUri), Times.Once ());
			fileSystem.FileMock.Verify (m => m.Delete (normalThumbnailUri), Times.Once ());
			// test ends without the exceptions thrown by File.Delete beeing unhandled
		}
예제 #11
0
		// Analysis disable once InconsistentNaming
		public void DeleteThumbnail_DeletesLargeAndNormalThumbnails_IfTheyExist ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (largeThumbnailUri);
			fileSystem.SetFile (normalThumbnailUri);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			thumbnailService.DeleteThumbnails (fileUri);

			fileSystem.FileMock.Verify (m => m.Delete (largeThumbnailUri), Times.Once ());
			fileSystem.FileMock.Verify (m => m.Delete (normalThumbnailUri), Times.Once ());
		}
예제 #12
0
		// Analysis disable once InconsistentNaming
		public void GetThumbnail_ReturnsNull_IfThumbnailCreationFails ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			thumbnailerMock.Setup (thumb => thumb.TryCreateThumbnail (largeThumbnailUri, ThumbnailSize.Large)).Returns (false);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.GetThumbnail (fileUri, ThumbnailSize.Large);

			Assert.IsNull (result);
		}
예제 #13
0
		// Analysis disable once InconsistentNaming
		public void GetThumbnail_ReturnsNull_IfNoThumbnailerFound ()
		{
			var fileSystem = new FileSystemMock ();
			var thumbnailerFactoryMock = new Mock<IThumbnailerFactory> ();
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactoryMock.Object, fileSystem);

			var result = thumbnailService.GetThumbnail (fileUri, ThumbnailSize.Large);

			Assert.IsNull (result);
		}
예제 #14
0
		// Analysis disable once InconsistentNaming
		public void GetThumbnail_CreatesPngAndReturnsPixbuf_IfPngIsMissing ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			thumbnailerMock.Setup (thumb => thumb.TryCreateThumbnail (largeThumbnailUri, ThumbnailSize.Large))
				.Returns (true)
				.Callback (() => fileSystem.SetFile (largeThumbnailUri, 0, thumbnail));
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.GetThumbnail (fileUri, ThumbnailSize.Large);

			Assert.IsNotNull (result);
		}
예제 #15
0
		// Analysis disable once InconsistentNaming
		public void GetThumbnail_ReturnsPixbuf_IfValidPngExists ()
		{
			var fileSystem = new FileSystemMock ();
			fileSystem.SetFile (fileUri, fileMTime);
			fileSystem.SetFile (largeThumbnailUri, 0, thumbnail);
			var thumbnailService = new ThumbnailService (xdgDirectoryService, thumbnailerFactory, fileSystem);

			var result = thumbnailService.GetThumbnail (fileUri, ThumbnailSize.Large);

			Assert.IsNotNull (result);
		}