コード例 #1
0
        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);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
 public TasksController(RetrieveUsers userRetriever, ITaskStorage taskStorage, FavoriteUpdater updater)
 {
     _userRetriever = userRetriever;
     _taskStorage = taskStorage;
     _updater = updater;
 }