mirror of https://github.com/dapr/dotnet-sdk.git
Moved to xunit for testing (#127)
* Updated Dapr.AspNetCore.IntegrationTest * Updated Dapr.AspNetCore.Test * Updated Dapr.Client.Test * Updated to latest packages
This commit is contained in:
parent
eba332e911
commit
07fa2c615d
|
@ -6,7 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.23.2" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.24.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.9.2" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.10.0" />
|
||||
<PackageReference Include="Grpc" Version="2.24.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -12,9 +12,8 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
using System.Threading.Tasks;
|
||||
using Dapr.AspNetCore.IntegrationTest.App;
|
||||
using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class CloudEventsIntegrationTest
|
||||
{
|
||||
private readonly JsonSerializerOptions options = new JsonSerializerOptions()
|
||||
|
@ -23,7 +22,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
PropertyNameCaseInsensitive = true,
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task CanSendEmptyStructuredCloudEvent()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -39,7 +38,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task CanSendStructuredCloudEvent()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -67,7 +66,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task CanSendStructuredCloudEvent_WithContentType()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -99,7 +98,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
// Yeah, I know, binary isn't a great term for this, it's what the cloudevents spec uses.
|
||||
// Basically this is here to test that an endpoint can handle requests with and without
|
||||
// an envelope.
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task CanSendBinaryCloudEvent_WithContentType()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -124,4 +123,4 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,11 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
using System.Threading.Tasks;
|
||||
using Dapr.AspNetCore.IntegrationTest.App;
|
||||
using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class ControllerIntegrationTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task ModelBinder_CanBindFromState()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -33,7 +32,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task ModelBinder_CanBindFromState_WithStateEntry()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -52,7 +51,7 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task ModelBinder_CanBindFromState_WithStateEntryAndCustomKey()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -71,4 +70,4 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -9,12 +9,11 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
using System.Threading.Tasks;
|
||||
using Dapr.AspNetCore.IntegrationTest.App;
|
||||
using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class RoutingIntegrationTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task StateClient_CanBindFromState()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -33,4 +32,4 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,11 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class SubscribeEndpointTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task SubscribeEndpoint_ReportsTopics()
|
||||
{
|
||||
using (var factory = new AppWebApplicationFactory())
|
||||
|
@ -45,4 +44,4 @@ namespace Dapr.AspNetCore.IntegrationTest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,16 @@ namespace Dapr.AspNetCore.Test
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class CloudEventsMiddlewareTest
|
||||
{
|
||||
[DataTestMethod]
|
||||
[DataRow("text/plain")]
|
||||
[DataRow("application/json")] // "binary" format
|
||||
[DataRow("application/cloudevents")] // no format
|
||||
[DataRow("application/cloudevents+xml")] // wrong format
|
||||
[DataRow("application/cloudevents-batch+json")] // we don't support batch
|
||||
[Theory]
|
||||
[InlineData("text/plain")]
|
||||
[InlineData("application/json")] // "binary" format
|
||||
[InlineData("application/cloudevents")] // no format
|
||||
[InlineData("application/cloudevents+xml")] // wrong format
|
||||
[InlineData("application/cloudevents-batch+json")] // we don't support batch
|
||||
public async Task InvokeAsync_IgnoresOtherContentTypes(string contentType)
|
||||
{
|
||||
var app = new ApplicationBuilder(null);
|
||||
|
@ -45,12 +44,12 @@ namespace Dapr.AspNetCore.Test
|
|||
await pipeline.Invoke(context);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(null, null)] // assumes application/json + utf8
|
||||
[DataRow("application/json", null)] // assumes utf8
|
||||
[DataRow("application/json", "utf-8")]
|
||||
[DataRow("application/json", "UTF-8")]
|
||||
[DataRow("application/person+json", "UTF-16")] // arbitrary content type and charset
|
||||
[Theory]
|
||||
[InlineData(null, null)] // assumes application/json + utf8
|
||||
[InlineData("application/json", null)] // assumes utf8
|
||||
[InlineData("application/json", "utf-8")]
|
||||
[InlineData("application/json", "UTF-8")]
|
||||
[InlineData("application/person+json", "UTF-16")] // arbitrary content type and charset
|
||||
public async Task InvokeAsync_ReplacesBodyJson(string dataContentType, string charSet)
|
||||
{
|
||||
var encoding = charSet == null ? null : Encoding.GetEncoding(charSet);
|
||||
|
@ -78,7 +77,7 @@ namespace Dapr.AspNetCore.Test
|
|||
|
||||
// This is a special case. S.T.Json will always output utf8, so we have to reinterpret the charset
|
||||
// of the datacontenttype.
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task InvokeAsync_ReplacesBodyJson_NormalizesPayloadCharset()
|
||||
{
|
||||
var dataContentType = "application/person+json;charset=UTF-16";
|
||||
|
@ -124,4 +123,4 @@ namespace Dapr.AspNetCore.Test
|
|||
return encoding.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -14,12 +14,11 @@ namespace Dapr.AspNetCore.Test
|
|||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class StateEntryModelBinderTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task BindAsync_WithoutMatchingRouteValue_ReportsError()
|
||||
{
|
||||
var binder = new StateEntryModelBinder("test", isStateEntry: false, typeof(Widget));
|
||||
|
@ -35,7 +34,7 @@ namespace Dapr.AspNetCore.Test
|
|||
httpClient.Requests.Count.Should().Be(0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task BindAsync_CanBindValue()
|
||||
{
|
||||
var binder = new StateEntryModelBinder("id", isStateEntry: false, typeof(Widget));
|
||||
|
@ -58,7 +57,7 @@ namespace Dapr.AspNetCore.Test
|
|||
context.ValidationState[context.Result.Model].SuppressValidation.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task BindAsync_CanBindStateEntry()
|
||||
{
|
||||
var binder = new StateEntryModelBinder("id", isStateEntry: true, typeof(Widget));
|
||||
|
@ -113,4 +112,4 @@ namespace Dapr.AspNetCore.Test
|
|||
public string Color { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -10,12 +10,11 @@ namespace Dapr.Client.Test
|
|||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
[TestClass]
|
||||
public class StateHttpClientTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateAsync_CanReadState()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -33,7 +32,7 @@ namespace Dapr.Client.Test
|
|||
state.Color.Should().Be("yellow");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateAsync_CanReadEmptyState_ReturnsDefault()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -50,7 +49,7 @@ namespace Dapr.Client.Test
|
|||
state.Should().BeNull();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateAsync_ThrowsForNonSuccess()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -66,7 +65,7 @@ namespace Dapr.Client.Test
|
|||
await FluentActions.Awaiting(async () => await task).Should().ThrowAsync<HttpRequestException>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task SaveStateAsync_CanSaveState()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -94,7 +93,7 @@ namespace Dapr.Client.Test
|
|||
await task;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task SaveStateAsync_CanClearState()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -119,7 +118,7 @@ namespace Dapr.Client.Test
|
|||
await task;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task SetStateAsync_ThrowsForNonSuccess()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -136,7 +135,7 @@ namespace Dapr.Client.Test
|
|||
await FluentActions.Awaiting(async () => await task).Should().ThrowAsync<HttpRequestException>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateEntryAsync_CanReadState()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -155,7 +154,7 @@ namespace Dapr.Client.Test
|
|||
state.Value.Color.Should().Be("yellow");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateEntryAsync_CanReadEmptyState_ReturnsDefault()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -173,7 +172,7 @@ namespace Dapr.Client.Test
|
|||
state.Value.Should().BeNull();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task GetStateEntryAsync_CanSaveState()
|
||||
{
|
||||
var httpClient = new TestHttpClient();
|
||||
|
@ -230,4 +229,4 @@ namespace Dapr.Client.Test
|
|||
public string Color { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue