Exemplo n.º 1
0
        public void TestTimeTasksRepository_ShouldRemoveTask()
        {
            // Arrange
            var repository = new TimeTasksRepository(DatabaseContext);
            var mapper     = new TimeTasksMapper();
            var tasksList  = TestTaskListProvider.GetMockTimeTaskContexts(1);
            var task       = tasksList[1];

            // Act
            repository.SaveTask(mapper.ReverseMap(tasksList[0]));
            repository.SaveTask(mapper.ReverseMap(tasksList[1]));
            repository.SaveTask(mapper.ReverseMap(tasksList[2]));

            repository.RemoveTasks(new List <int> {
                task.Id
            });

            var returnedList = repository.GetSavedTasksForToday("").ToList();

            // Assert
            Assert.True(returnedList.Count == tasksList.Count - 1);
            Assert.True(returnedList[0].Name == "NAME1");
            Assert.True(returnedList[1].Name == "NAME2");
            Assert.True(returnedList[1].Priority == Priority.Three);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves new task to the database and adds it to the application's task list
        /// </summary>
        /// <param name="context">The context of a task to add</param>
        public void SaveTask(TimeTaskContext context)
        {
            // Initialize remaining data based on task's type
            InitializeTaskWithType(context);

            // Map it to the entity
            var entity = mTimeTasksMapper.ReverseMap(context);

            // Save it into database
            mTimeTasksRepository.SaveTask(entity);
        }