Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update dependencies #748

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CommonProperties.Test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<!-- Common dependencies. Not *all* projects need all of these, but enough to make it worth doing. -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="Xunit.Combinatorial" Version="1.5.25" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
</ItemGroup>

</Project>
39 changes: 19 additions & 20 deletions Google.Api.Gax.Grpc.Tests/AsyncResponseStreamTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

using Google.Api.Gax.Grpc.Testing;
using Grpc.Core;
using Moq;
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -61,42 +60,42 @@ public async Task MoveNextAsync_WithCancellationToken()
// Tests for cancellation tokens being propagated

[Fact]
public void MoveNextAsync_Parameterless_WithoutGetAsyncEnumerator_UsesCancellationTokenNone()
public async Task MoveNextAsync_Parameterless_WithoutGetAsyncEnumerator_UsesCancellationTokenNone()
{
var mock = new Mock<IAsyncStreamReader<int>>(MockBehavior.Strict);
mock.Setup(x => x.MoveNext(CancellationToken.None)).Returns(Task.FromResult(true)).Verifiable();
var mock = Substitute.For<IAsyncStreamReader<int>>();
mock.MoveNext(CancellationToken.None).Returns(Task.FromResult(true));

var stream = new AsyncResponseStream<int>(mock.Object);
Assert.True(stream.MoveNextAsync().Result);
var stream = new AsyncResponseStream<int>(mock);
Assert.True(await stream.MoveNextAsync());

mock.Verify();
_ = mock.Received(1).MoveNext(default);
}

[Fact]
public void MoveNextAsync_Parameterless_AfterGetAsyncEnumerator_PropagatesToken()
public async Task MoveNextAsync_Parameterless_AfterGetAsyncEnumerator_PropagatesToken()
{
var token = new CancellationTokenSource().Token;
var mock = new Mock<IAsyncStreamReader<int>>(MockBehavior.Strict);
mock.Setup(x => x.MoveNext(token)).Returns(Task.FromResult(true)).Verifiable();
var mock = Substitute.For<IAsyncStreamReader<int>>();
mock.MoveNext(token).Returns(Task.FromResult(true));

var stream = new AsyncResponseStream<int>(mock.Object);
var stream = new AsyncResponseStream<int>(mock);
stream.GetAsyncEnumerator(token);
Assert.True(stream.MoveNextAsync().Result);
Assert.True(await stream.MoveNextAsync());

mock.Verify();
_ = mock.Received(1).MoveNext(token);
}

[Fact]
public void MoveNextAsync_WithCancellationToken_PropagatesToken()
public async Task MoveNextAsync_WithCancellationToken_PropagatesToken()
{
var token = new CancellationTokenSource().Token;
var mock = new Mock<IAsyncStreamReader<int>>(MockBehavior.Strict);
mock.Setup(x => x.MoveNext(token)).Returns(Task.FromResult(true)).Verifiable();
var mock = Substitute.For<IAsyncStreamReader<int>>();
mock.MoveNext(token).Returns(Task.FromResult(true));

var stream = new AsyncResponseStream<int>(mock.Object);
Assert.True(stream.MoveNextAsync(token).Result);
var stream = new AsyncResponseStream<int>(mock);
Assert.True(await stream.MoveNextAsync(token));

mock.Verify();
_ = mock.Received(1).MoveNext(token);
}

private AsyncResponseStream<int> CreateStream(params int[] array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public async Task AtomicTaskCompletion()
// This write can fail if task completion inside writer is not atomic.
Task task = writer.WriteAsync(msg);
fake.CompleteCurrentTask();
await task.ConfigureAwait(false);
await task;
}
fake.AssertMessages(msgs);
}
Expand Down
34 changes: 17 additions & 17 deletions Google.Api.Gax.Grpc.Tests/CallSettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using Google.Api.Gax.Testing;
using Grpc.Core;
using Moq;
using NSubstitute;
using System;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -43,22 +43,22 @@ public void Merge_HeaderMutationOrdering()
[Fact]
public void ToCallOptions_NullSettings()
{
var mockClock = new Mock<IClock>();
var mockClock = Substitute.For<IClock>();
CallSettings callSettings = null;
var options = callSettings.ToCallOptions(mockClock.Object);
var options = callSettings.ToCallOptions(mockClock);
Assert.Null(options.Deadline);
mockClock.Verify(c => c.GetCurrentDateTimeUtc(), Times.Never);
mockClock.DidNotReceive().GetCurrentDateTimeUtc();
}

[Fact]
public void ToCallOptions_NoExpiration()
{
var mockClock = new Mock<IClock>();
var mockClock = Substitute.For<IClock>();
CallSettings callSettings = CallSettings.CancellationTokenNone;
Assert.Null(callSettings.Expiration);
var options = callSettings.ToCallOptions(mockClock.Object);
var options = callSettings.ToCallOptions(mockClock);
Assert.Null(options.Deadline);
mockClock.Verify(c => c.GetCurrentDateTimeUtc(), Times.Never);
mockClock.DidNotReceive().GetCurrentDateTimeUtc();
}

[Fact]
Expand All @@ -76,29 +76,29 @@ public void ToCallOptions_ExpirationTimeout()
public void ToCallOptions_ExpirationDeadline()
{
var deadline = new DateTime(2015, 6, 19, 5, 2, 3, DateTimeKind.Utc);
var mockClock = new Mock<IClock>();
var mockClock = Substitute.For<IClock>();
CallSettings callSettings = CallSettings.FromExpiration(Expiration.FromDeadline(deadline));
var options = callSettings.ToCallOptions(mockClock.Object);
var options = callSettings.ToCallOptions(mockClock);
// Value should be exact, as we control time precisely.
Assert.Equal(options.Deadline.Value, deadline);
mockClock.Verify(c => c.GetCurrentDateTimeUtc(), Times.Never);
mockClock.DidNotReceive().GetCurrentDateTimeUtc();
}

[Fact]
public void ToCallOptions_ExpirationNone()
{
var deadline = new DateTime(2015, 6, 19, 5, 2, 3, DateTimeKind.Utc);
var mockClock = new Mock<IClock>();
var mockClock = Substitute.For<IClock>();
CallSettings callSettings = CallSettings.FromExpiration(Expiration.None);
var options = callSettings.ToCallOptions(mockClock.Object);
var options = callSettings.ToCallOptions(mockClock);
Assert.Null(options.Deadline);
mockClock.Verify(c => c.GetCurrentDateTimeUtc(), Times.Never);
mockClock.DidNotReceive().GetCurrentDateTimeUtc();
}

[Fact]
public void ToCallOptions_All()
{
var mockClock = new Mock<IClock>();
var mockClock = Substitute.For<IClock>();
var callSettings = new CallSettings
(
headerMutation: metadata => metadata.Add(new Metadata.Entry("1", "one")),
Expand All @@ -109,7 +109,7 @@ public void ToCallOptions_All()
writeOptions: new WriteOptions(WriteFlags.NoCompress),
propagationToken: null // Not possible to create/mock
);
var options = callSettings.ToCallOptions(mockClock.Object);
var options = callSettings.ToCallOptions(mockClock);
Assert.Equal(1, options.Headers.Count);
Assert.Equal("[Entry: key=1, value=one]", options.Headers[0].ToString());
Assert.Null(options.Deadline);
Expand All @@ -123,7 +123,7 @@ public void ToCallOptions_InvalidHeaderMutations(string header, string value) =>
Assert.Throws<InvalidOperationException>(
() => CallSettings
.FromHeaderMutation(metadata => metadata.Add(new Metadata.Entry(header, value)))
.ToCallOptions(new Mock<IClock>().Object));
.ToCallOptions(Substitute.For<IClock>()));

[Fact]
public void ToCallOptions_ConcatenatesRoutingParams()
Expand All @@ -137,7 +137,7 @@ public void ToCallOptions_ConcatenatesRoutingParams()
.MergedWith(projects)
.MergedWith(resources);

var options = callSettings.ToCallOptions(new Mock<IClock>().Object);
var options = callSettings.ToCallOptions(Substitute.For<IClock>());

var entry = Assert.Single(options.Headers, entry => entry.Key == CallSettings.RequestParamsHeader);
Assert.Equal("locations=global&projects=my-project&resources=my-resource", entry.Value);
Expand Down
8 changes: 4 additions & 4 deletions Google.Api.Gax.Grpc.Tests/ServiceSettingsBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* https://developers.google.com/open-source/licenses/bsd
*/

using Moq;
using NSubstitute;
using System.Threading;
using Xunit;

Expand Down Expand Up @@ -33,19 +33,19 @@ public void DefaultToNulls()
[Fact]
public void Clone()
{
var clock = new Mock<IClock>();
var clock = Substitute.For<IClock>();
var callSettings = new CallSettings(new CancellationTokenSource().Token, null, null, null, null, null);
var settings = new TestSettings
{
CallSettings = callSettings,
Clock = clock.Object,
Clock = clock,
};
var clonedSettings = settings.Clone();
Assert.NotSame(settings, clonedSettings);
// CallSettings is immutable, so just a reference copy is fine.
Assert.Same(callSettings, clonedSettings.CallSettings);
Assert.Equal(settings.VersionHeader, clonedSettings.VersionHeader);
Assert.Equal(clock.Object, clonedSettings.Clock);
Assert.Equal(clock, clonedSettings.Clock);

// The version header builder really is cloned...
clonedSettings.VersionHeaderBuilder.AppendVersion("x", "1.0.0");
Expand Down
8 changes: 4 additions & 4 deletions Google.Api.Gax.Grpc/Google.Api.Gax.Grpc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<ProjectReference Include="..\Google.Api.CommonProtos\Google.Api.CommonProtos.csproj" />
<ProjectReference Include="..\Google.Api.Gax\Google.Api.Gax.csproj" />

<PackageReference Include="Grpc.Auth" Version="[2.53.0, 3.0.0)" />
<PackageReference Include="Google.Apis.Auth" Version="[1.60.0, 2.0.0)" />
<PackageReference Include="Grpc.Core.Api" Version="[2.53.0, 3.0.0)" />
<PackageReference Include="Grpc.Net.Client" Version="[2.53.0, 3.0.0)" />
<PackageReference Include="Grpc.Auth" Version="[2.60.0, 3.0.0)" />
<PackageReference Include="Google.Apis.Auth" Version="[1.66.0, 2.0.0)" />
<PackageReference Include="Grpc.Core.Api" Version="[2.60.0, 3.0.0)" />
<PackageReference Include="Grpc.Net.Client" Version="[2.60.0, 3.0.0)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Google.Api.Gax.Rest/Google.Api.Gax.Rest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\Google.Api.Gax\Google.Api.Gax.csproj" />

<PackageReference Include="Google.Apis.Auth" Version="[1.60.0, 2.0.0)" />
<PackageReference Include="Google.Apis.Auth" Version="[1.66.0, 2.0.0)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>
</Project>