Example #1
0
        public async Task GetOrCreateDailyTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            var daily = await dailyService.GetOrCreateDailyAsync(2L);

            Assert.NotNull(daily);
        }
Example #2
0
        public async Task DailyStreakResetTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            await dailyService.ClaimDailyAsync(4L);

            var daily = await dailyService.GetOrCreateDailyAsync(4L);

            Assert.Equal(0, daily.CurrentStreak);
        }
Example #3
0
        public async Task CheckIfDailyUpdatedInDatabaseTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            await dailyService.ClaimDailyAsync(2L);

            var daily = await dailyService.GetOrCreateDailyAsync(2L);

            Assert.NotNull(daily);
            Assert.Equal(1, daily.CurrentStreak);
            Assert.Equal(1, daily.LongestStreak);
            Assert.InRange(daily.LastClaimTime, DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow.AddMinutes(2));
        }