Skip to content

Commit

Permalink
Updated xunit (2.4.1 -> 2.9.0) (#7275)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Jul 19, 2024
1 parent e302aa4 commit 76c4f25
Show file tree
Hide file tree
Showing 98 changed files with 518 additions and 533 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="Unquote" Version="6.1.0" />
<PackageVersion Include="Xunit" Version="2.4.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageVersion Include="Xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
4 changes: 2 additions & 2 deletions src/GreenDonut/test/Core.Tests/DataLoaderExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task SetNewCacheEntry()
loader.Set(key, value);

// assert
var loadResult = await loader.LoadAsync(key).ConfigureAwait(false);
var loadResult = await loader.LoadAsync(key);

Assert.Equal(value, loadResult);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public async Task SetTwice()
loader.Set(key, second);

// assert
var loadResult = await loader.LoadAsync(key).ConfigureAwait(false);
var loadResult = await loader.LoadAsync(key);

Assert.Equal(first, loadResult);
}
Expand Down
8 changes: 4 additions & 4 deletions src/GreenDonut/test/Core.Tests/TaskCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void TryAddTwice()
}

[Fact(DisplayName = "GetOrAddTask: Should return new item if nothing is cached")]
public void GetOrAddTaskWhenNothingIsCached()
public async Task GetOrAddTaskWhenNothingIsCached()
{
// arrange
var cacheSize = 10;
Expand All @@ -227,11 +227,11 @@ public void GetOrAddTaskWhenNothingIsCached()
var resolved = cache.GetOrAddTask(key, _ => new Promise<string>(Task.FromResult("Quox")));

// assert
Assert.Equal("Quox", resolved.Result);
Assert.Equal("Quox", await resolved);
}

[Fact(DisplayName = "TryGetValue (String): Should return one result")]
public void GetOrAddTaskWhenNothingIsCached_IntegerKey()
public async Task GetOrAddTaskWhenNothingIsCached_IntegerKey()
{
// arrange
var cacheSize = 10;
Expand All @@ -242,6 +242,6 @@ public void GetOrAddTaskWhenNothingIsCached_IntegerKey()
var resolved = cache.GetOrAddTask(key, _ => new Promise<string>(Task.FromResult("Quox")));

// assert
Assert.Equal("Quox", resolved.Result);
Assert.Equal("Quox", await resolved);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace HotChocolate.ApolloFederation;
public class ReferenceResolverAttributeTests
{
[Fact(Skip = "Needs to be fixed!")]
public async void InClassRefResolver_PureCodeFirst()
public async Task InClassRefResolver_PureCodeFirst()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -36,7 +36,7 @@ public async void InClassRefResolver_PureCodeFirst()
}

[Fact]
public async void ExternalRefResolver_PureCodeFirst()
public async Task ExternalRefResolver_PureCodeFirst()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -57,7 +57,7 @@ public async void ExternalRefResolver_PureCodeFirst()
}

[Fact]
public async void SingleKey_CompiledResolver()
public async Task SingleKey_CompiledResolver()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -76,7 +76,7 @@ public async void SingleKey_CompiledResolver()
}

[Fact]
public async void ExternalFields_Set()
public async Task ExternalFields_Set()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -98,7 +98,7 @@ public async void ExternalFields_Set()
}

[Fact]
public async void ExternalFields_Not_Set()
public async Task ExternalFields_Not_Set()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -118,7 +118,7 @@ public async void ExternalFields_Not_Set()
}

[Fact]
public async void MultiKey_CompiledResolver()
public async Task MultiKey_CompiledResolver()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -139,7 +139,7 @@ public async void MultiKey_CompiledResolver()
}

[Fact]
public async void ExternalRefResolver_RenamedMethod_PureCodeFirst()
public async Task ExternalRefResolver_RenamedMethod_PureCodeFirst()
{
// arrange
var schema = await new ServiceCollection()
Expand All @@ -159,7 +159,7 @@ public async void ExternalRefResolver_RenamedMethod_PureCodeFirst()
}

[Fact]
public void InClassRefResolver_RenamedMethod_InvalidName_PureCodeFirst()
public async Task InClassRefResolver_RenamedMethod_InvalidName_PureCodeFirst()
{
// arrange
async Task SchemaCreation()
Expand All @@ -173,11 +173,11 @@ async Task SchemaCreation()

// act
// assert
Assert.ThrowsAsync<SchemaException>(SchemaCreation);
await Assert.ThrowsAsync<SchemaException>(SchemaCreation);
}

[Fact]
public void ExternalRefResolver_RenamedMethod_InvalidName_PureCodeFirst()
public async Task ExternalRefResolver_RenamedMethod_InvalidName_PureCodeFirst()
{
// arrange
async Task SchemaCreation()
Expand All @@ -191,7 +191,7 @@ async Task SchemaCreation()

// act
// assert
Assert.ThrowsAsync<SchemaException>(SchemaCreation);
await Assert.ThrowsAsync<SchemaException>(SchemaCreation);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void CreateInstance_PolicyRoles_PolicyIsSetRolesIsEmpty()

// assert
Assert.Equal("abc", authorizeDirective.Policy);
Assert.Empty(authorizeDirective.Roles);
Assert.Empty(authorizeDirective.Roles!);
}

[Fact]
Expand Down Expand Up @@ -76,7 +76,7 @@ public void CreateInstance_Roles_RolesHasItems()
// assert
Assert.Null(authorizeDirective.Policy);
Assert.Collection(
authorizeDirective.Roles,
authorizeDirective.Roles!,
t => Assert.Equal("a", t),
t => Assert.Equal("b", t));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public MyInputObjectOut DoSomething(MyInputObject input) =>


[Fact]
public void DefaultValueTests_Simple()
public async Task DefaultValueTests_Simple()
{
// Arrange
var services = new ServiceCollection();
Expand All @@ -43,10 +43,10 @@ public void DefaultValueTests_Simple()

var serviceProvider = services.BuildServiceProvider();
var executorResolver = serviceProvider.GetRequiredService<IRequestExecutorResolver>();
var executor = executorResolver.GetRequestExecutorAsync().Result;
var executor = await executorResolver.GetRequestExecutorAsync();

// Act
var result = executor.ExecuteAsync("mutation{ doSomething(input: { }) { result } }").Result;
var result = await executor.ExecuteAsync("mutation{ doSomething(input: { }) { result } }");

// Extract the data from the result
var jsonResult = result.ToJson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public async Task OperationBatch()
using var response = await client.SendAsync(request);

// assert
Assert.Equal(response.StatusCode, OK);
Assert.Equal(OK, response.StatusCode);

var sortedResults = new SortedList<(int?, int?), OperationResult>();

Expand Down Expand Up @@ -581,7 +581,7 @@ public async Task VariableBatch()
using var response = await client.SendAsync(request);

// assert
Assert.Equal(response.StatusCode, OK);
Assert.Equal(OK, response.StatusCode);

await foreach (var result in response.ReadAsResultStreamAsync())
{
Expand All @@ -606,7 +606,7 @@ public async Task After_Execution_StatusCode_Is_200()
using var response = await client.SendAsync(request);

// assert
Assert.Equal(response.StatusCode, OK);
Assert.Equal(OK, response.StatusCode);
}

private HttpClient GetClient(HttpTransportVersion serverTransportVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public Task Subscribe_Disconnect()
// ... try iterate
await foreach (var unused in socketResult.ReadResultsAsync().WithCancellation(ct))
{
Assert.True(false, "Stream should have been aborted");
Assert.Fail("Stream should have been aborted");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public async Task AzFuncIsolatedProcess_EndToEndTestAsync()
// Execute Query Test for end-to-end validation...
// NOTE: This uses the new Az Func Isolated Process extension to execute
// via HttpRequestData...
var response = await requestExecutor.ExecuteAsync(request).ConfigureAwait(false);
var response = await requestExecutor.ExecuteAsync(request);

// Read, Parse & Validate the response...
var resultContent = await ReadResponseAsStringAsync(response).ConfigureAwait(false);
var resultContent = await ReadResponseAsStringAsync(response);
Assert.False(string.IsNullOrWhiteSpace(resultContent));

dynamic json = JObject.Parse(resultContent!);
Expand Down Expand Up @@ -87,10 +87,10 @@ public async Task AzFuncIsolatedProcess_FunctionsContextItemsTestAsync()
// Execute Query Test for end-to-end validation...
// NOTE: This uses the new Az Func Isolated Process extension to execute
// via HttpRequestData...
var response = await requestExecutor.ExecuteAsync(request).ConfigureAwait(false);
var response = await requestExecutor.ExecuteAsync(request);

// Read, Parse & Validate the response...
var resultContent = await ReadResponseAsStringAsync(response).ConfigureAwait(false);
var resultContent = await ReadResponseAsStringAsync(response);
Assert.False(string.IsNullOrWhiteSpace(resultContent));

dynamic json = JObject.Parse(resultContent!);
Expand All @@ -116,10 +116,10 @@ public async Task AzFuncIsolatedProcess_BananaCakePopTestAsync()
// Execute Query Test for end-to-end validation...
// NOTE: This uses the new Az Func Isolated Process extension to execute
// via HttpRequestData...
var httpResponseData = await requestExecutor.ExecuteAsync(httpRequestData).ConfigureAwait(false);
var httpResponseData = await requestExecutor.ExecuteAsync(httpRequestData);

// Read, Parse & Validate the response...
var resultContent = await ReadResponseAsStringAsync(httpResponseData).ConfigureAwait(false);
var resultContent = await ReadResponseAsStringAsync(httpResponseData);
Assert.NotNull(resultContent);
Assert.False(string.IsNullOrWhiteSpace(resultContent));
Assert.True(resultContent!.Contains("<html") && resultContent.Contains("</html>"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private static void ExpectErrors(Action<SchemaBuilder> configureBuilder)

builder.Create();

Assert.False(true, "Expected error!");
Assert.Fail("Expected error!");
}
catch (SchemaException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task Error_Filter_Adds_Details()
}

[Fact]
public async void Resolver_InvalidParentCast()
public async Task Resolver_InvalidParentCast()
{
// arrange
using var snapshot = StartResultSnapshot();
Expand All @@ -129,7 +129,7 @@ public async void Resolver_InvalidParentCast()
}

[Fact]
public async void PureResolver_InvalidParentCast()
public async Task PureResolver_InvalidParentCast()
{
// arrange
using var snapshot = StartResultSnapshot();
Expand All @@ -152,7 +152,7 @@ public async void PureResolver_InvalidParentCast()
}

[Fact]
public async void SetMaxAllowedValidationErrors_To_1()
public async Task SetMaxAllowedValidationErrors_To_1()
{
// arrange
using var snapshot = StartResultSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task ConvertSourceObject()
// arrange
var conversionTriggered = false;

var executor = new ServiceCollection()
var executor = await new ServiceCollection()
.AddGraphQL()
.AddQueryType<QueryType>()
.AddTypeConverter<Foo, Baz>(input =>
Expand All @@ -23,8 +23,7 @@ public async Task ConvertSourceObject()
.Services
.BuildServiceProvider()
.GetRequiredService<IRequestExecutorResolver>()
.GetRequestExecutorAsync()
.Result;
.GetRequestExecutorAsync();

// act
var result = await executor.ExecuteAsync("{ foo { qux } }");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public virtual async Task Invalid_Message_Type()
var sender = services.GetRequiredService<ITopicEventSender>();

var result = await services.ExecuteRequestAsync(
"subscription { onMessage2(arg1: \"a\", arg2: \"b\") }",
cancellationToken: cts.Token)
.ConfigureAwait(false);
"subscription { onMessage2(arg1: \"a\", arg2: \"b\") }",
cancellationToken: cts.Token);

// we need to execute the read for the subscription to start receiving.
await using var responseStream = result.ExpectResponseStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public void Set_Should_Throw_When_Disposed()
}

[Fact]
public void WaitAsync_Should_Throw_When_Disposed()
public async Task WaitAsync_Should_Throw_When_Disposed()
{
// Arrange
var autoResetEvent = new AsyncAutoResetEvent();
autoResetEvent.Dispose();

// Act & Assert
Assert.ThrowsAsync<ObjectDisposedException>(()
await Assert.ThrowsAsync<ObjectDisposedException>(()
=> autoResetEvent.WaitAsync(CancellationToken.None));
}

Expand Down
Loading

0 comments on commit 76c4f25

Please sign in to comment.