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

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

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

            JsonResult result = controller.Search("new", "D/") as JsonResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("{ Status = NotAcceptable }", result.Data.ToString());
        }
        public void Search_EmptyPath_RedirectToAnotherUrl()
        {
            string expected = "/Drive/GetDrives/";
            DirectoryController controller = new DirectoryController(directoryServiceMock.Object, fileServiceMock.Object, searchServiceMock.Object);

            RedirectResult result = controller.Search("test", "") as RedirectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result.Url);
        }
        public void Search_PositiveTest_ReturnCorrectModel()
        {
            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);

            ViewResult result = controller.Search("test", "D/") as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Search", result.ViewName);
            Assert.AreEqual("D\\\\", result.ViewData["LastPath"]);
        }