public async Task SaveDictionaries(
            List <DictionaryLanguage> languages,
            List <DictionaryNations> natons,
            List <DictionaryVehicleType> vehicleTypes,
            List <AchievementSection> achievementSections,
            List <DictionaryClanRole> clanRoles)
        {
            await _dbContext.MergeLanguages(languages);

            await _dbContext.MergeNations(natons);

            await _dbContext.MergeVehicleType(vehicleTypes);

            await _dbContext.MergeAchievementSection(achievementSections);

            await _dbContext.MergeClanRoles(clanRoles);

            await _dbContext.SaveChangesAsync();
        }
Пример #2
0
        public async Task SaveAccountClanInfoTest(
            long accountId,
            long dbClanId,
            long wgClanId,
            string dbPlayerRole,
            string wgPlayerRole)
        {
            var accountDataAccessor = _container.Resolve <IAccountDataAccessor>();

            if (dbClanId > 0)
            {
                var dbAccountClanInfo = new AccountClanInfo
                {
                    AccountId  = accountId,
                    ClanId     = dbClanId,
                    PlayerRole = dbPlayerRole
                };
                await _dbContext.AccountClanInfo.AddAsync(dbAccountClanInfo);

                await _dbContext.SaveChangesAsync();

                _dbContext.Entry(dbAccountClanInfo).State = EntityState.Detached;
            }

            var wgAccountClanInfo = new AccountClanInfo
            {
                AccountId  = accountId,
                ClanId     = wgClanId,
                PlayerRole = wgPlayerRole
            };

            await accountDataAccessor.SaveAccountClanInfoAsync(accountId, wgAccountClanInfo);

            var savedClanInfo = await _dbContext.AccountClanInfo
                                .SingleOrDefaultAsync(c => c.AccountId == accountId);

            if (wgClanId > 0)
            {
                Assert.NotNull(savedClanInfo);
                Assert.Equal(wgClanId, savedClanInfo.ClanId);
                Assert.Equal(wgPlayerRole, savedClanInfo.PlayerRole);
            }
            else
            {
                Assert.Null(savedClanInfo);
            }
        }
Пример #3
0
        public async Task CreateClanHistoryOperationTest(
            long accountId,
            int databaseClanId,
            int wgClanId,
            string databasePlayerRole,
            string wgPlayerRole,
            bool historyMustBeCreated)
        {
            var operation = _container.Resolve <CreateAccountClanHistoryOperation>();

            // FillingDatabase
            if (databaseClanId > 0)
            {
                var clanInfo = new AccountClanInfo
                {
                    AccountId  = accountId,
                    ClanId     = databaseClanId,
                    PlayerRole = databasePlayerRole
                };
                await _dbContext.AccountClanInfo.AddAsync(clanInfo);

                await _dbContext.SaveChangesAsync();

                _dbContext.Entry(clanInfo).State = EntityState.Detached;
            }
            var operationContext = new StatisticsCollectorOperationContext
            {
                Accounts = new List <SatisticsCollectorAccountOperationContext>
                {
                    new SatisticsCollectorAccountOperationContext
                    {
                        WargamingAccountInfo = new AccountInfo
                        {
                            AccountId       = accountId,
                            AccountClanInfo = new AccountClanInfo
                            {
                                ClanId     = wgClanId,
                                PlayerRole = wgPlayerRole
                            }
                        },
                        CurrentAccountInfo = new AccountInfo
                        {
                            AccountId = accountId
                        }
                    }
                }
            };

            await operation.Execute(operationContext);

            var history = operationContext.Accounts.Single().AccountClanHistory;

            if (historyMustBeCreated)
            {
                Assert.NotNull(history);
                Assert.Equal(wgClanId, history.ClanId ?? 0);
                Assert.Equal(wgPlayerRole, history.PlayerRole);
            }
            else
            {
                Assert.Null(history);
            }
        }
Пример #4
0
        public async Task SaveProlongedAccountAsync(long accountId, string accessToken, DateTime accesTokenExpiration)
        {
            var accountInfo = await _dbContext.AccountInfo
                              .SingleAsync(a => a.AccountId == accountId);

            accountInfo.AccessToken           = accessToken;
            accountInfo.AccessTokenExpiration = accesTokenExpiration;
            await _dbContext.SaveChangesAsync();
        }