コード例 #1
0
        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]")));
        }
コード例 #2
0
        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("@")));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }