Skip to content

Commit

Permalink
refactor: extract serialization test for ExperienceComposer Session
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Jun 25, 2024
1 parent 5b91318 commit c989a09
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "1248e7070b81464c9789f46ad10e7764",
"sessionId": "flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN",
"applicationId": "93e36bb9-b72c-45b6-a9ea-5c37dbc49906",
"createdAt": 1437676551000,
"callbackUrl": "https://example.com/video/events",
"updatedAt": 1437676551000,
"name": "Composed stream for Live event #1",
"url": "https://example.com/",
"resolution": "720x1280",
"status": "failed",
"streamId": "e32445b743678c98230f238",
"reason": "Could not load URL"
}
4 changes: 2 additions & 2 deletions Vonage.Test/Video/ExperienceComposer/GetSession/E2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public async Task GetSession()
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue)
.UsingGet())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
.WithBody(this.Serialization.GetResponseJson(nameof(SessionSerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.VideoClient.ExperienceComposerClient
.GetSessionAsync(GetSessionRequest.Parse(new Guid("e3e78a75-221d-41ec-8846-25ae3db1943a"), "EXP-123"))
.Should()
.BeSuccessAsync(SerializationTest.BuildExpectedSession());
.BeSuccessAsync(SessionSerializationTest.BuildExpectedSession());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
using Vonage.Video.ExperienceComposer;
using Xunit;

namespace Vonage.Test.Video.ExperienceComposer.GetSession;
namespace Vonage.Test.Video.ExperienceComposer;

[Trait("Category", "Serialization")]
public class SerializationTest
public class SessionSerializationTest
{
private readonly SerializationTestHelper helper = new SerializationTestHelper(
typeof(SerializationTest).Namespace,
typeof(SessionSerializationTest).Namespace,
JsonSerializerBuilder.BuildWithCamelCase());

[Fact]
Expand Down
21 changes: 0 additions & 21 deletions Vonage.Test/Video/ExperienceComposer/Start/SerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Vonage.Server;
using Vonage.Test.Common;
using Vonage.Test.Common.Extensions;
using Vonage.Video.ExperienceComposer;
using Vonage.Video.ExperienceComposer.Start;
using Xunit;

Expand All @@ -16,12 +15,6 @@ public class SerializationTest
typeof(SerializationTest).Namespace,
JsonSerializerBuilder.BuildWithCamelCase());

[Fact]
public void ShouldDeserialize200() => this.helper.Serializer
.DeserializeObject<Session>(this.helper.GetResponseJson())
.Should()
.BeSuccess(BuildExpectedSession());

[Fact]
public void ShouldSerialize() => StartRequest
.Build()
Expand All @@ -36,18 +29,4 @@ public class SerializationTest
.GetStringContent()
.Should()
.BeSuccess(this.helper.GetRequestJson());

internal static Session BuildExpectedSession() =>
new Session("1248e7070b81464c9789f46ad10e7764",
"flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN",
new Guid("93e36bb9-b72c-45b6-a9ea-5c37dbc49906"),
1437676551000,
new Uri("https://example.com/video/events"),
1437676551000,
"Composed stream for Live event #1",
new Uri("https://example.com/"),
RenderResolution.HighDefinitionPortrait,
SessionStatus.Failed,
"e32445b743678c98230f238",
"Could not load URL");
}
3 changes: 3 additions & 0 deletions Vonage.Test/Vonage.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,9 @@
<None Update="Video\ExperienceComposer\Start\Data\ShouldSerialize-request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Video\ExperienceComposer\Data\ShouldDeserialize200-response.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="node ../.scripts/init.js"/>
Expand Down

0 comments on commit c989a09

Please sign in to comment.