Skip to content

Commit

Permalink
GH-469: Add new enum type for extended comment sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling authored May 29, 2023
1 parent 350b8ae commit ff69965
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 1 deletion.
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)
{
}
}
}
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");
}
}
}

0 comments on commit ff69965

Please sign in to comment.