Esempio n. 1
0
        public async Task AttackerShouldWinWhenOpponentIsKilledAndShouldTakeHalfHisGold()
        {
            var context      = ApplicationDbContextInMemoryFactory.InitializeContext();
            var arenaService = this.GetArenaService(context);

            var seederUsers = new UsersSeeder();
            await seederUsers.SeedUsers(context);

            var seederCoins = new UsersCoinsSeeder();
            await seederCoins.SeedUsersWithCoins(context);

            var arenaSeeder = new ArenaSeeder();
            await arenaSeeder.SeedAttackerWithKillingWeapon(context);

            var battleReportId = await arenaService.AttackOpponent("User1", "User2");

            var battleResult = context.BattleReports.Where(x => x.Id == battleReportId).SingleOrDefault().ReportString;

            var result = battleResult.Split(".\r\n");

            Assert.True(result[result.Count() - 2] == "User1 took 250 gold from User2", $"Defendant dies, but still ties.");
        }
Esempio n. 2
0
        public async Task DefendantShouldKillAttacker()
        {
            var context      = ApplicationDbContextInMemoryFactory.InitializeContext();
            var arenaService = this.GetArenaService(context);

            var seederUsers = new UsersSeeder();
            await seederUsers.SeedUsers(context);

            var seederCoins = new UsersCoinsSeeder();
            await seederCoins.SeedUsersWithCoins(context);

            var arenaSeeder = new ArenaSeeder();
            await arenaSeeder.SeedDefendantWithKillingWeapon(context);

            var battleReportId = await arenaService.AttackOpponent("User1", "User2");

            var battleResult = context.BattleReports.Where(x => x.Id == battleReportId).SingleOrDefault().ReportString;

            var result = battleResult.Split(".\r\n");

            Assert.True(result[result.Count() - 2] == "User2 defended his glory and gold", $"Defendant lives, but still looses.");
            Assert.True(result[result.Count() - 3] == "User1 died", $"Attacker doen't die when hit with killing blow.");
        }