-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement GetBroadcasts * Fix merge conflicts * Fix merge conflicts * Fill Xml Documentation on Broadcast * Implement StartBroadcastRequest * Implement StartBroadcast * Implement GetBroadcast * Implement StopBroadcast * Implement AddStreamToBroadcast * Implement AddStreamToBroadcast http content and serialization * Implement RemoveStreamFromBroadcast * Implement ChangeBroadcastLayout * Use enums for BroadcastStatus and RtmpStatus * Use Guids on most identifiers * Remove unnecessary using * Add missing XmlDocumentation * Rename ArchiveLayout to Layout, given it's not specific to Archive anymore * Convert Layout to a record * Replace structs by records * Apply PR suggestions * Fix broadcast layout creation
- Loading branch information
Showing
82 changed files
with
3,712 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
using FluentAssertions; | ||
using Vonage.Common.Failures; | ||
using Vonage.Common.Test.Extensions; | ||
|
||
namespace Vonage.Common.Test.Failures | ||
{ | ||
public class ResultFailureTest | ||
{ | ||
[Fact] | ||
public void FromError_ShouldReturnFailure() => | ||
public void FromErrorMessage_ShouldReturnFailure() => | ||
ResultFailure.FromErrorMessage("Some error.").GetFailureMessage().Should().Be("Some error."); | ||
|
||
[Fact] | ||
public void ToResult_ShouldReturnFailure() => | ||
ResultFailure.ToResult<int>("Some error.").Should() | ||
.BeFailure(failure => failure.GetFailureMessage().Should().Be("Some error.")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
namespace Vonage.Common.Failures; | ||
using Vonage.Common.Monads; | ||
|
||
namespace Vonage.Common.Failures; | ||
|
||
/// <inheritdoc /> | ||
public readonly struct ResultFailure : IResultFailure | ||
{ | ||
private ResultFailure(string error) => this.error = error; | ||
private readonly string error; | ||
private ResultFailure(string error) => this.error = error; | ||
|
||
/// <summary> | ||
/// Create a failure from an error message. | ||
/// Creates a failure from an error message. | ||
/// </summary> | ||
/// <param name="error">The error message.</param> | ||
/// <returns>The failure.</returns> | ||
public static ResultFailure FromErrorMessage(string error) => new(error); | ||
|
||
/// <inheritdoc /> | ||
public string GetFailureMessage() => this.error; | ||
|
||
/// <summary> | ||
/// Creates a result failure from an error message. | ||
/// </summary> | ||
/// <param name="error">The error message.</param> | ||
/// <typeparam name="T">Type of the result.</typeparam> | ||
/// <returns>The result.</returns> | ||
public static Result<T> ToResult<T>(string error) => Result<T>.FromFailure(FromErrorMessage(error)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Vonage.Server.Test/Video/Archives/CreateArchive/CreateArchiveDeserializationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Vonage.Server.Test/Video/Archives/GetArchive/GetArchiveDeserializationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Vonage.Server.Test/Video/Archives/GetArchives/GetArchivesDeserializationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Vonage.Server.Test/Video/Archives/StopArchive/StopArchiveDeserializationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...erver.Test/Video/Broadcast/AddStreamToBroadcast/AddStreamToBroadcastRequestBuilderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using AutoFixture; | ||
using FluentAssertions; | ||
using Vonage.Common.Failures; | ||
using Vonage.Common.Test.Extensions; | ||
using Vonage.Server.Video.Broadcast.AddStreamToBroadcast; | ||
using Xunit; | ||
|
||
namespace Vonage.Server.Test.Video.Broadcast.AddStreamToBroadcast | ||
{ | ||
public class AddStreamToBroadcastRequestBuilderTest | ||
{ | ||
private readonly Guid applicationId; | ||
private readonly Guid streamId; | ||
private readonly Guid broadcastId; | ||
|
||
public AddStreamToBroadcastRequestBuilderTest() | ||
{ | ||
var fixture = new Fixture(); | ||
this.applicationId = fixture.Create<Guid>(); | ||
this.broadcastId = fixture.Create<Guid>(); | ||
this.streamId = fixture.Create<Guid>(); | ||
} | ||
|
||
[Fact] | ||
public void Build_ShouldDisableAudio_GivenWithDisabledAudioIsUsed() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(this.streamId) | ||
.WithDisabledAudio() | ||
.Create() | ||
.Map(request => request.HasAudio) | ||
.Should() | ||
.BeSuccess(false); | ||
|
||
[Fact] | ||
public void Build_ShouldDisableVideo_GivenWithDisabledVideoIsUsed() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(this.streamId) | ||
.WithDisabledVideo() | ||
.Create() | ||
.Map(request => request.HasVideo) | ||
.Should() | ||
.BeSuccess(false); | ||
|
||
[Fact] | ||
public void Build_ShouldReturnFailure_GivenApplicationIdIsEmpty() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(Guid.Empty) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(this.streamId) | ||
.Create() | ||
.Should() | ||
.BeFailure(ResultFailure.FromErrorMessage("ApplicationId cannot be empty.")); | ||
|
||
[Fact] | ||
public void Build_ShouldReturnFailure_GivenBroadcastIdIsEmpty() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(Guid.Empty) | ||
.WithStreamId(this.streamId) | ||
.Create() | ||
.Should() | ||
.BeFailure(ResultFailure.FromErrorMessage("BroadcastId cannot be empty.")); | ||
|
||
[Fact] | ||
public void Build_ShouldReturnFailure_GivenStreamIdIsEmpty() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(Guid.Empty) | ||
.Create() | ||
.Should() | ||
.BeFailure(ResultFailure.FromErrorMessage("StreamId cannot be empty.")); | ||
|
||
[Fact] | ||
public void Build_ShouldReturnSuccess_WithMandatoryValues() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(this.streamId) | ||
.Create() | ||
.Should() | ||
.BeSuccess(success => | ||
{ | ||
success.ApplicationId.Should().Be(this.applicationId); | ||
success.BroadcastId.Should().Be(this.broadcastId); | ||
success.StreamId.Should().Be(this.streamId); | ||
success.HasAudio.Should().BeTrue(); | ||
success.HasVideo.Should().BeTrue(); | ||
}); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Vonage.Server.Test/Video/Broadcast/AddStreamToBroadcast/AddStreamToBroadcastRequestTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using AutoFixture; | ||
using Vonage.Common.Test.Extensions; | ||
using Vonage.Server.Video.Broadcast.AddStreamToBroadcast; | ||
using Xunit; | ||
|
||
namespace Vonage.Server.Test.Video.Broadcast.AddStreamToBroadcast | ||
{ | ||
public class AddStreamToBroadcastRequestTest | ||
{ | ||
private readonly Guid applicationId; | ||
private readonly Guid streamId; | ||
private readonly Guid broadcastId; | ||
|
||
public AddStreamToBroadcastRequestTest() | ||
{ | ||
var fixture = new Fixture(); | ||
this.applicationId = fixture.Create<Guid>(); | ||
this.broadcastId = fixture.Create<Guid>(); | ||
this.streamId = fixture.Create<Guid>(); | ||
} | ||
|
||
[Fact] | ||
public void GetEndpointPath_ShouldReturnApiEndpoint_WithDefaultOffsetAndCount() => | ||
AddStreamToBroadcastRequestBuilder.Build() | ||
.WithApplicationId(this.applicationId) | ||
.WithBroadcastId(this.broadcastId) | ||
.WithStreamId(this.streamId) | ||
.Create() | ||
.Map(request => request.GetEndpointPath()) | ||
.Should() | ||
.BeSuccess($"/v2/project/{this.applicationId}/broadcast/{this.broadcastId}/streams"); | ||
} | ||
} |
Oops, something went wrong.