Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: video e2e refactoring #477

Merged
merged 11 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Vonage.Common.Test.Extensions;
using Vonage.Server.Video.Moderation.DisconnectConnection;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Server.Test.Video.Moderation.DisconnectConnection
{
[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
public E2ETest() : base(typeof(E2ETest).Namespace)
{
}

[Fact]
public async Task DisconnectConnection()
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath(
"/v2/project/5e782e3b-9f63-426f-bd2e-b7d618d546cd/session/flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN/connection/97425ae1-4722-4dbf-b395-6169f08ebab3")
.WithHeader("Authorization", "Bearer *")
.UsingDelete())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK));
await this.Helper.VonageClient.ModerationClient.DisconnectConnectionAsync(DisconnectConnectionRequest
.Build()
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.WithConnectionId("97425ae1-4722-4dbf-b395-6169f08ebab3")
.Create())
.Should()
.BeSuccessAsync();
}
}
}

This file was deleted.

37 changes: 37 additions & 0 deletions Vonage.Server.Test/Video/Moderation/MuteStream/EETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Vonage.Common.Test.Extensions;
using Vonage.Server.Video.Moderation.MuteStream;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Server.Test.Video.Moderation.MuteStream
{
[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
public E2ETest() : base(typeof(E2ETest).Namespace)
{
}

[Fact]
public async Task MuteStream()
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath(
"/v2/project/5e782e3b-9f63-426f-bd2e-b7d618d546cd/session/flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN/stream/97425ae1-4722-4dbf-b395-6169f08ebab3/mute")
.WithHeader("Authorization", "Bearer *")
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.ModerationClient.MuteStreamAsync(MuteStreamRequest.Build()
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.WithStreamId("97425ae1-4722-4dbf-b395-6169f08ebab3")
.Create())
.Should()
.BeSuccessAsync(SerializationTest.VerifyResponse);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public SerializationTest()
public void ShouldDeserialize200() =>
this.helper.Serializer.DeserializeObject<MuteStreamResponse>(this.helper.GetResponseJson())
.Should()
.BeSuccess(success =>
{
success.ApplicationId.Should().Be("78d335fa-323d-0114-9c3d-d6f0d48968cf");
success.Status.Should().Be("ACTIVE");
success.Name.Should().Be("Joe Montana");
success.Environment.Should().Be("standard");
success.CreatedAt.Should().Be(1414642898000);
});
.BeSuccess(VerifyResponse);

internal static void VerifyResponse(MuteStreamResponse success)
{
success.ApplicationId.Should().Be("78d335fa-323d-0114-9c3d-d6f0d48968cf");
success.Status.Should().Be("ACTIVE");
success.Name.Should().Be("Joe Montana");
success.Environment.Should().Be("standard");
success.CreatedAt.Should().Be(1414642898000);
}
}
}
69 changes: 0 additions & 69 deletions Vonage.Server.Test/Video/Moderation/MuteStream/UseCaseTest.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"active": true,
"excludedStreamIds": [
"excludedStream1",
"excludedStream2"
]
}
39 changes: 39 additions & 0 deletions Vonage.Server.Test/Video/Moderation/MuteStreams/E2ETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Vonage.Common.Test.Extensions;
using Vonage.Server.Video.Moderation.MuteStreams;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Server.Test.Video.Moderation.MuteStreams
{
[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
public E2ETest() : base(typeof(E2ETest).Namespace)
{
}

[Fact]
public async Task MuteStreams()
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath(
"/v2/project/5e782e3b-9f63-426f-bd2e-b7d618d546cd/session/flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN/mute")
.WithHeader("Authorization", "Bearer *")
.WithBody(this.Serialization.GetRequestJson(nameof(SerializationTest.ShouldSerialize)))
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.ModerationClient.MuteStreamsAsync(MuteStreamsRequest.Build()
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.WithConfiguration(new MuteStreamsRequest.MuteStreamsConfiguration(true,
new[] {"excludedStream1", "excludedStream2"}))
.Create())
.Should()
.BeSuccessAsync(SerializationTest.VerifyResponse);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using AutoFixture;
using FluentAssertions;
using Vonage.Common.Test.Extensions;
using Vonage.Server.Video.Moderation.MuteStreams;
using Xunit;

namespace Vonage.Server.Test.Video.Moderation.MuteStreams
{
public class RequestBuilderTest
{
private readonly Fixture fixture;
private readonly Guid applicationId;
private readonly MuteStreamsRequest.MuteStreamsConfiguration configuration;
private readonly string sessionId;

public RequestBuilderTest()
{
this.fixture = new Fixture();
this.applicationId = this.fixture.Create<Guid>();
this.sessionId = this.fixture.Create<string>();
this.configuration = this.fixture.Create<MuteStreamsRequest.MuteStreamsConfiguration>();
}

[Fact]
public void Build_ShouldReturnFailure_GivenApplicationIdIsNullOrWhitespace() =>
MuteStreamsRequest.Build()
.WithApplicationId(Guid.Empty)
.WithSessionId(this.sessionId)
.WithConfiguration(this.configuration)
.Create()
.Should()
.BeParsingFailure("ApplicationId cannot be empty.");

[Fact]
public void Build_ShouldReturnFailure_GivenExcludedStreamsIdsAreNull() =>
MuteStreamsRequest.Build()
.WithApplicationId(this.applicationId)
.WithSessionId(this.sessionId)
.WithConfiguration(new MuteStreamsRequest.MuteStreamsConfiguration(this.fixture.Create<bool>(), null))
.Create()
.Should()
.BeParsingFailure("ExcludedStreamIds cannot be null.");

[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData(null)]
public void Build_ShouldReturnFailure_GivenSessionIdIsNullOrWhitespace(string value) =>
MuteStreamsRequest.Build()
.WithApplicationId(this.applicationId)
.WithSessionId(value)
.WithConfiguration(this.configuration)
.Create()
.Should()
.BeParsingFailure("SessionId cannot be null or whitespace.");

[Fact]
public void Build_ShouldReturnSuccess_GivenValuesAreProvided() =>
MuteStreamsRequest.Build()
.WithApplicationId(this.applicationId)
.WithSessionId(this.sessionId)
.WithConfiguration(this.configuration)
.Create()
.Should()
.BeSuccess(request =>
{
request.ApplicationId.Should().Be(this.applicationId);
request.SessionId.Should().Be(this.sessionId);
request.Configuration.Active.Should().Be(this.configuration.Active);
request.Configuration.ExcludedStreamIds.Should()
.BeEquivalentTo(this.configuration.ExcludedStreamIds);
});
}
}
Loading
Loading