public async Task Update_Saves_ParentTask()
        {
            // Arrange
            var repository           = new TaskRepository(dbContext);
            var parentTaskRepository = new ParentTaskRepository(dbContext);

            var parentTask = await parentTaskRepository.Get(1);

            var task = await repository.Get(4);

            task.ParentTask = parentTask;

            // Act
            var result = await repository.Update(task);

            var actualTask = await repository.Get(4);

            var actualParentTasks = await parentTaskRepository.GetAll();

            // Assert
            Assert.Equal(task.Id, actualTask.Id);
            Assert.Equal(task.ParentTask.Id, actualTask.ParentTask.Id);
            Assert.Equal(task.ParentTask.Name, actualTask.ParentTask.Name);
            Assert.Equal(2, actualParentTasks.Count());
        }
Beispiel #2
0
        public async Task EndTask_Throws_NotImplementedException()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act && Assert
            await Assert.ThrowsAsync <NotImplementedException>(() => repository.EndTask(1));
        }
Beispiel #3
0
        public async Task Create_Throws_NotImplementedException()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act && Assert
            await Assert.ThrowsAsync <NotImplementedException>(() => repository.Create(new Model.ParentTask {
                Id = 5, Name = "Parent Task 5"
            }));
        }
Beispiel #4
0
        public async Task Get_Returns_Null()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act
            var result = await repository.Get(3);

            // Assert
            Assert.Null(result);
        }
Beispiel #5
0
        public async Task Get_Returns_CorrectType()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act
            var result = await repository.Get(1);

            // Assert
            Assert.IsAssignableFrom <Model.ParentTask>(result);
        }
Beispiel #6
0
        public async Task GetAll_Returns_AllParentTasks()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act
            var results = await repository.GetAll();

            // Assert
            Assert.Equal(2, results.Count());
        }
Beispiel #7
0
        public async Task GetAll_Returns_CorrectType()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act
            var results = await repository.GetAll();

            // Assert
            Assert.IsAssignableFrom <IEnumerable <Model.ParentTask> >(results);
        }
Beispiel #8
0
        public async Task Get_Returns_ExpectedParentTask()
        {
            // Arrange
            var repository = new ParentTaskRepository(dbContext);

            // Act
            var result = await repository.Get(1);

            // Assert
            Assert.Equal(1, result.Id);
            Assert.Equal("Parent Task 1", result.Name);
        }
        public void AddParentTask_Test()
        {
            ParentTask ptask = new ParentTask();

            ptask.TaskName = "test";
            var mockTaskRepository = new Mock <IProjectManagerRepository <ParentTask> >(MockBehavior.Strict);

            mockTaskRepository.Setup(p => p.Create(ptask));
            mockTaskRepository.Setup(p => p.SaveChange());
            var objPtaskRepo = new ParentTaskRepository(mockTaskRepository.Object);

            objPtaskRepo.AddParentTask(ptask);
            mockTaskRepository.Verify(mock => mock.Create(ptask), Times.Once());
            mockTaskRepository.Verify(mock => mock.SaveChange(), Times.Once());
        }
        public void GetParentTasks_Test()
        {
            ParentTask ptask = new ParentTask();

            ptask.TaskName = "test";
            List <ParentTask> tasklist = new List <ParentTask>();

            tasklist.Add(ptask);

            IQueryable <ParentTask> pTasks = tasklist.AsQueryable();
            var mockTaskRepository         = new Mock <IProjectManagerRepository <ParentTask> >(MockBehavior.Strict);

            mockTaskRepository.Setup(p => p.All).Returns(pTasks);
            var objPtaskRepo = new ParentTaskRepository(mockTaskRepository.Object);
            var returnTasks  = objPtaskRepo.GetParentTasks();

            mockTaskRepository.Verify(mock => mock.All, Times.Once());
            Assert.AreEqual(returnTasks.ToList().Count, 1);
        }
        public async Task Create_Inserts_NewTask_With_NoParentTask()
        {
            // Arrange
            var repository           = new TaskRepository(dbContext);
            var parentTaskRepository = new ParentTaskRepository(dbContext);

            // Act
            var result = await repository.Create(new Model.Task {
                Id = 5, Name = "Task 5", Priority = 1, StartDate = new DateTime()
            });

            var actualTasks = await repository.GetAll();

            var actualParentTasks = await parentTaskRepository.GetAll();

            // Assert
            Assert.Equal(5, actualTasks.Count());
            Assert.Equal(2, actualParentTasks.Count());
        }
        public async Task Create_Does_Not_Inserts_ParentTask_If_Aleardy_Exists()
        {
            // Arrange
            var repository           = new TaskRepository(dbContext);
            var parentTaskRepository = new ParentTaskRepository(dbContext);

            // Act
            var result = await repository.Create(new Model.Task {
                Id = 7, Name = "Task 7", Priority = 1, StartDate = new DateTime(), ParentTask = new Model.ParentTask {
                    Id = 1, Name = "Parent Task 3"
                }
            });

            var actualTasks = await repository.GetAll();

            var actualParentTasks = await parentTaskRepository.GetAll();

            // Assert
            Assert.Equal(5, actualTasks.Count());
            Assert.Equal(2, actualParentTasks.Count());
        }
        public async Task Update_Does_Not_Inserts_ParentTask_If_Aleardy_Exists()
        {
            // Arrange
            var repository           = new TaskRepository(dbContext);
            var parentTaskRepository = new ParentTaskRepository(dbContext);

            var task = await repository.Get(2);

            task.Name = "New Task Name";

            // Act
            var result = await repository.Update(task);

            var actualTask = await repository.Get(2);

            var actualParentTasks = await parentTaskRepository.GetAll();

            // Assert
            Assert.Equal(task.Id, actualTask.Id);
            Assert.Equal(task.Name, actualTask.Name);
            Assert.Equal(2, actualParentTasks.Count());
        }
        public async Task Update_Saves_Task_With_WithChanges()
        {
            // Arrange
            var repository           = new TaskRepository(dbContext);
            var parentTaskRepository = new ParentTaskRepository(dbContext);

            var task = await repository.Get(1);

            task.Name     = "New Task Name";
            task.Priority = 2;

            // Act
            var result = await repository.Update(task);

            var actualTask = await repository.Get(1);

            var actualParentTasks = await parentTaskRepository.GetAll();

            // Assert
            Assert.Equal(task.Id, actualTask.Id);
            Assert.Equal(task.Name, actualTask.Name);
            Assert.Equal(task.Priority, actualTask.Priority);
            Assert.Equal(2, actualParentTasks.Count());
        }