From c35a299eeb0fb87fc5bae99421be541ad8dd2b82 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Sat, 18 Jan 2025 16:55:09 -0600 Subject: [PATCH] Migrated Dapr.AspNetCore.IntegrationTest Signed-off-by: Whit Waldo --- .../AuthenticationTest.cs | 6 +-- .../CloudEventsIntegrationTest.cs | 11 ++-- .../ControllerIntegrationTest.cs | 16 +++--- .../Dapr.AspNetCore.IntegrationTest.csproj | 2 +- .../RoutingIntegrationTest.cs | 4 +- .../SubscribeEndpointTest.cs | 52 +++++++++---------- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/test/Dapr.AspNetCore.IntegrationTest/AuthenticationTest.cs b/test/Dapr.AspNetCore.IntegrationTest/AuthenticationTest.cs index 2712779e7..3684e709c 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/AuthenticationTest.cs +++ b/test/Dapr.AspNetCore.IntegrationTest/AuthenticationTest.cs @@ -16,7 +16,7 @@ using System.Text; using System.Threading.Tasks; using Dapr.AspNetCore.IntegrationTest.App; -using FluentAssertions; +using Shouldly; using Newtonsoft.Json; using Xunit; @@ -43,7 +43,7 @@ public async Task ValidToken_ShouldBeAuthenticatedAndAuthorized() response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync(); var responseUserInfo = JsonConvert.DeserializeObject(responseContent); - responseUserInfo.Name.Should().Be(userInfo.Name); + responseUserInfo.Name.ShouldBe(userInfo.Name); } } @@ -64,7 +64,7 @@ public async Task InvalidToken_ShouldBeUnauthorized() request.Headers.Add("Dapr-Api-Token", "asdfgh"); var response = await httpClient.SendAsync(request); - response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); + response.StatusCode.ShouldBe(HttpStatusCode.Unauthorized); } } } diff --git a/test/Dapr.AspNetCore.IntegrationTest/CloudEventsIntegrationTest.cs b/test/Dapr.AspNetCore.IntegrationTest/CloudEventsIntegrationTest.cs index 9b0b5d3a3..928286fb6 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/CloudEventsIntegrationTest.cs +++ b/test/Dapr.AspNetCore.IntegrationTest/CloudEventsIntegrationTest.cs @@ -19,7 +19,7 @@ namespace Dapr.AspNetCore.IntegrationTest using System.Text.Json; using System.Threading.Tasks; using Dapr.AspNetCore.IntegrationTest.App; - using FluentAssertions; + using Shouldly; using Xunit; public class CloudEventsIntegrationTest @@ -48,6 +48,7 @@ public async Task CanSendEmptyStructuredCloudEvent() } } + [Fact] public async Task CanSendStructuredCloudEvent() { @@ -74,7 +75,7 @@ public async Task CanSendStructuredCloudEvent() response.EnsureSuccessStatusCode(); var userInfo = await JsonSerializer.DeserializeAsync(await response.Content.ReadAsStreamAsync(), this.options); - userInfo.Name.Should().Be("jimmy"); + userInfo.Name.ShouldBe("jimmy"); } } @@ -105,7 +106,7 @@ public async Task CanSendStructuredCloudEvent_WithContentType() response.EnsureSuccessStatusCode(); var userInfo = await JsonSerializer.DeserializeAsync(await response.Content.ReadAsStreamAsync(), this.options); - userInfo.Name.Should().Be("jimmy"); + userInfo.Name.ShouldBe("jimmy"); } } @@ -133,7 +134,7 @@ public async Task CanSendStructuredCloudEvent_WithNonJsonContentType() response.EnsureSuccessStatusCode(); var user = await response.Content.ReadAsStringAsync(); - user.Should().Be("jimmy \"the cool guy\" smith"); + user.ShouldBe("jimmy \"the cool guy\" smith"); } } @@ -163,7 +164,7 @@ public async Task CanSendBinaryCloudEvent_WithContentType() response.EnsureSuccessStatusCode(); var userInfo = await JsonSerializer.DeserializeAsync(await response.Content.ReadAsStreamAsync(), this.options); - userInfo.Name.Should().Be("jimmy"); + userInfo.Name.ShouldBe("jimmy"); } } } diff --git a/test/Dapr.AspNetCore.IntegrationTest/ControllerIntegrationTest.cs b/test/Dapr.AspNetCore.IntegrationTest/ControllerIntegrationTest.cs index 7735ec4fb..d3eb87cd6 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/ControllerIntegrationTest.cs +++ b/test/Dapr.AspNetCore.IntegrationTest/ControllerIntegrationTest.cs @@ -16,7 +16,7 @@ namespace Dapr.AspNetCore.IntegrationTest using System.Net.Http; using System.Threading.Tasks; using Dapr.AspNetCore.IntegrationTest.App; - using FluentAssertions; + using Shouldly; using Newtonsoft.Json; using Xunit; @@ -37,7 +37,7 @@ public async Task ModelBinder_CanBindFromState() response.EnsureSuccessStatusCode(); var widget = await daprClient.GetStateAsync("testStore", "test"); - widget.Count.Should().Be(18); + widget.Count.ShouldBe(18); } } @@ -56,8 +56,8 @@ public async Task ModelBinder_GetFromStateEntryWithKeyPresentInStateStore_Return response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync(); var responseWidget = JsonConvert.DeserializeObject(responseContent); - responseWidget.Size.Should().Be(widget.Size); - responseWidget.Count.Should().Be(widget.Count); + responseWidget.Size.ShouldBe(widget.Size); + responseWidget.Count.ShouldBe(widget.Count); } } @@ -92,7 +92,7 @@ public async Task ModelBinder_CanBindFromState_WithStateEntry() response.EnsureSuccessStatusCode(); var widget = await daprClient.GetStateAsync("testStore", "test"); - widget.Count.Should().Be(18); + widget.Count.ShouldBe(18); } } @@ -111,7 +111,7 @@ public async Task ModelBinder_CanBindFromState_WithStateEntryAndCustomKey() response.EnsureSuccessStatusCode(); var widget = await daprClient.GetStateAsync("testStore", "test"); - widget.Count.Should().Be(18); + widget.Count.ShouldBe(18); } } @@ -130,8 +130,8 @@ public async Task ModelBinder_GetFromStateEntryWithStateEntry_WithKeyPresentInSt response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync(); var responseWidget = JsonConvert.DeserializeObject(responseContent); - responseWidget.Size.Should().Be(widget.Size); - responseWidget.Count.Should().Be(widget.Count); + responseWidget.Size.ShouldBe(widget.Size); + responseWidget.Count.ShouldBe(widget.Count); } } diff --git a/test/Dapr.AspNetCore.IntegrationTest/Dapr.AspNetCore.IntegrationTest.csproj b/test/Dapr.AspNetCore.IntegrationTest/Dapr.AspNetCore.IntegrationTest.csproj index d7dd6d52a..5772612b4 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/Dapr.AspNetCore.IntegrationTest.csproj +++ b/test/Dapr.AspNetCore.IntegrationTest/Dapr.AspNetCore.IntegrationTest.csproj @@ -5,7 +5,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/test/Dapr.AspNetCore.IntegrationTest/RoutingIntegrationTest.cs b/test/Dapr.AspNetCore.IntegrationTest/RoutingIntegrationTest.cs index c3129df9d..89130c3bd 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/RoutingIntegrationTest.cs +++ b/test/Dapr.AspNetCore.IntegrationTest/RoutingIntegrationTest.cs @@ -16,7 +16,7 @@ namespace Dapr.AspNetCore.IntegrationTest using System.Net.Http; using System.Threading.Tasks; using Dapr.AspNetCore.IntegrationTest.App; - using FluentAssertions; + using Shouldly; using Xunit; public class RoutingIntegrationTest @@ -36,7 +36,7 @@ public async Task StateClient_CanBindFromState() response.EnsureSuccessStatusCode(); var widget = await daprClient.GetStateAsync("testStore", "test"); - widget.Count.Should().Be(18); + widget.Count.ShouldBe(18); } } } diff --git a/test/Dapr.AspNetCore.IntegrationTest/SubscribeEndpointTest.cs b/test/Dapr.AspNetCore.IntegrationTest/SubscribeEndpointTest.cs index 4cd0d4f1e..7354f6aa6 100644 --- a/test/Dapr.AspNetCore.IntegrationTest/SubscribeEndpointTest.cs +++ b/test/Dapr.AspNetCore.IntegrationTest/SubscribeEndpointTest.cs @@ -19,7 +19,7 @@ namespace Dapr.AspNetCore.IntegrationTest using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; - using FluentAssertions; + using Shouldly; using Xunit; public class SubscribeEndpointTest @@ -39,8 +39,8 @@ public async Task SubscribeEndpoint_ReportsTopics() { var json = await JsonSerializer.DeserializeAsync(stream); - json.ValueKind.Should().Be(JsonValueKind.Array); - json.GetArrayLength().Should().Be(18); + json.ValueKind.ShouldBe(JsonValueKind.Array); + json.GetArrayLength().ShouldBe(18); var subscriptions = new List<(string PubsubName, string Topic, string Route, string rawPayload, string match, string metadata, string DeadLetterTopic, string bulkSubscribeMetadata)>(); @@ -109,34 +109,34 @@ public async Task SubscribeEndpoint_ReportsTopics() } } - subscriptions.Should().Contain(("testpubsub", "A", "topic-a", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("testpubsub", "A.1", "topic-a", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "B", "B", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("custom-pubsub", "custom-C", "C", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "register-user", "register-user", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "register-user-plaintext", "register-user-plaintext", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "D", "D", "true", string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "E", "E", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "E", "E-Critical", string.Empty, "event.type == \"critical\"", string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "E", "E-Important", string.Empty, "event.type == \"important\"", string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "F", "multiTopicAttr", string.Empty, string.Empty, string.Empty, string.Empty, + subscriptions.ShouldContain(("testpubsub", "A", "topic-a", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("testpubsub", "A.1", "topic-a", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "B", "B", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("custom-pubsub", "custom-C", "C", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "register-user", "register-user", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "register-user-plaintext", "register-user-plaintext", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "D", "D", "true", string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "E", "E", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "E", "E-Critical", string.Empty, "event.type == \"critical\"", string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "E", "E-Important", string.Empty, "event.type == \"important\"", string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "F", "multiTopicAttr", string.Empty, string.Empty, string.Empty, string.Empty, "{\"enabled\":true,\"maxMessagesCount\":100,\"maxAwaitDurationMs\":1000}")); - subscriptions.Should().Contain(("pubsub", "F.1", "multiTopicAttr", "true", string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "G", "G", string.Empty, string.Empty, string.Empty, "deadLetterTopicName", + subscriptions.ShouldContain(("pubsub", "F.1", "multiTopicAttr", "true", string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "G", "G", string.Empty, string.Empty, string.Empty, "deadLetterTopicName", "{\"enabled\":true,\"maxMessagesCount\":300,\"maxAwaitDurationMs\":1000}")); - subscriptions.Should().Contain(("pubsub", "splitTopicBuilder", "splitTopics", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "splitTopicAttr", "splitTopics", "true", string.Empty, string.Empty, string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "metadata", "multiMetadataTopicAttr", string.Empty, string.Empty, "n1=v1;n2=v2,v3", string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "metadata.1", "multiMetadataTopicAttr", "true", string.Empty, "n1=v1", string.Empty, + subscriptions.ShouldContain(("pubsub", "splitTopicBuilder", "splitTopics", string.Empty, string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "splitTopicAttr", "splitTopics", "true", string.Empty, string.Empty, string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "metadata", "multiMetadataTopicAttr", string.Empty, string.Empty, "n1=v1;n2=v2,v3", string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "metadata.1", "multiMetadataTopicAttr", "true", string.Empty, "n1=v1", string.Empty, "{\"enabled\":true,\"maxMessagesCount\":500,\"maxAwaitDurationMs\":2000}")); - subscriptions.Should().Contain(("pubsub", "splitMetadataTopicBuilder", "splitMetadataTopics", string.Empty, string.Empty, "n1=v1;n2=v1", string.Empty, String.Empty)); - subscriptions.Should().Contain(("pubsub", "metadataseparatorbyemptytring", "topicmetadataseparatorattrbyemptytring", string.Empty, string.Empty, "n1=v1,", string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "splitMetadataTopicBuilder", "splitMetadataTopics", string.Empty, string.Empty, "n1=v1;n2=v1", string.Empty, String.Empty)); + subscriptions.ShouldContain(("pubsub", "metadataseparatorbyemptytring", "topicmetadataseparatorattrbyemptytring", string.Empty, string.Empty, "n1=v1,", string.Empty, String.Empty)); // Test priority route sorting var eTopic = subscriptions.FindAll(e => e.Topic == "E"); - eTopic.Count.Should().Be(3); - eTopic[0].Route.Should().Be("E-Critical"); - eTopic[1].Route.Should().Be("E-Important"); - eTopic[2].Route.Should().Be("E"); + eTopic.Count.ShouldBe(3); + eTopic[0].Route.ShouldBe("E-Critical"); + eTopic[1].Route.ShouldBe("E-Important"); + eTopic[2].Route.ShouldBe("E"); } } }