diff --git a/Vonage.Server.Test/Video/Broadcast/StartBroadcast/E2ETest.cs b/Vonage.Server.Test/Video/Broadcast/StartBroadcast/E2ETest.cs index 24bd449d6..7215f81e7 100644 --- a/Vonage.Server.Test/Video/Broadcast/StartBroadcast/E2ETest.cs +++ b/Vonage.Server.Test/Video/Broadcast/StartBroadcast/E2ETest.cs @@ -48,7 +48,7 @@ await this.Helper.VonageClient.BroadcastClient.StartBroadcastsAsync(StartBroadca .WithMultiBroadcastTag("foo") .Create()) .Should() - .BeSuccessAsync(); + .BeSuccessAsync(SerializationTest.VerifyBroadcast); } [Fact] @@ -78,7 +78,7 @@ await this.Helper.VonageClient.BroadcastClient.StartBroadcastsAsync(StartBroadca }) .Create()) .Should() - .BeSuccessAsync(); + .BeSuccessAsync(SerializationTest.VerifyBroadcast); } } } \ No newline at end of file diff --git a/Vonage.Server.Test/Video/Broadcast/StopBroadcast/E2ETest.cs b/Vonage.Server.Test/Video/Broadcast/StopBroadcast/E2ETest.cs new file mode 100644 index 000000000..506c641a3 --- /dev/null +++ b/Vonage.Server.Test/Video/Broadcast/StopBroadcast/E2ETest.cs @@ -0,0 +1,37 @@ +using System; +using System.Net; +using System.Threading.Tasks; +using Vonage.Common.Test.Extensions; +using Vonage.Server.Video.Broadcast.StopBroadcast; +using WireMock.ResponseBuilders; +using Xunit; + +namespace Vonage.Server.Test.Video.Broadcast.StopBroadcast +{ + [Trait("Category", "E2E")] + public class E2ETest : E2EBase + { + public E2ETest() : base(typeof(E2ETest).Namespace) + { + } + + [Fact] + public async Task StopBroadcast() + { + this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() + .WithPath( + "/v2/project/5e782e3b-9f63-426f-bd2e-b7d618d546cd/broadcast/97425ae1-4722-4dbf-b395-6169f08ebab3/stop") + .WithHeader("Authorization", "Bearer *") + .UsingPost()) + .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) + .WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); + await this.Helper.VonageClient.BroadcastClient.StopBroadcastAsync(StopBroadcastRequest + .Build() + .WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd")) + .WithBroadcastId(Guid.Parse("97425ae1-4722-4dbf-b395-6169f08ebab3")) + .Create()) + .Should() + .BeSuccessAsync(SerializationTest.VerifyBroadcast); + } + } +} \ No newline at end of file diff --git a/Vonage.Server.Test/Video/Broadcast/StopBroadcast/SerializationTest.cs b/Vonage.Server.Test/Video/Broadcast/StopBroadcast/SerializationTest.cs index e5bd90b35..8716094b3 100644 --- a/Vonage.Server.Test/Video/Broadcast/StopBroadcast/SerializationTest.cs +++ b/Vonage.Server.Test/Video/Broadcast/StopBroadcast/SerializationTest.cs @@ -20,35 +20,37 @@ public void ShouldDeserialize200() => this.helper.Serializer .DeserializeObject(this.helper.GetResponseJson()) .Should() - .BeSuccess(success => - { - success.Id.Should().Be(new Guid("6c2bc486-0f4c-49cd-877c-7b609ec5dd19")); - success.SessionId.Should().Be("2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ-TjMzfn4"); - success.MultiBroadcastTag.Should().Be("broadcast_tag_provided"); - success.ApplicationId.Should().Be(new Guid("af4cba75-3e4b-48d2-806b-7b9aecef7988")); - success.CreatedAt.Should().Be(1676124372); - success.UpdatedAt.Should().Be(1676624372); - success.MaxDuration.Should().Be(5400); - success.MaxBitrate.Should().Be(2000000); - success.Resolution.Should().Be("640x480"); - success.HasAudio.Should().Be(true); - success.HasVideo.Should().Be(true); - success.StreamMode.Should().Be("manual"); - success.Status.Should().Be(Server.Video.Broadcast.Broadcast.BroadcastStatus.Started); - success.BroadcastUrls.Hls.Should() - .Be(new Uri("http://server/fakepath/playlist.m3u8")); - success.BroadcastUrls.Rtmp.Should().HaveCount(1); - success.BroadcastUrls.Rtmp[0].Id.Should().Be(new Guid("432c916e-22fb-492e-b45b-b96ef3b90297")); - success.BroadcastUrls.Rtmp[0].Status.Should() - .Be(Server.Video.Broadcast.Broadcast.RtmpStatus.Live); - success.BroadcastUrls.Rtmp[0].StreamName.Should().Be("myfooapp"); - success.BroadcastUrls.Rtmp[0].ServerUrl.Should().Be("rtmps://myfooserver/myfooapp"); - success.Settings.Hls.Dvr.Should().BeTrue(); - success.Settings.Hls.LowLatency.Should().BeTrue(); - success.Streams.Should().HaveCount(1); - success.Streams[0].StreamId.Should().Be(new Guid("cbad214d-4712-40dd-88fd-82412bf66dd5")); - success.Streams[0].HasVideo.Should().BeTrue(); - success.Streams[0].HasAudio.Should().BeTrue(); - }); + .BeSuccess(VerifyBroadcast); + + internal static void VerifyBroadcast(Server.Video.Broadcast.Broadcast success) + { + success.Id.Should().Be(new Guid("6c2bc486-0f4c-49cd-877c-7b609ec5dd19")); + success.SessionId.Should().Be("2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ-TjMzfn4"); + success.MultiBroadcastTag.Should().Be("broadcast_tag_provided"); + success.ApplicationId.Should().Be(new Guid("af4cba75-3e4b-48d2-806b-7b9aecef7988")); + success.CreatedAt.Should().Be(1676124372); + success.UpdatedAt.Should().Be(1676624372); + success.MaxDuration.Should().Be(5400); + success.MaxBitrate.Should().Be(2000000); + success.Resolution.Should().Be("640x480"); + success.HasAudio.Should().Be(true); + success.HasVideo.Should().Be(true); + success.StreamMode.Should().Be("manual"); + success.Status.Should().Be(Server.Video.Broadcast.Broadcast.BroadcastStatus.Started); + success.BroadcastUrls.Hls.Should() + .Be(new Uri("http://server/fakepath/playlist.m3u8")); + success.BroadcastUrls.Rtmp.Should().HaveCount(1); + success.BroadcastUrls.Rtmp[0].Id.Should().Be(new Guid("432c916e-22fb-492e-b45b-b96ef3b90297")); + success.BroadcastUrls.Rtmp[0].Status.Should() + .Be(Server.Video.Broadcast.Broadcast.RtmpStatus.Live); + success.BroadcastUrls.Rtmp[0].StreamName.Should().Be("myfooapp"); + success.BroadcastUrls.Rtmp[0].ServerUrl.Should().Be("rtmps://myfooserver/myfooapp"); + success.Settings.Hls.Dvr.Should().BeTrue(); + success.Settings.Hls.LowLatency.Should().BeTrue(); + success.Streams.Should().HaveCount(1); + success.Streams[0].StreamId.Should().Be(new Guid("cbad214d-4712-40dd-88fd-82412bf66dd5")); + success.Streams[0].HasVideo.Should().BeTrue(); + success.Streams[0].HasAudio.Should().BeTrue(); + } } } \ No newline at end of file diff --git a/Vonage.Server.Test/Video/Broadcast/StopBroadcast/UseCaseTest.cs b/Vonage.Server.Test/Video/Broadcast/StopBroadcast/UseCaseTest.cs deleted file mode 100644 index 46e1db761..000000000 --- a/Vonage.Server.Test/Video/Broadcast/StopBroadcast/UseCaseTest.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using AutoFixture; -using AutoFixture.Kernel; -using FsCheck; -using FsCheck.Xunit; -using Vonage.Common.Client; -using Vonage.Common.Monads; -using Vonage.Common.Test; -using Vonage.Common.Test.TestHelpers; -using Vonage.Server.Video.Broadcast; -using Vonage.Server.Video.Broadcast.StopBroadcast; -using Xunit; - -namespace Vonage.Server.Test.Video.Broadcast.StopBroadcast -{ - public class UseCaseTest : BaseUseCase, IUseCaseWithResponse - { - private Func>> Operation => - configuration => new BroadcastClient(configuration).StopBroadcastAsync(this.request); - - private readonly Result request; - - public UseCaseTest() => this.request = BuildRequest(this.Helper.Fixture); - - [Property] - public Property ShouldReturnFailure_GivenApiErrorCannotBeParsed() => - this.Helper.VerifyReturnsFailureGivenErrorCannotBeParsed(this.BuildExpectedRequest(), this.Operation); - - [Fact] - public async Task ShouldReturnFailure_GivenApiResponseCannotBeParsed() => - await this.Helper.VerifyReturnsFailureGivenApiResponseCannotBeParsed(this.BuildExpectedRequest(), - this.Operation); - - [Property] - public Property ShouldReturnFailure_GivenApiResponseIsError() => - this.Helper.VerifyReturnsFailureGivenApiResponseIsError(this.BuildExpectedRequest(), this.Operation); - - [Fact] - public async Task ShouldReturnFailure_GivenRequestIsFailure() => - await this.Helper - .VerifyReturnsFailureGivenRequestIsFailure( - (configuration, failureRequest) => - new BroadcastClient(configuration).StopBroadcastAsync(failureRequest)); - - [Fact] - public async Task ShouldReturnFailure_GivenTokenGenerationFailed() => - await this.Helper.VerifyReturnsFailureGivenTokenGenerationFails(this.Operation); - - [Fact] - public async Task ShouldReturnSuccess_GivenApiResponseIsSuccess() => - await this.Helper.VerifyReturnsExpectedValueGivenApiResponseIsSuccess(this.BuildExpectedRequest(), - this.Operation); - - private ExpectedRequest BuildExpectedRequest() => - new ExpectedRequest - { - Method = HttpMethod.Post, - RequestUri = new Uri(UseCaseHelper.GetPathFromRequest(this.request), UriKind.Relative), - }; - - private static Result BuildRequest(ISpecimenBuilder fixture) => - StopBroadcastRequest.Build().WithApplicationId(fixture.Create()) - .WithBroadcastId(fixture.Create()).Create(); - } -} \ No newline at end of file