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

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

            Assert.IsNotNull(result);
            Assert.AreEqual(400, result.StatusCode);
        }
        public void CreateFile_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.CreateFile(new CreateFileViewModel()) as JsonResult;

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

            JsonResult result = controller.CreateFile(new CreateFileViewModel()) as JsonResult;

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

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

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

            Assert.IsNotNull(result);
            Assert.AreEqual("CreateFile", result.ViewName);
        }
        public void CreateFile_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.CreateFile(new CreateFileViewModel()
            {
                ParentDirectoryPath = "D/"
            }) as PartialViewResult;

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