コード例 #1
0
        public void GetMaintenanceTasks_ShouldCallRepository_GetTasksWithCorrectVIN()
        {
            var controller = new MaintenanceTaskController(_mockRepo.Object);
            var id         = "1";

            controller.GetMaintenanceTasks(id);

            _mockRepo.Verify(m => m.GetMaintenanceTasks(id));
        }
コード例 #2
0
        public void GetMaintenanceTasks_ShouldReturnEmptyList_GivenNoTasksReturnedFromRepo()
        {
            var controller = new MaintenanceTaskController(_mockRepo.Object);
            var id         = "1";

            _mockRepo.Setup(m => m.GetMaintenanceTasks(id)).Returns(new List <MaintenanceTask>());

            var result = controller.GetMaintenanceTasks(id);

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count());
        }
コード例 #3
0
        public void GetMaintenanceTasks_ShouldReturnTasks_GivenTaskReturnedFromRepo()
        {
            var vin        = "1";
            var controller = new MaintenanceTaskController(_mockRepo.Object);
            var tasks      = new List <MaintenanceTask>();
            var task       = new MaintenanceTask()
            {
                Id = 1, VIN = vin
            };

            tasks.Add(task);
            _mockRepo.Setup(m => m.GetMaintenanceTasks(vin)).Returns(tasks);

            var actualTasks = controller.GetMaintenanceTasks(vin);

            Assert.IsNotNull(actualTasks);
            Assert.AreEqual(1, actualTasks.Count());
            Assert.IsNotNull(tasks[0]);
            Assert.AreEqual(task, tasks[0]);
        }