public async Task ThumbnailGenerationTest_CheckIfGenerated_Socket_Success() { var storage = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg" }, new List <byte[]> { CreateAnImage.Bytes }); var thumbStorage = new FakeIStorage(); var socket = new FakeIWebSocketConnectionsService(); var selectorStorage = new FakeSelectorStorage(storage); var controller = new ThumbnailGenerationController(selectorStorage, new FakeIQuery( new List <FileIndexItem> { new FileIndexItem("/test.jpg") } ), new FakeIWebLogger(), socket); await controller.WorkItem("/", storage, thumbStorage); Assert.AreEqual(1, socket.FakeSendToAllAsync.Count(p => !p.StartsWith("[system]"))); }
public async Task ThumbnailGenerationTest_CheckIfGenerated() { var storage = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg" }, new List <byte[]> { CreateAnImage.Bytes }); var thumbStorage = new FakeIStorage(); var selectorStorage = new FakeSelectorStorage(storage); var controller = new ThumbnailGenerationController(selectorStorage, new FakeIQuery( new List <FileIndexItem> { new FileIndexItem("/test.jpg") } ), new FakeIWebLogger(), new FakeIWebSocketConnectionsService()); await controller.WorkItem("/", storage, thumbStorage); var folder = thumbStorage.GetAllFilesInDirectoryRecursive( "/").ToList(); Assert.AreEqual(1, folder.Count(p => !p.Contains("@"))); }
public async Task WorkItem_TestFailing() { var message = "[ThumbnailGenerationController] reading not allowed"; var storage = new FakeIStorage(new UnauthorizedAccessException(message)); var selectorStorage = new FakeSelectorStorage(storage); var webLogger = new FakeIWebLogger(); var controller = new ThumbnailGenerationController(selectorStorage, new FakeIQuery(), webLogger, new FakeIWebSocketConnectionsService()); await controller.WorkItem("/", storage, storage); Assert.IsTrue(webLogger.TrackedExceptions.FirstOrDefault().Item2.Contains(message)); }
public async Task ThumbnailGenerationTest_CheckIfGenerated_Socket_NoResultsInDatabase() { var storage = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg" }, new List <byte[]> { CreateAnImage.Bytes }); var thumbStorage = new FakeIStorage(); var socket = new FakeIWebSocketConnectionsService(); var selectorStorage = new FakeSelectorStorage(storage); var controller = new ThumbnailGenerationController(selectorStorage, new FakeIQuery( new List <FileIndexItem>()), new FakeIWebLogger(), socket); await controller.WorkItem("/", storage, thumbStorage); Assert.AreEqual(0, socket.FakeSendToAllAsync.Count); }