public void checkWorkaholic() { IAchievementGainer _workaholic = new WorkaholicGain(); NpgsqlConnection connection = new NpgsqlConnection(_connstring); connection.Open(); User popo = User.NewUser("Popo"); IHabitRepository habitRepo = new PostgresHabitRepository(connection, null); IBadgeRepository badgeRepo = new PostgresBadgeRepository(connection, null); Habit belajar = Habit.addNewHabit(popo.ID, "Belajar", new string[] { "Sat", "Mon" }); habitRepo.Create(belajar); Habit olahraga = Habit.addNewHabit(popo.ID, "Olahraga", new string[] { "Mon" }); habitRepo.Create(olahraga); List <Habit> habitList = new List <Habit>(); habitList.Add(belajar); habitList.Add(olahraga); AbcApplication daily = new HabitTracker(habitList); ILogsRepository repoLogs = new PostgresLogsRepository(connection, null); Track track; track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 7)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 9)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 14)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 16)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 21)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 23)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 28)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 3, 30)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 4, 4)); daily.Do(track); repoLogs.AddLogs(track); track = new HabitTrack(belajar, popo.ID, new DateTime(2020, 4, 6)); daily.Do(track); repoLogs.AddLogs(track); Habit founded_habit = habitRepo.FindByIdAndUserId(belajar.ID, popo.ID); List <DateTime> h = founded_habit.Log.GetLogDate; int listSize = founded_habit.Log.GetLogDate.Count; if (founded_habit.isWorkaholic()) { badgeRepo.CreateBadge(_workaholic.GainAchievement(popo.ID), founded_habit.Log.GetLogDate[listSize - 1]); } Assert.True(founded_habit.isWorkaholic() == true); }