Skip to content

Commit

Permalink
feat: finalize E2E flow for GetEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Jun 12, 2024
1 parent 3b23c7c commit d969926
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
31 changes: 31 additions & 0 deletions Vonage.Test/Conversations/GetEvent/E2ETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Net;
using System.Threading.Tasks;
using Vonage.Conversations.GetEvent;
using Vonage.Test.Common.Extensions;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Test.Conversations.GetEvent;

[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
public E2ETest() : base(typeof(E2ETest).Namespace)
{
}

[Fact]
public async Task GetEvent()
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath("/v1/conversations/CON-123/events/EVE-123")
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue)
.UsingGet())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.ConversationsClient
.GetEventAsync(GetEventRequest.Parse("CON-123", "EVE-123"))
.Should()
.BeSuccessAsync(SerializationTest.VerifyExpectedResponse);
}
}
34 changes: 18 additions & 16 deletions Vonage.Test/Conversations/GetEvent/SerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ public class SerializationTest
public void ShouldDeserialize200() => this.helper.Serializer
.DeserializeObject<Event>(this.helper.GetResponseJson())
.Should()
.BeSuccess(success =>
{
success.Id.Should().Be(100);
success.Type.Should().Be("message");
success.From.Should().Be("string");
success.Body.Should().Be(JsonSerializer.SerializeToElement(new {message_type = "text", text = "string"}));
success.Embedded.Member.Should().Be(new EmbeddedEventMember("string"));
success.Embedded.User.Id.Should().Be("USR-82e028d9-5201-4f1e-8188-604b2d3471ec");
success.Embedded.User.Name.Should().Be("my_user_name");
success.Embedded.User.DisplayName.Should().Be("My User Name");
success.Embedded.User.ImageUrl.Should().Be("https://example.com/image.png");
success.Embedded.User.CustomData.Should()
.Be(JsonSerializer.SerializeToElement(new {field_1 = "value_1", field_2 = "value_2"}));
success.Links.Should()
.Be(new Links(new HalLink(new Uri("https://api.nexmo.com/v0.1/conversations/CON-1234/events/100"))));
});
.BeSuccess(VerifyExpectedResponse);

internal static void VerifyExpectedResponse(Event success)
{
success.Id.Should().Be(100);
success.Type.Should().Be("message");
success.From.Should().Be("string");
success.Body.Should().Be(JsonSerializer.SerializeToElement(new {message_type = "text", text = "string"}));
success.Embedded.Member.Should().Be(new EmbeddedEventMember("string"));
success.Embedded.User.Id.Should().Be("USR-82e028d9-5201-4f1e-8188-604b2d3471ec");
success.Embedded.User.Name.Should().Be("my_user_name");
success.Embedded.User.DisplayName.Should().Be("My User Name");
success.Embedded.User.ImageUrl.Should().Be("https://example.com/image.png");
success.Embedded.User.CustomData.Should()
.Be(JsonSerializer.SerializeToElement(new {field_1 = "value_1", field_2 = "value_2"}));
success.Links.Should()
.Be(new Links(new HalLink(new Uri("https://api.nexmo.com/v0.1/conversations/CON-1234/events/100"))));
}
}

0 comments on commit d969926

Please sign in to comment.