Exemplo n.º 1
0
        public async Task ByZoomFactor_InputBadRequest()
        {
            var storageSelector = new FakeSelectorStorage(ArrangeStorage());

            var controller   = new ThumbnailController(_query, storageSelector);;
            var actionResult = await controller.ByZoomFactor("../") as BadRequestResult;

            Assert.AreEqual(400, actionResult.StatusCode);
        }
Exemplo n.º 2
0
        public async Task ByZoomFactor_NonExistingFile_API_Test()
        {
            var controller = new ThumbnailController(_query, new FakeSelectorStorage());

            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            var actionResult = await controller.ByZoomFactor("404filehash", 1) as NotFoundObjectResult;

            var thumbnailAnswer = actionResult.StatusCode;

            Assert.AreEqual(404, thumbnailAnswer);
        }
Exemplo n.º 3
0
        public void ByZoomFactor_IgnoreRawFile()
        {
            var storageSelector = new FakeSelectorStorage(ArrangeStorage());

            var controller = new ThumbnailController(new FakeIQuery(
                                                         new List <FileIndexItem>
            {
                new FileIndexItem("/test.dng")
                {
                    FileHash = "hash1"
                }
            }), storageSelector);

            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            controller.ByZoomFactor("hash1");

            Assert.AreEqual(210, controller.Response.StatusCode);
        }
Exemplo n.º 4
0
        public async Task ByZoomFactor_ShowOriginalImage_NoFileHash_API_Test()
        {
            InsertSearchData();
            var storage = ArrangeStorage();

            var controller = new ThumbnailController(_query, new FakeSelectorStorage(storage));

            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var actionResult = await controller.ByZoomFactor("____", 1, "/test.jpg") as FileStreamResult;

            var thumbnailAnswer = actionResult.ContentType;

            controller.Response.Headers.TryGetValue("x-filename", out var value);
            Assert.AreEqual("test.jpg", value.ToString());

            Assert.AreEqual("image/jpeg", thumbnailAnswer);

            await actionResult.FileStream.DisposeAsync();             // for windows
        }