Esempio n. 1
0
        public static void SetupWargamingApiMockDependencies(this ContainerBuilder containerBuilder,
                                                             DataStubs dataStubs)
        {
            var wgApiClientMock = new Mock <IWargamingApiClient>();

            wgApiClientMock.Setup(c => c.ProlongateAccount(It.IsAny <string>()))
            .ReturnsAsync(dataStubs.AccountInfo);

            wgApiClientMock.Setup(c => c.GetAccountInfoAllStatisticsAsync(It.IsAny <long>(), It.IsAny <string>()))
            .ReturnsAsync(dataStubs.WargamingAccountInfo);

            wgApiClientMock.Setup(c => c.GetAccountClanInfoAsync(It.IsAny <long>()))
            .ReturnsAsync(dataStubs.AccountClanInfo);

            wgApiClientMock.Setup(c => c.GetAccountAchievementsAsync(It.IsAny <long>()))
            .ReturnsAsync(dataStubs.AccountInfoAchievements);

            wgApiClientMock.Setup(c => c.GetTanksStatisticsAsync(It.IsAny <long>(), It.IsAny <string>()))
            .ReturnsAsync(dataStubs.AccountTanksStatistics);

            wgApiClientMock.Setup(c => c.GetAccountTankAchievementsAsync(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <List <int> >()))
            .ReturnsAsync(dataStubs.AccountInfoTankAchievements);


            containerBuilder.RegisterInstance(wgApiClientMock.Object).As <IWargamingApiClient>();
        }
        public StatisticCollectorTest(ITestOutputHelper output)
        {
            _output    = output;
            _dataStubs = new DataStubs(
                accountCreatedAt: DateTime.Now.AddMonths(-6),
                dbLastBattleTime: DateTime.Now.AddHours(-2),
                dbAccessTokenExp: DateTime.Now.AddDays(1),
                wgLastBattleTime: DateTime.Now.AddHours(-1)
                );

            var containerBuilder = new ContainerBuilder();

            var loggerFactory = TestOutputLoggerFactory.CreateLoggerFactory(output);

            containerBuilder.SetupLogger(loggerFactory);
            containerBuilder.AddInMemoryDataBase(loggerFactory);
            containerBuilder.ConfigureBlitzStaticianLogic();
            containerBuilder.SetupWargamingApiMockDependencies(_dataStubs);

            _container = containerBuilder.Build();

            _statisticsCollectorFactory = _container.Resolve <IStatisticsCollectorFactory>();
            _statisticsCollectorEngine  = _container.Resolve <IStatisticsCollectorEngine>();
            _dbContext = _container.Resolve <BlitzStaticianDbContext>();
        }