Skip to content

Commit

Permalink
Merge pull request #507 from henrikfroehling/issue/release-1.4.0/GH-469
Browse files Browse the repository at this point in the history
Resolves GH-469
  • Loading branch information
henrikfroehling authored May 29, 2023
2 parents 350b8ae + 87aa94b commit eff7c60
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source/Lib/Trakt.NET/Enums/TraktCommentSortOrder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TraktNet.Enums
{
/// <summary>Determines the sort order for comments lists.</summary>
/// <summary>Determines the sort order for comments.</summary>
public sealed class TraktCommentSortOrder : TraktEnumeration
{
/// <summary>An invalid sort order.</summary>
Expand Down
42 changes: 42 additions & 0 deletions Source/Lib/Trakt.NET/Enums/TraktExtendedCommentSortOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace TraktNet.Enums
{
/// <summary>Determines the sort order for comments.</summary>
public sealed class TraktExtendedCommentSortOrder : TraktEnumeration
{
/// <summary>An invalid sort order.</summary>
public static TraktExtendedCommentSortOrder Unspecified { get; } = new TraktExtendedCommentSortOrder();

/// <summary>Comments will be sorted by newest comments first.</summary>
public static TraktExtendedCommentSortOrder Newest { get; } = new TraktExtendedCommentSortOrder(1, "newest", "newest", "Newest");

/// <summary>Comments will be sorted by oldest comments first.</summary>
public static TraktExtendedCommentSortOrder Oldest { get; } = new TraktExtendedCommentSortOrder(2, "oldest", "oldest", "Oldest");

/// <summary>Comments will be sorted by the number of likes first.</summary>
public static TraktExtendedCommentSortOrder Likes { get; } = new TraktExtendedCommentSortOrder(4, "likes", "likes", "Likes");

/// <summary>Comments will be sorted by the number of replies first.</summary>
public static TraktExtendedCommentSortOrder Replies { get; } = new TraktExtendedCommentSortOrder(8, "replies", "replies", "Replies");

/// <summary>Comments will be sorted by highest comments first.</summary>
public static TraktExtendedCommentSortOrder Highest { get; } = new TraktExtendedCommentSortOrder(16, "highest", "highest", "Highest");

/// <summary>Comments will be sorted by lowest comments first.</summary>
public static TraktExtendedCommentSortOrder Lowest { get; } = new TraktExtendedCommentSortOrder(32, "lowest", "lowest", "Lowest");

/// <summary>Comments will be sorted by the number of plays first.</summary>
public static TraktExtendedCommentSortOrder Plays { get; } = new TraktExtendedCommentSortOrder(64, "plays", "plays", "Plays");

/// <summary>
/// Initializes a new instance of the <see cref="TraktExtendedCommentSortOrder" /> class.<para />
/// The initialized <see cref="TraktExtendedCommentSortOrder" /> is invalid.
/// </summary>
public TraktExtendedCommentSortOrder()
{
}

public TraktExtendedCommentSortOrder(int value, string objectName, string uriName, string displayName) : base(value, objectName, uriName, displayName)
{
}
}
}
4 changes: 2 additions & 2 deletions Source/Lib/Trakt.NET/Modules/TraktEpisodesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async IAsyncEnumerable<TraktResponse<ITraktEpisode>> GetEpisodesStreamAsy
/// <param name="showIdOrSlug">The show's Trakt-Id or -Slug. See also <seealso cref="ITraktShowIds" />.</param>
/// <param name="seasonNumber">The number of the season containing the episode, for which the comments should be queried.</param>
/// <param name="episodeNumber">The number of the episode, for which the comments should be queried.</param>
/// <param name="commentSortOrder">The comments sort order. See also <seealso cref="TraktCommentSortOrder" />.</param>
/// <param name="commentSortOrder">The comments sort order. See also <seealso cref="TraktExtendedCommentSortOrder" />.</param>
/// <param name="pagedParameters">Specifies pagination parameters. <see cref="TraktPagedParameters" />.</param>
/// <param name="cancellationToken">
/// Propagates notification that the request should be canceled.<para/>
Expand All @@ -157,7 +157,7 @@ public async IAsyncEnumerable<TraktResponse<ITraktEpisode>> GetEpisodesStreamAsy
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
/// <exception cref="TraktRequestValidationException">Thrown, if validation of request data fails.</exception>
public Task<TraktPagedResponse<ITraktComment>> GetEpisodeCommentsAsync(string showIdOrSlug, uint seasonNumber, uint episodeNumber,
TraktCommentSortOrder commentSortOrder = null,
TraktExtendedCommentSortOrder commentSortOrder = null,
TraktPagedParameters pagedParameters = null,
CancellationToken cancellationToken = default)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Lib/Trakt.NET/Modules/TraktMoviesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public Task<TraktListResponse<ITraktMovieTranslation>> GetMovieTranslationsAsync
/// </para>
/// </summary>
/// <param name="movieIdOrSlug">The movie's Trakt-Id or -Slug. See also <seealso cref="ITraktMovieIds" />.</param>
/// <param name="commentSortOrder">The comments sort order. See also <seealso cref="TraktCommentSortOrder" />.</param>
/// <param name="commentSortOrder">The comments sort order. See also <seealso cref="TraktExtendedCommentSortOrder" />.</param>
/// <param name="pagedParameters">Specifies pagination parameters. <see cref="TraktPagedParameters" />.</param>
/// <param name="cancellationToken">
/// Propagates notification that the request should be canceled.<para/>
Expand All @@ -234,7 +234,7 @@ public Task<TraktListResponse<ITraktMovieTranslation>> GetMovieTranslationsAsync
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
/// <exception cref="TraktRequestValidationException">Thrown, if validation of request data fails.</exception>
public Task<TraktPagedResponse<ITraktComment>> GetMovieCommentsAsync(string movieIdOrSlug,
TraktCommentSortOrder commentSortOrder = null,
TraktExtendedCommentSortOrder commentSortOrder = null,
TraktPagedParameters pagedParameters = null,
CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

internal sealed class EpisodeCommentsRequest : AEpisodeRequest<ITraktComment>, ISupportsPagination
{
internal TraktCommentSortOrder SortOrder { get; set; }
internal TraktExtendedCommentSortOrder SortOrder { get; set; }

public uint? Page { get; set; }

Expand All @@ -19,7 +19,7 @@ public override IDictionary<string, object> GetUriPathParameters()
{
var uriParams = base.GetUriPathParameters();

if (SortOrder != null && SortOrder != TraktCommentSortOrder.Unspecified)
if (SortOrder != null && SortOrder != TraktExtendedCommentSortOrder.Unspecified)
uriParams.Add("sort_order", SortOrder.UriName);

if (Page.HasValue)
Expand Down
4 changes: 2 additions & 2 deletions Source/Lib/Trakt.NET/Requests/Movies/MovieCommentsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

internal sealed class MovieCommentsRequest : AMovieRequest<ITraktComment>, ISupportsPagination
{
internal TraktCommentSortOrder SortOrder { get; set; }
internal TraktExtendedCommentSortOrder SortOrder { get; set; }

public uint? Page { get; set; }

Expand All @@ -19,7 +19,7 @@ public override IDictionary<string, object> GetUriPathParameters()
{
var uriParams = base.GetUriPathParameters();

if (SortOrder != null && SortOrder != TraktCommentSortOrder.Unspecified)
if (SortOrder != null && SortOrder != TraktExtendedCommentSortOrder.Unspecified)
uriParams.Add("sort_order", SortOrder.UriName);

if (Page.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,29 @@ public void Test_TraktCommentSortOrder_GetAll()
TraktCommentSortOrder.Oldest, TraktCommentSortOrder.Likes,
TraktCommentSortOrder.Replies });
}

[Fact]
public void Test_TraktCommentSortOrder_Properties()
{
TraktCommentSortOrder.Newest.Value.Should().Be(1);
TraktCommentSortOrder.Newest.ObjectName.Should().Be("newest");
TraktCommentSortOrder.Newest.UriName.Should().Be("newest");
TraktCommentSortOrder.Newest.DisplayName.Should().Be("Newest");

TraktCommentSortOrder.Oldest.Value.Should().Be(2);
TraktCommentSortOrder.Oldest.ObjectName.Should().Be("oldest");
TraktCommentSortOrder.Oldest.UriName.Should().Be("oldest");
TraktCommentSortOrder.Oldest.DisplayName.Should().Be("Oldest");

TraktCommentSortOrder.Likes.Value.Should().Be(4);
TraktCommentSortOrder.Likes.ObjectName.Should().Be("likes");
TraktCommentSortOrder.Likes.UriName.Should().Be("likes");
TraktCommentSortOrder.Likes.DisplayName.Should().Be("Likes");

TraktCommentSortOrder.Replies.Value.Should().Be(8);
TraktCommentSortOrder.Replies.ObjectName.Should().Be("replies");
TraktCommentSortOrder.Replies.UriName.Should().Be("replies");
TraktCommentSortOrder.Replies.DisplayName.Should().Be("Replies");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace TraktNet.Core.Tests.Enums
{
using FluentAssertions;
using System.Collections.Generic;
using Trakt.NET.Tests.Utility.Traits;
using TraktNet.Enums;
using Xunit;

[TestCategory("Enums")]
public class TraktExtendedCommentSortOrder_Tests
{
[Fact]
public void Test_TraktExtendedCommentSortOrder_GetAll()
{
var allValues = TraktEnumeration.GetAll<TraktExtendedCommentSortOrder>();

allValues.Should().NotBeNull().And.HaveCount(8);
allValues.Should().Contain(new List<TraktExtendedCommentSortOrder>() { TraktExtendedCommentSortOrder.Unspecified, TraktExtendedCommentSortOrder.Newest,
TraktExtendedCommentSortOrder.Oldest, TraktExtendedCommentSortOrder.Likes,
TraktExtendedCommentSortOrder.Replies, TraktExtendedCommentSortOrder.Highest,
TraktExtendedCommentSortOrder.Lowest, TraktExtendedCommentSortOrder.Plays });
}

[Fact]
public void Test_TraktExtendedCommentSortOrder_Properties()
{
TraktExtendedCommentSortOrder.Newest.Value.Should().Be(1);
TraktExtendedCommentSortOrder.Newest.ObjectName.Should().Be("newest");
TraktExtendedCommentSortOrder.Newest.UriName.Should().Be("newest");
TraktExtendedCommentSortOrder.Newest.DisplayName.Should().Be("Newest");

TraktExtendedCommentSortOrder.Oldest.Value.Should().Be(2);
TraktExtendedCommentSortOrder.Oldest.ObjectName.Should().Be("oldest");
TraktExtendedCommentSortOrder.Oldest.UriName.Should().Be("oldest");
TraktExtendedCommentSortOrder.Oldest.DisplayName.Should().Be("Oldest");

TraktExtendedCommentSortOrder.Likes.Value.Should().Be(4);
TraktExtendedCommentSortOrder.Likes.ObjectName.Should().Be("likes");
TraktExtendedCommentSortOrder.Likes.UriName.Should().Be("likes");
TraktExtendedCommentSortOrder.Likes.DisplayName.Should().Be("Likes");

TraktExtendedCommentSortOrder.Replies.Value.Should().Be(8);
TraktExtendedCommentSortOrder.Replies.ObjectName.Should().Be("replies");
TraktExtendedCommentSortOrder.Replies.UriName.Should().Be("replies");
TraktExtendedCommentSortOrder.Replies.DisplayName.Should().Be("Replies");

TraktExtendedCommentSortOrder.Highest.Value.Should().Be(16);
TraktExtendedCommentSortOrder.Highest.ObjectName.Should().Be("highest");
TraktExtendedCommentSortOrder.Highest.UriName.Should().Be("highest");
TraktExtendedCommentSortOrder.Highest.DisplayName.Should().Be("Highest");

TraktExtendedCommentSortOrder.Lowest.Value.Should().Be(32);
TraktExtendedCommentSortOrder.Lowest.ObjectName.Should().Be("lowest");
TraktExtendedCommentSortOrder.Lowest.UriName.Should().Be("lowest");
TraktExtendedCommentSortOrder.Lowest.DisplayName.Should().Be("Lowest");

TraktExtendedCommentSortOrder.Plays.Value.Should().Be(64);
TraktExtendedCommentSortOrder.Plays.ObjectName.Should().Be("plays");
TraktExtendedCommentSortOrder.Plays.UriName.Should().Be("plays");
TraktExtendedCommentSortOrder.Plays.DisplayName.Should().Be("Plays");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TraktEpisodesModule_Tests
private const int COMMENTS_ITEM_COUNT = 4;
private const int LISTS_ITEM_COUNT = 10;
private readonly TraktExtendedInfo EXTENDED_INFO = new TraktExtendedInfo { Full = true };
private readonly TraktCommentSortOrder COMMENT_SORT_ORDER = TraktCommentSortOrder.Likes;
private readonly TraktExtendedCommentSortOrder COMMENT_SORT_ORDER = TraktExtendedCommentSortOrder.Likes;
private readonly TraktListSortOrder LIST_SORT_ORDER = TraktListSortOrder.Comments;
private readonly TraktListType LIST_TYPE = TraktListType.Official;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class TraktMoviesModule_Tests
private const int LISTS_ITEM_COUNT = 10;
private readonly TraktExtendedInfo EXTENDED_INFO = new TraktExtendedInfo { Full = true };
private readonly TraktTimePeriod TIME_PERIOD = TraktTimePeriod.Monthly;
private readonly TraktCommentSortOrder COMMENT_SORT_ORDER = TraktCommentSortOrder.Likes;
private readonly TraktExtendedCommentSortOrder COMMENT_SORT_ORDER = TraktExtendedCommentSortOrder.Likes;
private readonly TraktListSortOrder LIST_SORT_ORDER = TraktListSortOrder.Comments;
private readonly TraktListType LIST_TYPE = TraktListType.Official;
private readonly DateTime TODAY = DateTime.UtcNow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class EpisodeCommentsRequest_TestData : IEnumerable<object[]>
private const string _id = "123";
private const uint _seasonNumber = 1;
private const uint _episodeNumber = 8;
private static readonly TraktCommentSortOrder _sortOrder = TraktCommentSortOrder.Newest;
private static readonly TraktExtendedCommentSortOrder _sortOrder = TraktExtendedCommentSortOrder.Newest;
private const int _page = 5;
private const int _limit = 20;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Test_MovieCommentsRequest_Returns_Valid_UriPathParameters(IDictionar
public class MovieCommentsRequest_TestData : IEnumerable<object[]>
{
private const string _id = "123";
private static readonly TraktCommentSortOrder _sortOrder = TraktCommentSortOrder.Newest;
private static readonly TraktExtendedCommentSortOrder _sortOrder = TraktExtendedCommentSortOrder.Newest;
private const int _page = 5;
private const int _limit = 20;

Expand Down

0 comments on commit eff7c60

Please sign in to comment.