public void search_throwException()
        {
            int      id          = -21;
            string   description = "Test";
            DateTime dueDate     = DateTime.Now;
            String   title       = "Test Task";

            var taskSearchModel = new TasksSearchModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };


            var logger = new Mock <Microsoft.Extensions.Logging.ILogger <TasksController> >().Object;


            IkarusContext     db  = new IkarusContext();
            ITaskRepository   itr = new TaskRepository(db);
            ITaskManipulation itm = new TaskManipulation(itr);
            var controller        = new TasksController(itm);


            var result = controller.Search(taskSearchModel, -1, -1);

            Xunit.Assert.IsType <OkObjectResult>(result);
        }
Example #2
0
        public void Search_ThrowsNSIException()
        {
            var taskRepo         = new Mock <ITaskRepository>();
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.Search(null, 1, 1);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Example #3
0
        public void deleteTask_throwException()
        {
            var taskRepo         = new Mock <ITaskRepository>();
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.DeleteTask(-1);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Example #4
0
        public void UpdateTask_ThrowException()
        {
            var TaskRepo         = new Mock <ITaskRepository>();
            var TaskManipulation = new TaskManipulation(TaskRepo.Object);
            var controller       = new TasksController(TaskManipulation);

            var result = controller.ChangeTask(-1, null);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Example #5
0
        public void getTasksByUserId_ReturnsBadRequest()
        {
            var taskRepo         = new Mock <ITaskRepository>();
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.GetTasksByUserId(1, null, null);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Example #6
0
        public void getTasksByIDTest_ReturnsNoContent()
        {
            var TaskRepo = new Mock <ITaskRepository>();

            var TaskManipulation = new TaskManipulation(TaskRepo.Object);
            var controller       = new TasksController(TaskManipulation);

            var result = controller.GetTaskById(-1);

            Assert.IsType <BadRequestObjectResult>(result);
        }
        public void deleteTask_throwException()
        {
            var               logger     = new Mock <Microsoft.Extensions.Logging.ILogger <TasksController> >().Object;
            IkarusContext     db         = new IkarusContext();
            ITaskRepository   itr        = new TaskRepository(db);
            ITaskManipulation itm        = new TaskManipulation(itr);
            var               controller = new TasksController(itm);

            var result = controller.DeleteTask(-1);

            Xunit.Assert.IsType <BadRequestObjectResult>(result);
        }
        public void getTasksByIDTest_ReturnsNoContent()
        {
            var               logger     = new Mock <Microsoft.Extensions.Logging.ILogger <TasksController> >().Object;
            IkarusContext     db         = new IkarusContext();
            ITaskRepository   itr        = new TaskRepository(db);
            ITaskManipulation itm        = new TaskManipulation(itr);
            var               controller = new TasksController(itm);


            var result = controller.GetTaskById(-1);

            Xunit.Assert.IsType <BadRequestObjectResult>(result);
        }
Example #9
0
        public void searchTask_returnOK()
        {
            int      id          = 21;
            string   description = "Test";
            DateTime dueDate     = DateTime.Now;
            String   title       = "Test Task";

            var Task = new List <TaskDto>()
            {
                new TaskDto()
                {
                    TaskId = 1
                }
            };

            NSI.REST.Models.TasksCreateModel task = new TasksCreateModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };

            var task2 = new TaskDto
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };

            var taskSearchModel = new TasksSearchModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };


            var taskRepo = new Mock <ITaskRepository>();

            taskRepo.Setup(x => x.CreateTask(task2));
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.Search(taskSearchModel, 1, 1);

            Assert.IsType <OkObjectResult>(result);
        }
        public void UpdateTask_ThrowException()
        {
            var logger = new Mock <Microsoft.Extensions.Logging.ILogger <TasksController> >().Object;

            IkarusContext     db  = new IkarusContext();
            ITaskRepository   itr = new TaskRepository(db);
            ITaskManipulation itm = new TaskManipulation(itr);
            var controller        = new TasksController(itm);


            var result = controller.ChangeTask(5, model: null);

            Xunit.Assert.IsType <ObjectResult>(result);
        }
        public void deleteTask_ReturnBadRequest_GivenInvalidMove()
        {
            var logger = new Mock <Microsoft.Extensions.Logging.ILogger <TasksController> >().Object;

            IkarusContext     db  = new IkarusContext();
            ITaskRepository   itr = new TaskRepository(db);
            ITaskManipulation itm = new TaskManipulation(itr);
            var controller        = new TasksController(itm);

            controller.ModelState.AddModelError("error", "some error");

            var result = controller.DeleteTask(-1);

            Xunit.Assert.IsType <BadRequestObjectResult>(result);
        }
Example #12
0
        public void search_throwException()
        {
            int      id          = -21;
            string   description = "Test";
            DateTime dueDate     = DateTime.Now;
            String   title       = "Test Task";

            var Task = new List <TaskDto>()
            {
                new TaskDto()
                {
                    TaskId = 1
                }
            };

            NSI.REST.Models.TasksCreateModel task = new TasksCreateModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };

            var task2 = new TaskDto
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };

            var taskSearchModel = new TasksSearchModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title
            };

            var taskRepo         = new Mock <ITaskRepository>();
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);


            var result = controller.Search(taskSearchModel, null, null);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Example #13
0
        public void GetTaskWithDueDateRange_ReturnOK() //dateFrom, dateTo, page,pageSize
        {
            int      id          = 21;
            string   description = "Test";
            DateTime dueDateFrom = DateTime.Now;
            DateTime dueDateTo   = DateTime.Now;

            dueDateTo.AddYears(1);
            String title = "Test Task";


            var Task = new List <TaskDto>()
            {
                new TaskDto()
                {
                    TaskId = 1
                }
            };

            NSI.REST.Models.TasksCreateModel task = new TasksCreateModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDateFrom,
                Title       = title
            };

            var task2 = new TaskDto
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDateFrom,
                Title       = title
            };

            var taskRepo = new Mock <ITaskRepository>();

            taskRepo.Setup(x => x.CreateTask(task2));
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.GetTasksWithDueDateRange(dueDateFrom, dueDateTo, 1, 1);

            Assert.IsType <OkObjectResult>(result);
        }
Example #14
0
        public void getTasksByUserId_ReturnOK()
        {
            int      id          = 21;
            string   description = "Test";
            DateTime dueDate     = DateTime.Now;
            String   title       = "Test Task";



            var userOnTask = new List <TaskDto>()
            {
                new TaskDto()
                {
                    UserId = 69
                }
            };

            NSI.REST.Models.TasksCreateModel task = new TasksCreateModel()
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title,
                UserId      = 69
            };

            var task2 = new TaskDto
            {
                TaskId      = id,
                Description = description,
                DueDate     = dueDate,
                Title       = title,
                UserId      = 69
            };

            var taskRepo = new Mock <ITaskRepository>();

            taskRepo.Setup(x => x.CreateTask(task2));
            var taskManipulation = new TaskManipulation(taskRepo.Object);
            var controller       = new TasksController(taskManipulation);

            var result = controller.GetTasksByUserId(69, 3, 1);

            Assert.IsType <OkObjectResult>(result);
        }