public void DeleteMasterWillDeleteLocalMasterFileIfExists()
        {
            var masterLocation = masterPath + "Master.txt";

            // Closes the file after creating it
            File.Create(masterLocation).Dispose();

            var project = new ProjectStructure()
            {
                Id             = ObjectId.GenerateNewId().ToString(),
                TimeOfCreation = DateTime.Now.ToString(),
                Progress       = ProjectStructure.Types.State.Completed,
                MasterLocation = masterLocation
            };

            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Project = project
            });
            MockMakerClient.Setup(x => x.DeleteProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Error = "Error"
            });

            var model = new DeleteProjectModel(masterPath, mosaicPath);

            model.DeleteProject(MockMakerClient.Object, ObjectId.GenerateNewId().ToString());
            Assert.IsFalse(File.Exists(masterLocation));
        }
        public void DeleteProjectReturnsErrorIfIdIsNull()
        {
            var model = new DeleteProjectModel();

            model.DeleteProject(MockMakerClient.Object, null);
            Assert.IsFalse(String.IsNullOrEmpty(model.Error));
        }
        public void DeleteProjectReturnsErrorIfReadProjectReturnsError()
        {
            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Error = "Error"
            });

            var model = new DeleteProjectModel();

            model.DeleteProject(MockMakerClient.Object, ObjectId.GenerateNewId().ToString());
            Assert.IsFalse(String.IsNullOrEmpty(model.Error));
        }
Пример #4
0
        public IActionResult Delete(string id)
        {
            var model = new DeleteProjectModel();

            model.DeleteProject(client, id);
            if (String.IsNullOrEmpty(model.Error))
            {
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(Json("Delete project request was valid"));
            }
            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json(model.Error));
        }
        public void DeleteProjectWillReturnErrorIfProjectCannotBeDeleted()
        {
            var project = new ProjectStructure()
            {
                Id             = ObjectId.GenerateNewId().ToString(),
                TimeOfCreation = DateTime.Now.ToString(),
                Progress       = ProjectStructure.Types.State.Completed,
            };

            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Project = project
            });
            MockMakerClient.Setup(x => x.DeleteProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Error = "Error"
            });

            var model = new DeleteProjectModel();

            model.DeleteProject(MockMakerClient.Object, ObjectId.GenerateNewId().ToString());
            Assert.IsFalse(String.IsNullOrEmpty(model.Error));
        }
        public void DeleteMasterImageReturnErrorIfImageDoesNotExist()
        {
            var project = new ProjectStructure()
            {
                Id             = ObjectId.GenerateNewId().ToString(),
                TimeOfCreation = DateTime.Now.ToString(),
                Progress       = ProjectStructure.Types.State.Largeadded,
                MasterLocation = "//InvalidLocation"
            };

            MockMakerClient.Setup(x => x.ReadProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Project = project
            });
            MockMakerClient.Setup(x => x.DeleteProject(It.IsAny <string>())).Returns(new ProjectResponse {
                Error = "Error"
            });

            var model = new DeleteProjectModel();

            model.DeleteProject(MockMakerClient.Object, ObjectId.GenerateNewId().ToString());
            Assert.IsFalse(String.IsNullOrEmpty(model.Error));
        }