public void CreateFolder_EmptyPath_ReturnStatusCode400()
        {
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            HttpStatusCodeResult result = controller.CreateFolder("") as HttpStatusCodeResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(400, result.StatusCode);
        }
        public void CreateFolder_ThrowException_ReturnJsonResult()
        {
            directoryServiceMock.Setup(a => a.GetAllDirectories(It.IsAny <String>())).Throws <UnauthorizedAccessException>();
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            JsonResult result = controller.CreateFolder(new DirectoryViewModel()) as JsonResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("{ Status = NotAcceptable }", result.Data.ToString());
        }
        public void CreateFolder_PostActionWithExistFolder_ReturnCorrectJson()
        {
            directoryServiceMock.Setup(a => a.IsExist(It.IsAny <string>())).Returns(true);
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            JsonResult result = controller.CreateFolder(new DirectoryViewModel()) as JsonResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("{ Status = Exist }", result.Data.ToString());
        }
        public void CreateFolder_PositiveTest_ReturnCorrectView()
        {
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            controller.ControllerContext = new ControllerContext(HttpContextBaseMock.Object, new RouteData(), controller);

            ViewResult result = controller.CreateFolder("D/data/NewFolder") as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("CreateFolder", result.ViewName);
        }
        public void CreateFolder_PositiveTest_CreateDirectoryAndReturnPartialView()
        {
            fileServiceMock.Setup(a => a.GetParrent(It.IsAny <string>())).Returns("D/");
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            controller.ControllerContext = new ControllerContext(HttpContextBaseMock.Object, new RouteData(), controller);

            PartialViewResult result = controller.CreateFolder(new DirectoryViewModel()
            {
                ParentDirectoryPath = "D/"
            }) as PartialViewResult;

            Assert.IsNotNull(result);
            directoryServiceMock.Verify(a => a.CreateDirectory(It.IsAny <string>()));
        }