Skip to content
Open
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
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<LangVersion>14</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Events/Events/src/ClickView.Extensions.Events.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<PackageTags>events</PackageTags>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/Events/Events/test/EventsIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task CanPublishUsingInMemoryBus()
await eventPublisher.PublishAsync(evt);

//Wait for events to propagate/tasks to finish
await Task.Delay(100);
await Task.Delay(100, TestContext.Current.CancellationToken);

//assert
Assert.Single(eventHandler.Events);
Expand Down Expand Up @@ -55,4 +55,4 @@ public Task HandleEventAsync(CustomEvent evt)
return Task.FromResult(0);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageTags>hosting</PackageTags>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -12,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task RunAsync_RunEveryTwoSeconds()

await scheduler.StartAsync(CancellationToken.None);

await Task.Delay(TimeSpan.FromSeconds(5));
await Task.Delay(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken);

await scheduler.StopAsync(CancellationToken.None);

Expand All @@ -30,7 +30,7 @@ public void CronWorkerOption_MinGreaterThanMax_ThrowException()
{
const string everyTwoSecondCron = "*/2 * * * * *";

Assert.Throws<InvalidCronWorkerOptionException>(() =>
Assert.Throws<InvalidCronWorkerOptionException>(() =>
{ new CronWorkerOption(everyTwoSecondCron, true, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1)); });
}

Expand All @@ -48,7 +48,7 @@ public async Task RunAsync_RunEveryTwoSecondsWithJitter_Executes()
var currentTime = DateTime.UtcNow;

// Give it a bit more time to ensure the task is executed
await Task.Delay(TimeSpan.FromSeconds(4));
await Task.Delay(TimeSpan.FromSeconds(4), TestContext.Current.CancellationToken);

await scheduler.StopAsync(CancellationToken.None);

Expand All @@ -70,4 +70,4 @@ protected override Task RunAsync(CancellationToken cancellationToken)
return Task.CompletedTask;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<PackageTags>primitives</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<PackageTags>restclient rest http oauth</PackageTags>
<Description>OAuth authenticators for ClickView.Extensions.RestClient</Description>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>disable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task GetTokenClientAsync_Expired_Refreshes()

var endpoints = await factory.GetAsync();

await Task.Delay(1500);
await Task.Delay(1500, TestContext.Current.CancellationToken);

var endpoints2 = await factory.GetAsync();

Expand Down Expand Up @@ -76,4 +76,4 @@ public async Task GetTokenClientAsync_ThreadSafe_SameInstance()

Assert.Equal(await endpoints1Task, await endpoints2Task);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public async Task GetTokensAsync_TokenStoreReturnsNull_DoesNotReturnListWithNull

var source = new TokenStoreTokenSource(tokenStore.Object);

var tokens = await source.GetTokensAsync();
var tokens = await source.GetTokensAsync(TestContext.Current.CancellationToken);

Assert.Empty(tokens);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<PackageTags>restclient rest http</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,7 +17,7 @@
<Reference Include="System.Threading.Tasks" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 6 additions & 0 deletions src/RestClient/RestClient/test/RestClientRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public async Task GetContent_StreamBody_ReturnsStreamContent()
var result = request.GetContent();

var streamContent = Assert.IsType<StreamContent>(result);
#pragma warning disable xUnit1051
var bytes = await streamContent.ReadAsByteArrayAsync();
#pragma warning restore xUnit1051
Assert.Equal(streamContent.Headers.ContentType, MediaTypeHeaderValue.Parse("application/octet-stream"));
Assert.Equal([1, 2, 3], bytes);
}
Expand All @@ -41,7 +43,9 @@ public async Task GetContent_StreamBodyContentType_ReturnsStreamContent()
var result = request.GetContent();

var streamContent = Assert.IsType<StreamContent>(result);
#pragma warning disable xUnit1051
var bytes = await streamContent.ReadAsByteArrayAsync();
#pragma warning restore xUnit1051
Assert.Equal(streamContent.Headers.ContentType, MediaTypeHeaderValue.Parse("application/test"));
Assert.Equal([1, 2, 3], bytes);
}
Expand All @@ -58,7 +62,9 @@ public async Task GetContent_ObjectBody_ReturnsStringContent()
var result = request.GetContent();

var streamContent = Assert.IsType<StringContent>(result);
#pragma warning disable xUnit1051
var resultString = await streamContent.ReadAsStringAsync();
#pragma warning restore xUnit1051

Assert.Equal("hello world", resultString);
Assert.Equal("application/test", streamContent.Headers.ContentType?.MediaType);
Expand Down
16 changes: 8 additions & 8 deletions src/RestClient/RestClient/test/RestClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task ExecuteAsync_UsesBaseAddress()
var client = new RestClient(new Uri("http://clickview.com.au"), new HttpClient(mockMessageHandler.Object));

// act
await client.ExecuteAsync(request);
await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

// assert
mockMessageHandler.Verify();
Expand Down Expand Up @@ -74,7 +74,7 @@ public async Task ExecuteAsync_UsesBaseAddressOverHttpClientBaseAddress()
});

// act
await client.ExecuteAsync(request);
await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

// assert
mockMessageHandler.Verify();
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task ExecuteAsync_UsesHttpClientBaseAddress()
});

// act
await client.ExecuteAsync(request);
await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

// assert
mockMessageHandler.Verify();
Expand Down Expand Up @@ -142,7 +142,7 @@ public async Task ExecuteAsync_AbsoluteUriRequest()
});

// act
await client.ExecuteAsync(request);
await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

// assert
mockMessageHandler.Verify();
Expand All @@ -159,7 +159,7 @@ public async Task ExecuteAsync_NoBaseAddress_ThrowsInvalidOperationException()
var client = new RestClient(new HttpClient(mockMessageHandler.Object));

// act/assert
await Assert.ThrowsAsync<InvalidOperationException>(() => client.ExecuteAsync(request));
await Assert.ThrowsAsync<InvalidOperationException>(() => client.ExecuteAsync(request, TestContext.Current.CancellationToken));
}

[Fact]
Expand All @@ -186,7 +186,7 @@ public async Task ExecuteAsync_AddBodyStream_MessageContentStreamContent()

request.AddBody(new MemoryStream());

var response = await client.ExecuteAsync(request);
var response = await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

mockMessageHandler.Verify();
Assert.Equal("test: success", response.Data);
Expand Down Expand Up @@ -231,7 +231,7 @@ public async Task ExecuteAsync_DefaultUserAgentSet_RequestContainsDefaultUserAge
DefaultUserAgent = "testapp/1.0.0 (rv:1; test; example/1.2.3)"
});

await client.ExecuteAsync(request);
await client.ExecuteAsync(request, TestContext.Current.CancellationToken);

mockMessageHandler.Verify();
Assert.Equal("testapp/1.0.0 (rv:1; test; example/1.2.3)", userAgentHeader);
Expand All @@ -244,4 +244,4 @@ protected override async ValueTask<RestClientResponse<string>> ParseResponseAsyn
return new RestClientResponse<string>(message, await message.Content.ReadAsStringAsync());
}
}
}
}
4 changes: 2 additions & 2 deletions src/RestClient/examples/ExampleClient/ErrorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class ErrorResponse
{
public string Message { get; set; }
}
public string? Message { get; set; }
}
10 changes: 5 additions & 5 deletions src/RestClient/examples/ExampleClient/ExampleApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public ExampleApiClient(Uri baseAddress, string authKey)
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
public async Task<UserModel> GetUserCustomRequestAsync(string username)
public async Task<UserModel?> GetUserCustomRequestAsync(string username)
{
var response = await _client.ExecuteAsync(new ExampleUserRequest(username)).ConfigureAwait(false);
var response = await _client.ExecuteAsync(new ExampleUserRequest(username));

return response.Data;
}

public async Task<UserModel> GetUserAsync(string username)
public async Task<UserModel?> GetUserAsync(string username)
{
var request = new RestClientRequest<UserModel>(HttpMethod.Get, "v1/users");

request.AddQueryParameter("username", username);

var response = await _client.ExecuteAsync(request).ConfigureAwait(false);
var response = await _client.ExecuteAsync(request);

return response.Data;
}
}
}
5 changes: 3 additions & 2 deletions src/RestClient/examples/ExampleClient/ExampleUserRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ExampleClient;

using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using ClickView.Extensions.RestClient;
Expand All @@ -26,7 +27,7 @@ protected override void HandleError(Error error)
base.HandleError(error);
}

protected override bool TryParseErrorBody(string content, out ErrorBody error)
protected override bool TryParseErrorBody(string content, [NotNullWhen(true)] out ErrorBody? error)
{
var errorResponse = Deserialize<ErrorResponse>(content);

Expand All @@ -43,4 +44,4 @@ protected override bool TryParseErrorBody(string content, out ErrorBody error)

return true;
}
}
}
4 changes: 2 additions & 2 deletions src/RestClient/examples/ExampleClient/UserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class UserModel
{
public string Username { get; set; }
}
public string? Username { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(FullTargetFrameworks)</TargetFrameworks>
<PackageTags>utilities</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading