Ejemplo n.º 1
0
        public async Task ServiceReadsAccountIfOneExists()
        {
            //Arrange
            string  serviceId       = "serviceId";
            Account originalAccount = await DefaultAccountFactoryService.CreateDefaultAccountAsync(serviceId);

            int originalAccountRating = originalAccount.GetAccountRating();
            int accountSoftCurrency   = originalAccount.GetAccountSoftCurrency();
            int accountHardCurrency   = originalAccount.GetAccountHardCurrency();

            //Act
            NetworkLibrary.NetworkLibrary.Http.LobbyModel lobbyModel = await LobbyModelFacadeService.CreateAsync(originalAccount.ServiceId);

            //Assert
            Assert.AreEqual(originalAccountRating, lobbyModel.AccountDto.AccountRating);
            Assert.AreEqual(accountSoftCurrency, lobbyModel.AccountDto.SoftCurrency);
            Assert.AreEqual(accountHardCurrency, lobbyModel.AccountDto.HardCurrency);
            Assert.IsNotNull(lobbyModel);
            Assert.IsNotNull(lobbyModel.AccountDto);
            Assert.IsNotNull(lobbyModel.AccountDto.Warships);
            Assert.IsTrue(lobbyModel.AccountDto.Warships.Count > 1);
            // Assert.IsNotNull(lobbyModel.WarshipPowerScaleModel);
            Assert.IsNotNull(lobbyModel.WarshipRatingScaleModel);
            Assert.IsNotNull(lobbyModel.RewardsThatHaveNotBeenShown);

            foreach (var warshipDto in lobbyModel.AccountDto.Warships)
            {
                Assert.IsNotNull(warshipDto.Description);
                Assert.IsNotNull(warshipDto.WarshipName);
                Assert.IsNotNull(warshipDto.CombatRoleName);
                // Assert.IsTrue(warshipDto.ViewTypeId==ViewTypeId.HareShip
                //               || warshipDto.ViewTypeId==ViewTypeId.BirdPlayer
                //               ||warshipDto.ViewTypeId==ViewTypeId.SmileyPlayer);
            }
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            Console.WriteLine("Initialization");
            IDbConnectionConfig dbConnectionConfig = new DbConnectionConfig(DatabaseName);

            //Создать БД
            dbContextFactory = new DbContextFactory(dbConnectionConfig);
            DbContext        = dbContextFactory.Create(DatabaseName);
            //Ввести базовые данные
            var seeder = new DataSeeder();

            seeder.Seed(DbContext);
            //Прервать текущие сессии
            DbContext.Accounts.FromSql(new RawSqlString("ALTER DATABASE {0} SET postgres WITH ROLLBACK IMMEDIATE"), DatabaseName);
            //Очиста аккаунта
            TruncateAccountsTable();
            string connectionString = dbConnectionConfig.GetConnectionString();
            //Создать сервисы
            NpgsqlConnection               npgsqlConnection              = new NpgsqlConnection(connectionString);
            ISkinsDbReaderService          skinsDbReaderService          = new SkinsDbReaderService(DbContext);
            IDbWarshipsStatisticsReader    dbWarshipsStatisticsReader    = new DbWarshipsStatisticsReader(npgsqlConnection);
            IDbAccountWarshipReaderService dbAccountWarshipReaderService = new DbAccountWarshipReaderService(dbWarshipsStatisticsReader, skinsDbReaderService);
            AccountResourcesDbReader       accountResourcesDbReader      = new AccountResourcesDbReader(npgsqlConnection);

            AccountReaderService         = new AccountDbReaderService(dbAccountWarshipReaderService, accountResourcesDbReader);
            NotShownRewardsReaderService = new NotShownRewardsReaderService(DbContext);
            DefaultAccountFactoryService = new DefaultAccountFactoryService(DbContext);
            var accountRegistrationService            = new AccountRegistrationService(DefaultAccountFactoryService);
            var warshipsCharacteristicsService        = new WarshipsCharacteristicsService();
            AccountMapperService accountMapperService = new AccountMapperService(warshipsCharacteristicsService);

            AccountFacadeService = new AccountFacadeService(AccountReaderService, accountRegistrationService);
            var bundleVersionService = new BundleVersionService();

            LobbyModelFacadeService = new LobbyModelFacadeService(AccountFacadeService, NotShownRewardsReaderService,
                                                                  accountMapperService, bundleVersionService);

            UsernameValidatorService usernameValidatorService = new UsernameValidatorService();
            UsernameChangingService  usernameChangingService  = new UsernameChangingService(usernameValidatorService, DbContext);

            LobbyModelController            = new LobbyModelController(LobbyModelFacadeService, usernameChangingService);
            WarshipImprovementCostChecker   = new WarshipImprovementCostChecker();
            WarshipImprovementFacadeService = new WarshipImprovementFacadeService(AccountReaderService, DbContext, WarshipImprovementCostChecker);
        }
Ejemplo n.º 3
0
        public async Task ServiceCreatesAnAccountIfItIsNot()
        {
            //Arrange
            string serviceId = "someServiceId";

            //Act
            NetworkLibrary.NetworkLibrary.Http.LobbyModel lobbyModel = await LobbyModelFacadeService.CreateAsync(serviceId);

            //Assert
            Assert.IsNotNull(lobbyModel);
            Assert.IsNotNull(lobbyModel.AccountDto);
            Assert.IsNotNull(lobbyModel.AccountDto.Warships);
            Assert.IsTrue(lobbyModel.AccountDto.Warships.Count > 1);
            // Assert.IsNotNull(lobbyModel.WarshipPowerScaleModel);
            Assert.IsNotNull(lobbyModel.WarshipRatingScaleModel);
            Assert.IsNotNull(lobbyModel.RewardsThatHaveNotBeenShown);

            foreach (var warshipDto in lobbyModel.AccountDto.Warships)
            {
                Assert.IsNotNull(warshipDto.Description);
                Assert.IsNotNull(warshipDto.WarshipName);
                Assert.IsNotNull(warshipDto.CombatRoleName);
            }
        }
Ejemplo n.º 4
0
 public LobbyModelController(LobbyModelFacadeService lobbyModelFacadeService,
                             UsernameChangingService usernameChangingService)
 {
     this.lobbyModelFacadeService = lobbyModelFacadeService;
     this.usernameChangingService = usernameChangingService;
 }