Exemplo n.º 1
0
        public async Task BasicGensisTime()
        {
            // Arrange
            IServiceCollection testServiceCollection = TestSystem.BuildTestServiceCollection();

            IBeaconNodeOApiClient beaconNodeOApiClient = Substitute.For <IBeaconNodeOApiClient>();

            beaconNodeOApiClient.TimeAsync(Arg.Any <CancellationToken>()).Returns(1_578_009_600uL);
            IBeaconNodeOApiClientFactory beaconNodeOApiClientFactory = Substitute.For <IBeaconNodeOApiClientFactory>();

            beaconNodeOApiClientFactory.CreateClient(Arg.Any <string>()).Returns(beaconNodeOApiClient);
            testServiceCollection.AddSingleton <IBeaconNodeOApiClientFactory>(beaconNodeOApiClientFactory);

            ServiceProvider testServiceProvider = testServiceCollection.BuildServiceProvider();

            // Act
            IBeaconNodeApi beaconNodeProxy = testServiceProvider.GetService <IBeaconNodeApi>();

            beaconNodeProxy.ShouldBeOfType(typeof(BeaconNodeProxy));
            ulong genesisTime = await beaconNodeProxy.GetGenesisTimeAsync(CancellationToken.None);

            // Assert
            genesisTime.ShouldBe(1578009600uL);
        }