コード例 #1
0
    public async Task Should_List_Specific_Kinds_Of_Rockets()
    {
        var client = new RocketClient(Factory.CreateClient());
        await ServiceProvider.WithScoped <RocketDbContext>()
        .Invoke(
            async z =>
        {
            var faker = new RocketFaker();
            z.AddRange(faker.UseSeed(100).Generate(10));

            await z.SaveChangesAsync();
        }
            );

        var response = await client.ListRocketsAsync(RocketType.AtlasV);

        response.Result.Should().HaveCount(5);
    }
コード例 #2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await _serviceProvider.WithScoped <RocketDbContext>().Invoke(
                async dbContext =>
            {
                await dbContext.Database.EnsureCreatedAsync(cancellationToken).ConfigureAwait(false);
                var rocketFaker = new RocketFaker();
                rocketFaker.UseSeed(0);
                var rockets     = rocketFaker.GenerateBetween(10, 100);
                var launchFaker = new LaunchRecordFaker(rockets);
                launchFaker.UseSeed(1);
                var launches = launchFaker.GenerateBetween(100, 1000);

                await dbContext.Rockets.AddRangeAsync(rockets, cancellationToken).ConfigureAwait(false);
                await dbContext.LaunchRecords.AddRangeAsync(launches, cancellationToken).ConfigureAwait(false);
                await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
            }
                ).ConfigureAwait(false);
        }
コード例 #3
0
    public async Task Should_List_Specific_Kinds_Of_LaunchRecords()
    {
        var client = new LaunchRecordClient(Factory.CreateClient());
        await ServiceProvider.WithScoped<RocketDbContext>()
                             .Invoke(
                                  async z =>
                                  {
                                      var faker = new RocketFaker();
                                      var rockets = faker.UseSeed(100).Generate(3);
                                      var records = new LaunchRecordFaker(rockets).UseSeed(100).Generate(10);
                                      z.AddRange(rockets);
                                      z.AddRange(records);
                                      await z.SaveChangesAsync();
                                  }
                              );

        var response = await client.ListLaunchRecordsAsync(RocketType.FalconHeavy);
        response.Result.Should().HaveCount(3);
    }
コード例 #4
0
    public async Task Should_List_Specific_Kinds_Of_Rockets()
    {
        var client = Factory.Services.GetRequiredService <IRocketClient>();
        await ServiceProvider.WithScoped <RocketDbContext>()
        .Invoke(
            async z =>
        {
            var faker = new RocketFaker();
            z.AddRange(faker.UseSeed(100).Generate(10));

            await z.SaveChangesAsync();
        }
            );

        var response = await client.GetFilteredRockets.ExecuteAsync(RocketType.AtlasV);

        response.EnsureNoErrors();

        response.Data !.Rockets !.Nodes !.Should().HaveCount(5);
    }
コード例 #5
0
    public async Task Should_List_Specific_Kinds_Of_LaunchRecords()
    {
        var client = Factory.Services.GetRequiredService <IRocketClient>();
        await ServiceProvider.WithScoped <RocketDbContext>()
        .Invoke(
            async z =>
        {
            var faker   = new RocketFaker();
            var rockets = faker.UseSeed(100).Generate(3);
            var records = new LaunchRecordFaker(rockets).UseSeed(100).Generate(10);
            z.AddRange(rockets);
            z.AddRange(records);
            await z.SaveChangesAsync();
        }
            );

        var response = await client.GetFilteredLaunchRecords.ExecuteAsync(RocketType.FalconHeavy);

        response.EnsureNoErrors();

        response.Data !.LaunchRecords !.Nodes !.Should().HaveCount(3);
    }