Esempio n. 1
0
        public async Task TryToSyncTotalTokensWithPbf_PbfIsAvailable_SuccessfullySynced()
        {
            var snapshotRepo = Mock.Of <ITokensSnapshotRepository>();
            var lastTokensTotalAmountRepo = Mock.Of <ILastKnownStatsRepository>();
            var pbfClient = new Mock <IPrivateBlockchainFacadeClient>();

            pbfClient.Setup(x => x.TokensApi.GetTotalTokensSupplyAsync())
            .ReturnsAsync(new TotalTokensSupplyResponse());
            pbfClient.Setup(x => x.TokensApi.GetTokenGatewayWalletBalance())
            .ReturnsAsync(new TotalTokensSupplyResponse());

            TokensStatisticsService tokensStatisticsService;

            using (var logFactory = LogFactory.Create().AddUnbufferedConsole())
            {
                tokensStatisticsService = new TokensStatisticsService(logFactory,
                                                                      pbfClient.Object,
                                                                      snapshotRepo,
                                                                      lastTokensTotalAmountRepo);
            }

            var result = await tokensStatisticsService.SyncTotalTokensAsync();

            Assert.Equal(TokensErrorCodes.None, result);
        }
Esempio n. 2
0
        public async Task TryToSyncTotalTokensWithPbf_PbfNotAvailable_BusinessErrorIsReturned()
        {
            var snapshotRepo = Mock.Of <ITokensSnapshotRepository>();
            var lastTokensTotalAmountRepo = Mock.Of <ILastKnownStatsRepository>();
            var pbfClient = new Mock <IPrivateBlockchainFacadeClient>();

            pbfClient.Setup(x => x.TokensApi.GetTotalTokensSupplyAsync())
            .ThrowsAsync(new Exception());


            TokensStatisticsService tokensStatisticsService;

            using (var logFactory = LogFactory.Create().AddUnbufferedConsole())
            {
                tokensStatisticsService = new TokensStatisticsService(logFactory,
                                                                      pbfClient.Object,
                                                                      snapshotRepo,
                                                                      lastTokensTotalAmountRepo);
            }

            var result = await tokensStatisticsService.SyncTotalTokensAsync();

            Assert.Equal(TokensErrorCodes.PrivateBlockchainFacadeIsNotAvailable, result);
        }