Skip to content

Commit

Permalink
Merge pull request #51 from max-ieremenko/release/1.3.2
Browse files Browse the repository at this point in the history
Release/1.3.2
  • Loading branch information
max-ieremenko authored Nov 5, 2021
2 parents fc516e1 + 035e473 commit 29dc685
Show file tree
Hide file tree
Showing 37 changed files with 398 additions and 201 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,7 +54,8 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<HeadersService>();
})
.StartAsync(HttpProtocols.Http1);
.StartAsync(HttpProtocols.Http1)
.ConfigureAwait(false);

var document = await OpenApiDocument
.DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,8 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<MultipurposeService>();
})
.StartAsync(HttpProtocols.Http1);
.StartAsync(HttpProtocols.Http1)
.ConfigureAwait(false);

var document = await OpenApiDocument
.DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,7 +62,8 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<HeadersService>();
})
.StartAsync(HttpProtocols.Http1);
.StartAsync(HttpProtocols.Http1)
.ConfigureAwait(false);

var document = await OpenApiDocument
.DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,7 +68,8 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<MultipurposeService>();
})
.StartAsync(HttpProtocols.Http1);
.StartAsync(HttpProtocols.Http1)
.ConfigureAwait(false);

var document = await OpenApiDocument
.DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,15 +47,16 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<ErrorService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);

DomainService = _host.ClientFactory.CreateClient<IErrorService>(_host.Channel);
}

[OneTimeTearDown]
public async Task AfterAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,15 +38,16 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<HeadersService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);

DomainService = _host.ClientFactory.CreateClient<IHeadersService>(_host.Channel);
}

[OneTimeTearDown]
public async Task AfterAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}
}
}
16 changes: 10 additions & 6 deletions Sources/ServiceModel.Grpc.AspNetCore.Test/HostRegistrationsTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,7 +84,7 @@ public void BeforeEachTest()
[TearDown]
public async Task AfterEachAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}

[Test]
Expand All @@ -99,7 +99,8 @@ await _host
{
endpoints.MapGrpcService<ErrorService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);
_domainService = _host.ClientFactory.CreateClient<IErrorService>(_host.Channel);

Assert.Throws<RpcException>(() => _domainService.ThrowApplicationException("some message"));
Expand All @@ -120,7 +121,8 @@ await _host
{
endpoints.MapGrpcService<ErrorService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);
_domainService = _host.ClientFactory.CreateClient<IErrorService>(_host.Channel);

Assert.Throws<RpcException>(() => _domainService.ThrowApplicationException("some message"));
Expand All @@ -142,7 +144,8 @@ await _host
{
endpoints.MapGrpcService<IErrorService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);
_domainService = _host.ClientFactory.CreateClient<IErrorService>(_host.Channel);

Assert.Throws<RpcException>(() => _domainService.ThrowApplicationException("some message"));
Expand All @@ -164,7 +167,8 @@ await _host
{
endpoints.MapGrpcService<ErrorService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);
_domainService = _host.ClientFactory.CreateClient<IErrorService>(_host.Channel);

Assert.Throws<RpcException>(() => _domainService.ThrowApplicationException("some message"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task IgnoreNonSwaggerUiRequest()
.SetupGet(r => r.ContentType)
.Returns(MediaTypeNames.Application.Json);

await _sut.Invoke(_httpContext.Object);
await _sut.Invoke(_httpContext.Object).ConfigureAwait(false);

_isNextCalled.ShouldBeTrue();
_loggerOutput.ShouldBeEmpty();
Expand All @@ -140,7 +140,7 @@ public async Task ApiDescriptionNotFound()
.Setup(a => a.FindApiDescription(_httpRequest.Object.Path))
.Returns((ApiDescription?)null);

await _sut.Invoke(_httpContext.Object);
await _sut.Invoke(_httpContext.Object).ConfigureAwait(false);

_isNextCalled.ShouldBeTrue();
_apiAdapter.VerifyAll();
Expand All @@ -158,7 +158,7 @@ public async Task MethodNotFound()
.Setup(a => a.GetMethod(_httpContext.Object))
.Returns((IMethod?)null);

await _sut.Invoke(_httpContext.Object);
await _sut.Invoke(_httpContext.Object).ConfigureAwait(false);

_isNextCalled.ShouldBeTrue();
_apiAdapter.VerifyAll();
Expand All @@ -183,7 +183,7 @@ public async Task NonUnaryMethodIsNotSupported(MethodType methodType)
.Setup(a => a.GetMethod(_httpContext.Object))
.Returns(_method.Object);

await _sut.Invoke(_httpContext.Object);
await _sut.Invoke(_httpContext.Object).ConfigureAwait(false);

_httpResponse.Object.StatusCode.ShouldBe((int)HttpStatusCode.NotImplemented);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,7 +39,8 @@ public async Task BeforeAll()
endpoints.MapGrpcService<GreeterService>();
endpoints.MapGrpcService<MultipurposeService>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);

DomainService = _host.ClientFactory.CreateClient<IMultipurposeService>(_host.Channel);
_greeterService = new Greeter.GreeterClient(_host.Channel);
Expand All @@ -48,13 +49,13 @@ public async Task BeforeAll()
[OneTimeTearDown]
public async Task AfterAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}

[Test]
public async Task NativeGreet()
{
var actual = await _greeterService.UnaryAsync(new HelloRequest { Name = "world" });
var actual = await _greeterService.UnaryAsync(new HelloRequest { Name = "world" }).ResponseAsync.ConfigureAwait(false);

actual.Message.ShouldBe("Hello world!");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,15 +36,16 @@ public async Task BeforeAll()
{
endpoints.MapGrpcService<Calculator>();
})
.StartAsync();
.StartAsync()
.ConfigureAwait(false);

_calculator = _host.ClientFactory.CreateClient<ICalculator>(_host.Channel);
}

[OneTimeTearDown]
public async Task AfterAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ private sealed class DomainGreeterService : IDomainGreeterService
{
public async Task<string> UnaryAsync(string name, CallContext? context)
{
var response = await new GreeterService().Unary(new HelloRequest { Name = name }, context!);
var response = await new GreeterService().Unary(new HelloRequest { Name = name }, context!).ConfigureAwait(false);
return response.Message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,19 +39,21 @@ public async Task BeforeAll()
_grpcHost = await new KestrelHost()
.ConfigureClientFactory(options => options.MarshallerFactory = ProtobufMarshallerFactory.Default)
.ConfigureEndpoints(endpoints => endpoints.MapGrpcService<GreeterService>())
.StartAsync();
.StartAsync()
.ConfigureAwait(false);

_serviceModelHost = await new KestrelHost(8081)
.ConfigureClientFactory(options => options.MarshallerFactory = ProtobufMarshallerFactory.Default)
.ConfigureEndpoints(endpoints => endpoints.MapGrpcService<DomainGreeterService>())
.StartAsync();
.StartAsync()
.ConfigureAwait(false);
}

[OneTimeTearDown]
public async Task AfterAll()
{
await _grpcHost.DisposeAsync();
await _serviceModelHost.DisposeAsync();
await _grpcHost.DisposeAsync().ConfigureAwait(false);
await _serviceModelHost.DisposeAsync().ConfigureAwait(false);
}

[Test]
Expand All @@ -60,7 +62,7 @@ public async Task AfterAll()
public async Task UnaryNativeCall(string channelName)
{
var client = new Greeter.GreeterClient(GetChannel(channelName));
var response = await client.UnaryAsync(new HelloRequest { Name = "world" });
var response = await client.UnaryAsync(new HelloRequest { Name = "world" }).ResponseAsync.ConfigureAwait(false);

response.Message.ShouldBe("Hello world!");
}
Expand All @@ -80,12 +82,12 @@ public async Task DuplexStreamingNativeCall(string channelName)

foreach (var name in new[] { "person 1", "person 2" })
{
await call.RequestStream.WriteAsync(new HelloRequest { Name = name });
await call.RequestStream.WriteAsync(new HelloRequest { Name = name }).ConfigureAwait(false);
}

await call.RequestStream.CompleteAsync();
await call.RequestStream.CompleteAsync().ConfigureAwait(false);

while (await call.ResponseStream.MoveNext(default))
while (await call.ResponseStream.MoveNext(default).ConfigureAwait(false))
{
response.Add(call.ResponseStream.Current.Message);
}
Expand All @@ -100,7 +102,7 @@ public async Task DuplexStreamingNativeCall(string channelName)
public async Task UnaryDomainCall(string channelName)
{
var client = _serviceModelHost.ClientFactory.CreateClient<IDomainGreeterService>(GetChannel(channelName));
var response = await client.UnaryAsync("world");
var response = await client.UnaryAsync("world").ConfigureAwait(false);

response.ShouldBe("Hello world!");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright>
// Copyright 2020 Max Ieremenko
// Copyright 2020-2021 Max Ieremenko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -71,15 +71,15 @@ public async Task BeforeAll()
});

ConfigureKestrelHost(_host);
await _host.StartAsync();
await _host.StartAsync().ConfigureAwait(false);

_domainService = _host.ClientFactory.CreateClient<IServiceWithAuthentication>(_host.Channel);
}

[OneTimeTearDown]
public async Task AfterAll()
{
await _host.DisposeAsync();
await _host.DisposeAsync().ConfigureAwait(false);
}

[Test]
Expand Down
Loading

0 comments on commit 29dc685

Please sign in to comment.