Esempio n. 1
0
        public void ReadImageFileIndexReturnsOnlyFilesNotAlreadyImported()
        {
            var indexedLocation = "indexedLocation";
            var id           = "1";
            var importedFile = new ImageFileIndexStructure()
            {
                Id = "1"
            };

            var moqImageResponse = new ImageFileIndexResponse()
            {
            };

            moqImageResponse.Files.Add(importedFile);
            var moqProjectResponse = new ProjectResponse()
            {
                Project = new ProjectStructure()
                {
                    Id = ObjectId.GenerateNewId().ToString()
                }
            };

            moqProjectResponse.Project.SmallFileIds.Add(importedFile.Id);

            MockMakerClient.Setup(x => x.ReadImageFileIndex(It.IsAny <string>())).Returns(moqImageResponse);
            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(moqProjectResponse);

            var model = new ImageFileIndexModel();

            model.ReadImageFileIndex(MockMakerClient.Object, indexedLocation, id);
            Assert.AreEqual(0, model.Files.Count);
        }
Esempio n. 2
0
        public void ReadImageFileIndexReturnsOneFilesIfOneInCollection()
        {
            var indexedLocation = "indexedLocation";
            var id           = "1";
            var importedFile = new ImageFileIndexStructure()
            {
                Id = "1"
            };

            var moqImageResponse   = new ImageFileIndexResponse();
            var moqProjectResponse = new ProjectResponse()
            {
                Project = new ProjectStructure()
            };

            moqImageResponse.Files.Add(importedFile);

            MockMakerClient.Setup(x => x.ReadImageFileIndex(It.IsAny <string>())).Returns(moqImageResponse);
            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(moqProjectResponse);

            var model = new ImageFileIndexModel();

            model.ReadImageFileIndex(MockMakerClient.Object, indexedLocation, id);
            Assert.AreEqual(1, model.Files.Count);
        }
Esempio n. 3
0
        public void ReadImageFileIndexReturnsErrorIfProjectDoesNotExist()
        {
            var indexedLocation = "indexedLocation";
            var id = "1";
            var moqProjectResponse = new ProjectResponse()
            {
            };

            MockMakerClient.Setup(x => x.ReadImageFileIndex(It.IsAny <string>())).Returns(new ImageFileIndexResponse {
            });
            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(moqProjectResponse);

            var model = new ImageFileIndexModel();

            model.ReadImageFileIndex(MockMakerClient.Object, indexedLocation, id);
            Assert.IsFalse(String.IsNullOrEmpty(model.Error));
        }
        public ActionResult ReadImageFileIndex(string indexedLocation, string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Project id cannot be null or empty"));
            }
            var model = new ImageFileIndexModel();

            model.ReadImageFileIndex(client, indexedLocation, id);

            if (String.IsNullOrEmpty(model.Error))
            {
                var tileTableModel = model.Files.Select(x => new TileTableModel(x));
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(Json(tileTableModel));
            }

            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json(model.Error));
        }