コード例 #1
0
 public TaskCategoryController(ApplicationDbContext context)
 {
     _projectRepository      = new ProjectRepository(context);
     _taskRepository         = new TaskRepository(context);
     _userProfileRepository  = new UserProfileRepository(context);
     _taskCategoryRepository = new TaskCategoryRepository(context);
 }
コード例 #2
0
        private TaskCategoryRepository CreateSUT()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ConnectionString;
            var sqlClient        = new SQLClient(connectionString);
            var sut = new TaskCategoryRepository(sqlClient);

            return(sut);
        }
コード例 #3
0
        public void UpdateCategory_CannotUpdateIfItDoesntExist_ReturnObjectNotFoundException()
        {
            // Arrange
            var category = new TaskCategoryEntity()
            {
                Id       = "Guid 1",
                DateTime = DateTime.Now,
                Title    = "Daily",
            };

            ITaskCategoryRepository repository = new TaskCategoryRepository();

            // Act
            repository.UpdateCategory(category);
        }
コード例 #4
0
        public void AddCategory_CanAddValidCategory_ReturnCategory()
        {
            // Arrange
            var category = new TaskCategoryEntity()
            {
                Id       = "Guid 1",
                DateTime = DateTime.Now,
                Title    = "Daily",
            };

            ITaskCategoryRepository repository = new TaskCategoryRepository();

            // Act
            var result = repository.AddCategory(category);

            repository.DeleteCategoryById(category.Id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(category, result);
        }
コード例 #5
0
        public void SortTasksByCategory_CanSortByCategoryTitle_ReturnTasks()
        {
            // Arrange
            var category = new TaskCategoryEntity()
            {
                Id       = "Guid 1",
                DateTime = DateTime.Now,
                Title    = "Daily",
            };

            var taskEntity = new TaskEntity
            {
                Id           = "Guid1",
                Completeness = false,
                DateTime     = DateTime.Now,
                Description  = "Description",
                Name         = "Name",
                Category     = category,
            };

            ITaskRepository         taskRepository         = new TaskRepository();
            ITaskCategoryRepository taskCategoryRepository = new TaskCategoryRepository();

            taskRepository.AddTask(taskEntity);


            // Act
            var result = taskRepository.SortTasksByCategory(taskEntity.Category.Title);

            // Assert
            Assert.IsNotNull(result);

            Assert.AreEqual(taskEntity, result.FirstOrDefault(t => t.Name == taskEntity.Name));

            taskRepository.DeleteTaskById(taskEntity.Id);
            taskCategoryRepository.DeleteCategoryById(category.Id);
        }
コード例 #6
0
 public void ShouldInsertDataInTaskCategory()
 {
     var taskCategoryRepository = new TaskCategoryRepository();
     var result = taskCategoryRepository.GetById("a9894a23-febb-40a1-9ce5-aff2b0461f95");
 }