Skip to content

Commit

Permalink
update xunit and fix compatibility issues in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed Jul 26, 2024
1 parent 276bb33 commit 844b3fe
Show file tree
Hide file tree
Showing 102 changed files with 888 additions and 617 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Condition=" '$(ReleasePackageVersion)' == '' " Version="$(LocalPackageVersion)" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Condition=" '$(ReleasePackageVersion)' != '' " Version="$(ReleasePackageVersion)" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Bot.Builder.Dialogs\Microsoft.Bot.Builder.Dialogs.csproj" />
Expand Down
15 changes: 13 additions & 2 deletions libraries/Microsoft.Bot.Streaming/Microsoft.Bot.Streaming.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<PackageId>Microsoft.Bot.Streaming</PackageId>
<Description>Streaming library for the Bot Framework SDK</Description>
<Summary>Streaming library for the Bot Framework SDK</Summary>
Expand All @@ -26,9 +26,20 @@
<NoWarn>$(NoWarn);</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task<ReceiveResponse> GetResponseAsync(Guid requestId, Cancellation
return null;
}

if (cancellationToken == null)
if (cancellationToken == default)
{
cancellationToken = CancellationToken.None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ConstructorShouldFailWithNullClient()
}

[Fact]
public async void ContinueConversationAsyncShouldSucceed()
public async Task ContinueConversationAsyncShouldSucceed()
{
var callbackInvoked = false;
var facebookAdapter = new FacebookAdapter(new FacebookClientWrapper(_testOptions), _adapterOptions);
Expand All @@ -50,7 +50,7 @@ Task BotsLogic(ITurnContext turnContext, CancellationToken cancellationToken)
}

[Fact]
public async void ContinueConversationAsyncShouldFailWithNullConversationReference()
public async Task ContinueConversationAsyncShouldFailWithNullConversationReference()
{
var facebookAdapter = new FacebookAdapter(new FacebookClientWrapper(_testOptions), _adapterOptions);
Task BotsLogic(ITurnContext turnContext, CancellationToken cancellationToken)
Expand All @@ -62,7 +62,7 @@ Task BotsLogic(ITurnContext turnContext, CancellationToken cancellationToken)
}

[Fact]
public async void ContinueConversationAsyncShouldFailWithNullLogic()
public async Task ContinueConversationAsyncShouldFailWithNullLogic()
{
var facebookAdapter = new FacebookAdapter(new FacebookClientWrapper(_testOptions), _adapterOptions);
var conversationReference = new ConversationReference();
Expand All @@ -83,7 +83,7 @@ public async Task DeleteActivityAsyncShouldThrowNotImplementedException()
}

[Fact]
public async void ProcessAsyncShouldSucceedWithCorrectData()
public async Task ProcessAsyncShouldSucceedWithCorrectData()
{
var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/Payload.json");
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand All @@ -102,7 +102,7 @@ public async void ProcessAsyncShouldSucceedWithCorrectData()
}

[Fact]
public async void ProcessAsyncShouldSucceedWithStandbyMessages()
public async Task ProcessAsyncShouldSucceedWithStandbyMessages()
{
var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/PayloadWithStandby.json");
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand All @@ -120,7 +120,7 @@ public async void ProcessAsyncShouldSucceedWithStandbyMessages()
}

[Fact]
public async void ProcessAsyncShouldSucceedWithReferralMessages()
public async Task ProcessAsyncShouldSucceedWithReferralMessages()
{
var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/PayloadWithReferral.json");
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand All @@ -138,7 +138,7 @@ public async void ProcessAsyncShouldSucceedWithReferralMessages()
}

[Fact]
public async void ProcessAsyncShouldVerifyWebhookOnHubModeSubscribe()
public async Task ProcessAsyncShouldVerifyWebhookOnHubModeSubscribe()
{
var testOptionsVerifyEnabled = new FacebookAdapterOptions()
{
Expand Down Expand Up @@ -190,7 +190,7 @@ public async Task ProcessAsyncShouldThrowExceptionWithUnverifiedSignature()
}

[Fact]
public async void SendActivitiesAsyncShouldSucceedWithActivityTypeMessage()
public async Task SendActivitiesAsyncShouldSucceedWithActivityTypeMessage()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down Expand Up @@ -219,7 +219,7 @@ public async void SendActivitiesAsyncShouldSucceedWithActivityTypeMessage()
}

[Fact]
public async void SendActivitiesAsyncShouldSucceedWithActivityTypeMessageAndAttachments()
public async Task SendActivitiesAsyncShouldSucceedWithActivityTypeMessageAndAttachments()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down Expand Up @@ -251,7 +251,7 @@ public async void SendActivitiesAsyncShouldSucceedWithActivityTypeMessageAndAtta
}

[Fact]
public async void SendActivitiesAsyncShouldSucceedAndNoActivityReturnedWithActivityTypeNotMessage()
public async Task SendActivitiesAsyncShouldSucceedAndNoActivityReturnedWithActivityTypeNotMessage()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down Expand Up @@ -283,7 +283,7 @@ public async void SendActivitiesAsyncShouldSucceedAndNoActivityReturnedWithActiv
}

[Fact]
public async void SendActivitiesAsyncShouldPostToFacebookOnPassThreadControl()
public async Task SendActivitiesAsyncShouldPostToFacebookOnPassThreadControl()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down Expand Up @@ -315,7 +315,7 @@ public async void SendActivitiesAsyncShouldPostToFacebookOnPassThreadControl()
}

[Fact]
public async void SendActivitiesAsyncShouldPostToFacebookOnTakeThreadControl()
public async Task SendActivitiesAsyncShouldPostToFacebookOnTakeThreadControl()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down Expand Up @@ -347,7 +347,7 @@ public async void SendActivitiesAsyncShouldPostToFacebookOnTakeThreadControl()
}

[Fact]
public async void SendActivitiesAsyncShouldPostToFacebookOnRequestThreadControl()
public async Task SendActivitiesAsyncShouldPostToFacebookOnRequestThreadControl()
{
const string testResponse = "Test Response";
var facebookClientWrapper = new Mock<FacebookClientWrapper>(_testOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Newtonsoft.Json;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void VerifySignatureShouldReturnFalseWithInvalidRequestHash()
}

[Fact]
public async void SendMessageAsyncShouldThrowAnExceptionWithWrongPath()
public async Task SendMessageAsyncShouldThrowAnExceptionWithWrongPath()
{
var facebookMessageJson = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/FacebookMessages.json");
var facebookMessage = JsonConvert.DeserializeObject<List<FacebookMessage>>(facebookMessageJson)[5];
Expand All @@ -77,7 +78,7 @@ await Assert.ThrowsAsync<HttpRequestException>(async () =>
}

[Fact]
public async void SendMessageAsyncShouldThrowAnExceptionWithNullPath()
public async Task SendMessageAsyncShouldThrowAnExceptionWithNullPath()
{
var facebookMessageJson = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/FacebookMessages.json");
var facebookMessage = JsonConvert.DeserializeObject<List<FacebookMessage>>(facebookMessageJson)[5];
Expand All @@ -90,7 +91,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(async () =>
}

[Fact]
public async void SendMessageAsyncShouldThrowAnExceptionWithNullPayload()
public async Task SendMessageAsyncShouldThrowAnExceptionWithNullPayload()
{
var facebookWrapper = new FacebookClientWrapper(_testOptions);

Expand All @@ -101,7 +102,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(async () =>
}

[Fact]
public async void VerifyWebhookAsyncShouldSendOkWhenVerified()
public async Task VerifyWebhookAsyncShouldSendOkWhenVerified()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);
var httpRequest = new Mock<HttpRequest>();
Expand All @@ -124,7 +125,7 @@ public async void VerifyWebhookAsyncShouldSendOkWhenVerified()
}

[Fact]
public async void VerifyWebhookAsyncShouldSendUnauthorizedWhenNotVerified()
public async Task VerifyWebhookAsyncShouldSendUnauthorizedWhenNotVerified()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);
var httpRequest = new Mock<HttpRequest>();
Expand All @@ -147,7 +148,7 @@ public async void VerifyWebhookAsyncShouldSendUnauthorizedWhenNotVerified()
}

[Fact]
public async void VerifyWebhookAsyncShouldThrowExceptionWithNullRequest()
public async Task VerifyWebhookAsyncShouldThrowExceptionWithNullRequest()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);
var httpResponse = new Mock<HttpResponse>();
Expand All @@ -156,7 +157,7 @@ public async void VerifyWebhookAsyncShouldThrowExceptionWithNullRequest()
}

[Fact]
public async void VerifyWebhookAsyncShouldThrowExceptionWithNullResponse()
public async Task VerifyWebhookAsyncShouldThrowExceptionWithNullResponse()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);
var httpRequest = new Mock<HttpRequest>();
Expand All @@ -165,47 +166,47 @@ public async void VerifyWebhookAsyncShouldThrowExceptionWithNullResponse()
}

[Fact]
public async void PassThreadControlAsyncShouldThrowExceptionWithNullTargetAppId()
public async Task PassThreadControlAsyncShouldThrowExceptionWithNullTargetAppId()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

await Assert.ThrowsAsync<ArgumentNullException>(async () => { await facebookClientWrapper.PassThreadControlAsync(null, "fakeUserId", "Test Pass Thread Control", default); });
}

[Fact]
public async void PassThreadControlAsyncShouldThrowExceptionWithNullUserId()
public async Task PassThreadControlAsyncShouldThrowExceptionWithNullUserId()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

await Assert.ThrowsAsync<ArgumentNullException>(async () => { await facebookClientWrapper.PassThreadControlAsync("fakeAppId", null, "Test Pass Thread Control", default); });
}

[Fact]
public async void RequestThreadControlAsyncShouldThrowExceptionWithNullUserId()
public async Task RequestThreadControlAsyncShouldThrowExceptionWithNullUserId()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

await Assert.ThrowsAsync<ArgumentNullException>(async () => { await facebookClientWrapper.RequestThreadControlAsync(null, "Test Pass Thread Control", default); });
}

[Fact]
public async void TakeThreadControlAsyncShouldThrowExceptionWithNullUserId()
public async Task TakeThreadControlAsyncShouldThrowExceptionWithNullUserId()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

await Assert.ThrowsAsync<ArgumentNullException>(async () => { await facebookClientWrapper.TakeThreadControlAsync(null, "Test Pass Thread Control", default); });
}

[Fact]
public async void PostToFacebookApiAsyncShouldThrowExceptionWithNullPostType()
public async Task PostToFacebookApiAsyncShouldThrowExceptionWithNullPostType()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

await Assert.ThrowsAsync<ArgumentNullException>(async () => { await facebookClientWrapper.PostToFacebookApiAsync(null, "fakeContent", default); });
}

[Fact]
public async void PostToFacebookApiAsyncShouldThrowExceptionWithNullContent()
public async Task PostToFacebookApiAsyncShouldThrowExceptionWithNullContent()
{
var facebookClientWrapper = new FacebookClientWrapper(_testOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<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 @@ -20,7 +20,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<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 @@ -405,7 +405,7 @@ Task BotsLogic(ITurnContext turnContext, CancellationToken cancellationToken)
}

[Fact]
public async void ProcessAsyncShouldFailWithNullHttpRequest()
public async Task ProcessAsyncShouldFailWithNullHttpRequest()
{
var slackApi = new Mock<SlackClientWrapper>(_testOptions);
slackApi.Setup(x => x.TestAuthAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult("mockedUserId"));
Expand All @@ -421,7 +421,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(async () =>
}

[Fact]
public async void ProcessAsyncShouldFailWithNullHttpResponse()
public async Task ProcessAsyncShouldFailWithNullHttpResponse()
{
var slackApi = new Mock<SlackClientWrapper>(_testOptions);
slackApi.Setup(x => x.TestAuthAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult("mockedUserId"));
Expand All @@ -437,7 +437,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(async () =>
}

[Fact]
public async void ProcessAsyncShouldFailWithNullBot()
public async Task ProcessAsyncShouldFailWithNullBot()
{
var slackApi = new Mock<SlackClientWrapper>(_testOptions);
slackApi.Setup(x => x.TestAuthAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult("mockedUserId"));
Expand Down Expand Up @@ -543,7 +543,7 @@ public async Task ProcessAsyncShouldSucceedWithUnknownEventType()

await slackAdapter.ProcessAsync(httpRequest.Object, httpResponse.Object, new Mock<IBot>().Object, default);

Assert.Equal(httpResponse.Object.StatusCode, (int)HttpStatusCode.OK);
Assert.Equal((int)HttpStatusCode.OK, httpResponse.Object.StatusCode);
}

[Fact]
Expand All @@ -559,7 +559,7 @@ public async Task ProcessAsyncShouldSucceedWithReactionAddedEventType()

await slackAdapter.ProcessAsync(httpRequest.Object, httpResponse.Object, new Mock<IBot>().Object, default);

Assert.Equal(httpResponse.Object.StatusCode, (int)HttpStatusCode.OK);
Assert.Equal((int)HttpStatusCode.OK, httpResponse.Object.StatusCode);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading

0 comments on commit 844b3fe

Please sign in to comment.