public void MaintTaskRepositoryEnsureICanAddAMaintTask()
        {
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask list = new MaintTask { Title = "Change Air Filters", MaintTaskId = 1, Frequency = "Every Year" };
            my_maintTasks.Add(new MaintTask { Title = "My First Task", Owner = user1 });

            ConnectMocksToDataSource();

            bool actual = maintTask_repo.AddMaintTask(list);

            Assert.AreEqual(1, maintTask_repo.GetAllMaintTasks().Count);
            Assert.IsTrue(actual);
        }
 public MaintTaskController(MaintTaskRepository _repo)
 {
     repository = _repo;
 }
 public MaintTaskController()
 {
     repository = new MaintTaskRepository();
 }
        public void MaintTaskRepositoryEnsureICanDeleteAMaintTask()
        {
            // Arrange
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask m_task1 = new MaintTask()
            {
                MaintTaskId = 1,
                Title = "my maint task",
                Frequency = "Every Year"
            };
            MaintTask m_task2 = new MaintTask()
            {
                MaintTaskId = 2,
                Title = "my maint task 2",
                Frequency = "Every Year"
            };

            my_maintTasks.Add(m_task1);
            my_maintTasks.Add(m_task2);

            ConnectMocksToDataSource();

            // Act
            bool success = maintTask_repo.DeleteMaintTask(m_task1.MaintTaskId);
            MaintTask m_task_found1 = maintTask_repo.GetMaintTaskById(m_task1.MaintTaskId);
            MaintTask m_task_found2 = maintTask_repo.GetMaintTaskById(m_task2.MaintTaskId);

            // Assert
            Assert.IsTrue(success);
            //Assert.IsNull(m_task_found1);
            //Assert.AreEqual(1, maintTask_repo.GetAllMaintTasks().Count);
            Assert.AreEqual(1, maintTask_repo.MaintTasks.Count());
            Assert.AreEqual("my maint task 2", m_task_found2.Title);
        }
        public void MaintTaskRepositoryEnsureICanEditAMaintTask()
        {
            // Arrange
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask m_task1 = new MaintTask { MaintTaskId = 1, Title = "My Maint Task" };
            MaintTask m_task2 = new MaintTask { MaintTaskId = 2, Title = "My Maint Task 2" };

            my_maintTasks.Add(m_task1);
            my_maintTasks.Add(m_task2);

            ConnectMocksToDataSource();

            // Act
            var newTitle1 = "My Maint Task NEW 1";
            var newTitle2 = "My Maint Task NEW 2";
            m_task1.Title = newTitle1;
            m_task2.Title = newTitle2;
            var mt_success1 = maintTask_repo.UpdateMaintTask(m_task1);
            var mt_success2 = maintTask_repo.UpdateMaintTask(m_task2);
            var actual1 = maintTask_repo.GetMaintTaskById(m_task1.MaintTaskId);
            var actual2 = maintTask_repo.GetMaintTaskById(m_task2.MaintTaskId);

            // Assert
            Assert.AreEqual(newTitle1, actual1.Title);
            Assert.AreEqual(newTitle2, actual2.Title);
        }