diff --git a/test/Dapr.AspNetCore.Test/CloudEventsMiddlewareTest.cs b/test/Dapr.AspNetCore.Test/CloudEventsMiddlewareTest.cs
index 2f9fab936..5a1133964 100644
--- a/test/Dapr.AspNetCore.Test/CloudEventsMiddlewareTest.cs
+++ b/test/Dapr.AspNetCore.Test/CloudEventsMiddlewareTest.cs
@@ -20,7 +20,7 @@ namespace Dapr.AspNetCore.Test
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
- using FluentAssertions;
+ using Shouldly;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Xunit;
@@ -44,8 +44,8 @@ public async Task InvokeAsync_IgnoresOtherContentTypes(string contentType)
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(contentType);
- ReadBody(httpContext.Request.Body).Should().Be("Hello, world!");
+ httpContext.Request.ContentType.ShouldBe(contentType);
+ ReadBody(httpContext.Request.Body).ShouldBe("Hello, world!");
return Task.CompletedTask;
});
@@ -77,8 +77,8 @@ public async Task InvokeAsync_ReplacesBodyJson(string dataContentType, string ch
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType ?? "application/json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe(dataContentType ?? "application/json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
return Task.CompletedTask;
});
@@ -117,8 +117,8 @@ public async Task InvokeAsync_ReplacesPascalCasedBodyJson(string dataContentType
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType ?? "application/json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe(dataContentType ?? "application/json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
return Task.CompletedTask;
});
@@ -160,11 +160,13 @@ public async Task InvokeAsync_ForwardsJsonPropertiesAsHeaders(string dataContent
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType ?? "application/json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe(dataContentType ?? "application/json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
- httpContext.Request.Headers.Should().ContainKey("Cloudevent.type").WhichValue.Should().BeEquivalentTo("Test.Type");
- httpContext.Request.Headers.Should().ContainKey("Cloudevent.subject").WhichValue.Should().BeEquivalentTo("Test.Subject");
+ httpContext.Request.Headers.ShouldContainKey("Cloudevent.type");
+ httpContext.Request.Headers["Cloudevent.type"].ShouldBeEquivalentTo("Test.Type");
+ httpContext.Request.Headers.ShouldContainKey("Cloudevent.subject");
+ httpContext.Request.Headers["Cloudevent.subject"].ShouldBeEquivalentTo("Test.Subject");
return Task.CompletedTask;
});
@@ -207,11 +209,12 @@ public async Task InvokeAsync_ForwardsIncludedJsonPropertiesAsHeaders(string dat
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType ?? "application/json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe(dataContentType ?? "application/json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
- httpContext.Request.Headers.Should().ContainKey("Cloudevent.type").WhichValue.Should().BeEquivalentTo("Test.Type");
- httpContext.Request.Headers.Should().NotContainKey("Cloudevent.subject");
+ httpContext.Request.Headers.ShouldContainKey("Cloudevent.type");
+ httpContext.Request.Headers["Cloudevent.type"].ShouldBeEquivalentTo("Test.Type");
+ httpContext.Request.Headers.ShouldNotContainKey("Cloudevent.subject");
return Task.CompletedTask;
});
@@ -254,11 +257,12 @@ public async Task InvokeAsync_DoesNotForwardExcludedJsonPropertiesAsHeaders(stri
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType ?? "application/json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe(dataContentType ?? "application/json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
- httpContext.Request.Headers.Should().NotContainKey("Cloudevent.type");
- httpContext.Request.Headers.Should().ContainKey("Cloudevent.subject").WhichValue.Should().BeEquivalentTo("Test.Subject");
+ httpContext.Request.Headers.ShouldNotContainKey("Cloudevent.type");
+ httpContext.Request.Headers.ShouldContainKey("Cloudevent.subject");
+ httpContext.Request.Headers["Cloudevent.subject"].ShouldBeEquivalentTo("Test.Subject");
return Task.CompletedTask;
});
@@ -297,8 +301,8 @@ public async Task InvokeAsync_ReplacesBodyNonJsonData()
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be("text/plain");
- ReadBody(httpContext.Request.Body).Should().Be(expected);
+ httpContext.Request.ContentType.ShouldBe("text/plain");
+ ReadBody(httpContext.Request.Body).ShouldBe(expected);
return Task.CompletedTask;
});
@@ -331,8 +335,8 @@ public async Task InvokeAsync_ReplacesBodyNonJsonData_ExceptWhenSuppressed()
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be("text/plain");
- ReadBody(httpContext.Request.Body).Should().Be(expected);
+ httpContext.Request.ContentType.ShouldBe("text/plain");
+ ReadBody(httpContext.Request.Body).ShouldBe(expected);
return Task.CompletedTask;
});
@@ -366,8 +370,8 @@ public async Task InvokeAsync_ReplacesBodyJson_NormalizesPayloadCharset()
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be("application/person+json");
- ReadBody(httpContext.Request.Body).Should().Be("{\"name\":\"jimmy\"}");
+ httpContext.Request.ContentType.ShouldBe("application/person+json");
+ ReadBody(httpContext.Request.Body).ShouldBe("{\"name\":\"jimmy\"}");
return Task.CompletedTask;
});
@@ -396,14 +400,14 @@ public async Task InvokeAsync_ReadsBinaryData()
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be(dataContentType);
+ httpContext.Request.ContentType.ShouldBe(dataContentType);
var bytes = new byte[httpContext.Request.Body.Length];
#if NET9_0
httpContext.Request.Body.ReadExactly(bytes, 0, bytes.Length);
#else
httpContext.Request.Body.Read(bytes, 0, bytes.Length);
#endif
- bytes.Should().Equal(data);
+ bytes.ShouldBe(data);
return Task.CompletedTask;
});
@@ -432,9 +436,9 @@ public async Task InvokeAsync_DataAndData64Set_ReturnsBadRequest()
// Do verification in the scope of the middleware
app.Run(httpContext =>
{
- httpContext.Request.ContentType.Should().Be("application/json");
+ httpContext.Request.ContentType.ShouldBe("application/json");
var body = ReadBody(httpContext.Request.Body);
- body.Should().Equals(data);
+ body.ShouldBe(data);
return Task.CompletedTask;
});
@@ -447,7 +451,7 @@ public async Task InvokeAsync_DataAndData64Set_ReturnsBadRequest()
MakeBody($"{{ \"datacontenttype\": \"{dataContentType}\", \"data_base64\": \"{base64Str}\", \"data\": {data} }}");
await pipeline.Invoke(context);
- context.Response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
+ context.Response.StatusCode.ShouldBe((int)HttpStatusCode.BadRequest);
}
private static Stream MakeBody(string text, Encoding encoding = null)
diff --git a/test/Dapr.AspNetCore.Test/Dapr.AspNetCore.Test.csproj b/test/Dapr.AspNetCore.Test/Dapr.AspNetCore.Test.csproj
index 9135e63d4..b25fcec6e 100644
--- a/test/Dapr.AspNetCore.Test/Dapr.AspNetCore.Test.csproj
+++ b/test/Dapr.AspNetCore.Test/Dapr.AspNetCore.Test.csproj
@@ -5,8 +5,8 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
all
diff --git a/test/Dapr.AspNetCore.Test/StateEntryApplicationModelProviderTest.cs b/test/Dapr.AspNetCore.Test/StateEntryApplicationModelProviderTest.cs
index 06572caa5..243b60bb6 100644
--- a/test/Dapr.AspNetCore.Test/StateEntryApplicationModelProviderTest.cs
+++ b/test/Dapr.AspNetCore.Test/StateEntryApplicationModelProviderTest.cs
@@ -18,7 +18,7 @@ namespace Dapr.AspNetCore.Test
using System.Linq;
using System.Reflection;
using Dapr.AspNetCore.Resources;
- using FluentAssertions;
+ using Shouldly;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.ModelBinding;
@@ -34,9 +34,7 @@ public void OnProvidersExecuted_NullActionsBindingSource()
Action action = () => provider.OnProvidersExecuted(context);
- action
- .Should()
- .NotThrow();
+ action.ShouldNotThrow();
}
[Fact]
@@ -48,8 +46,7 @@ public void OnProvidersExecuted_StateEntryParameterThrows()
Action action = () => provider.OnProvidersExecuted(context);
action
- .Should()
- .Throw(SR.ErrorStateStoreNameNotProvidedForStateEntry);
+ .ShouldThrow(SR.ErrorStateStoreNameNotProvidedForStateEntry);
}
private ApplicationModelProviderContext CreateContext(string methodName)
diff --git a/test/Dapr.AspNetCore.Test/StateEntryModelBinderTest.cs b/test/Dapr.AspNetCore.Test/StateEntryModelBinderTest.cs
index e2d774397..8cdcd32dd 100644
--- a/test/Dapr.AspNetCore.Test/StateEntryModelBinderTest.cs
+++ b/test/Dapr.AspNetCore.Test/StateEntryModelBinderTest.cs
@@ -18,7 +18,7 @@ namespace Dapr.AspNetCore.Test
using System.Threading.Tasks;
using Dapr.Client;
using Dapr.Client.Autogen.Grpc.v1;
- using FluentAssertions;
+ using Shouldly;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
@@ -38,9 +38,9 @@ public async Task BindAsync_WithoutMatchingRouteValue_ReportsError()
await binder.BindModelAsync(context);
- context.Result.IsModelSet.Should().BeFalse();
- context.ModelState.ErrorCount.Should().Be(1);
- context.ModelState["testParameter"].Errors.Count.Should().Be(1);
+ context.Result.IsModelSet.ShouldBeFalse();
+ context.ModelState.ErrorCount.ShouldBe(1);
+ context.ModelState["testParameter"].Errors.Count.ShouldBe(1);
// No request to state store, validated by disposing client
}
@@ -66,12 +66,12 @@ public async Task BindAsync_CanBindValue()
await SendResponseWithState(state, request);
// Get response and validate
- context.Result.IsModelSet.Should().BeTrue();
- context.Result.Model.As().Size.Should().Be("small");
- context.Result.Model.As().Color.Should().Be("yellow");
+ context.Result.IsModelSet.ShouldBeTrue();
+ ((Widget)context.Result.Model).Size.ShouldBe("small");
+ ((Widget)context.Result.Model).Color.ShouldBe("yellow");
- context.ValidationState.Count.Should().Be(1);
- context.ValidationState[context.Result.Model].SuppressValidation.Should().BeTrue();
+ context.ValidationState.Count.ShouldBe(1);
+ context.ValidationState[context.Result.Model].SuppressValidation.ShouldBeTrue();
}
[Fact]
@@ -95,13 +95,13 @@ public async Task BindAsync_CanBindStateEntry()
await SendResponseWithState(state, request);
// Get response and validate
- context.Result.IsModelSet.Should().BeTrue();
- context.Result.Model.As>().Key.Should().Be("test");
- context.Result.Model.As>().Value.Size.Should().Be("small");
- context.Result.Model.As>().Value.Color.Should().Be("yellow");
+ context.Result.IsModelSet.ShouldBeTrue();
+ ((StateEntry)context.Result.Model).Key.ShouldBe("test");
+ ((StateEntry)context.Result.Model).Value.Size.ShouldBe("small");
+ ((StateEntry)context.Result.Model).Value.Color.ShouldBe("yellow");
- context.ValidationState.Count.Should().Be(1);
- context.ValidationState[context.Result.Model].SuppressValidation.Should().BeTrue();
+ context.ValidationState.Count.ShouldBe(1);
+ context.ValidationState[context.Result.Model].SuppressValidation.ShouldBeTrue();
}
[Fact]
@@ -122,9 +122,9 @@ public async Task BindAsync_ReturnsNullForNonExistentStateEntry()
await SendResponseWithState(null, request);
- context.ModelState.IsValid.Should().BeTrue();
- context.Result.IsModelSet.Should().BeFalse();
- context.Result.Should().Be(ModelBindingResult.Failed());
+ context.ModelState.IsValid.ShouldBeTrue();
+ context.Result.IsModelSet.ShouldBeFalse();
+ context.Result.ShouldBe(ModelBindingResult.Failed());
}
[Fact]
@@ -145,9 +145,9 @@ public async Task BindAsync_WithStateEntry_ForNonExistentStateEntry()
await SendResponseWithState(null, request);
- context.ModelState.IsValid.Should().BeTrue();
- context.Result.IsModelSet.Should().BeTrue();
- ((StateEntry)context.Result.Model).Value.Should().BeNull();
+ context.ModelState.IsValid.ShouldBeTrue();
+ context.Result.IsModelSet.ShouldBeTrue();
+ ((StateEntry)context.Result.Model).Value.ShouldBeNull();
}
private static ModelBindingContext CreateContext(IServiceProvider services)