public TaskCategoryController(ApplicationDbContext context) { _projectRepository = new ProjectRepository(context); _taskRepository = new TaskRepository(context); _userProfileRepository = new UserProfileRepository(context); _taskCategoryRepository = new TaskCategoryRepository(context); }
private TaskCategoryRepository CreateSUT() { var connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ConnectionString; var sqlClient = new SQLClient(connectionString); var sut = new TaskCategoryRepository(sqlClient); return(sut); }
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); }
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); }
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); }
public void ShouldInsertDataInTaskCategory() { var taskCategoryRepository = new TaskCategoryRepository(); var result = taskCategoryRepository.GetById("a9894a23-febb-40a1-9ce5-aff2b0461f95"); }