public void FavoriteUpdater_UserCreatesNewFavoriteWithCompensationRate_NewFavoriteIsCreatedCompensationRateIsUnchanged() { var context = new AlvTimeDbContextBuilder() .WithTasks() .WithProjects() .WithCustomers() .CreateDbContext(); var previousNumberOfFavorites = context.TaskFavorites .Where(tf => tf.UserId == 1) .ToList().Count(); var storage = new TaskStorage(context); var updater = new FavoriteUpdater(storage); var previousCompensationRate = context.Task.FirstOrDefault(x => x.Id == 2).CompensationRate; updater.UpdateFavoriteTasks(new UpdateTasksDto { Id = 2, Favorite = true, }, 1); var task = context.Task.FirstOrDefault(x => x.Id == 2); Assert.Equal(previousCompensationRate, task.CompensationRate); }
public void FavoriteUpdater_UserCreatesNewFavorite_NewFavoriteIsCreated() { var context = new AlvTimeDbContextBuilder() .WithTasks() .WithProjects() .WithCustomers() .CreateDbContext(); var previousNumberOfFavorites = context.TaskFavorites .Where(tf => tf.UserId == 1) .ToList().Count(); var storage = new TaskStorage(context); var updater = new FavoriteUpdater(storage); updater.UpdateFavoriteTasks(new UpdateTasksDto { Id = 2, Favorite = true }, 1); var userFavorites = context.TaskFavorites .Where(tf => tf.UserId == 1) .ToList(); Assert.Equal(previousNumberOfFavorites + 1, userFavorites.Count()); }
public TasksController(RetrieveUsers userRetriever, ITaskStorage taskStorage, FavoriteUpdater updater) { _userRetriever = userRetriever; _taskStorage = taskStorage; _updater = updater; }