Example #1
0
        public void UpdateTask()
        {
            //Arrange
            var context        = new TestTaskManagerContext();
            var testController = new TestTaskController();

            testController.Tasks().ForEach(x =>
            {
                context.Tasks.Add(x);
            });

            var task = new Task()
            {
                TaskId = 2, TaskName = "FS1", Priority = 5, StartDate = new DateTime(2018, 10, 1), EndDate = new DateTime(2018, 10, 2)
            };

            //Act
            var     controller = new TaskController(context);
            dynamic result     = controller.UpdateTask(task);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, context.Tasks.Find(2).TaskId);
            Assert.AreEqual(task.TaskName, context.Tasks.Find(2).TaskName);
            Assert.AreEqual(task.Priority, context.Tasks.Find(2).Priority);
        }
Example #2
0
        public void EndTask()
        {
            //Arrange
            var context        = new TestTaskManagerContext();
            var testController = new TestTaskController();

            testController.Tasks().ForEach(x =>
            {
                context.Tasks.Add(x);
            });

            var task = new Task()
            {
                TaskId = 1
            };

            //Act
            var     controller = new TaskController(context);
            dynamic result     = controller.EndTask(task.TaskId);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, context.Tasks.Find(1).TaskId);
            Assert.AreEqual("Y", context.Tasks.Find(1).EndTask);
        }
Example #3
0
        public void GetTaskById_ReturnTask()
        {
            //Arrange
            var context        = new TestTaskManagerContext();
            var testController = new TestTaskController();

            testController.Tasks().ForEach(x =>
            {
                context.Tasks.Add(x);
            });


            //Act
            var     controller = new TaskController(context);
            dynamic result     = controller.GetTaskById(1);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(1, result.Content.TaskId);
        }