Ejemplo n.º 1
0
    public async Task Should_ThrowInvalidArgument_When_NameOfMessageIsEmpty()
    {
        // Given
        var client = new Grpc.Rockets.RocketsClient(_factory.CreateGrpcChannel());

        // When
        async Task Action()
        {
            await client.GetRocketsAsync(new GetRocketRequest { Id = "" });
        }

        // Then
        var rpcException = await Assert.ThrowsAsync <RpcException>(Action);

        Assert.Equal(StatusCode.InvalidArgument, rpcException.Status.StatusCode);
    }
Ejemplo n.º 2
0
    public async Task Should_ResponseMessage_When_MessageIsValid()
    {
        await _factory.Services.WithScoped <RocketDbContext>()
        .Invoke(
            async z =>
        {
            var faker   = new RocketFaker();
            var rockets = faker.Generate(3);
            var records = new LaunchRecordFaker(rockets).Generate(10);
            z.AddRange(rockets);
            z.AddRange(records);
            await z.SaveChangesAsync();
        }
            );

        // Given
        var client = new Grpc.Rockets.RocketsClient(_factory.CreateGrpcChannel());

        // When
        var response = await client.ListRockets(new ListRocketsRequest()).ResponseStream.ReadAllAsync().ToListAsync();

        // Then nothing happen.
        response.Should().HaveCountGreaterThan(0);
    }