Skip to content

Commit

Permalink
GH-346 GH-340: Implement Validate() method for comment post objects
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Oct 30, 2022
1 parent e1fc5a1 commit c8ef5be
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace TraktNet.Objects.Post.Comments
{
using Extensions;
using Objects.Basic;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -21,6 +23,13 @@ public abstract class TraktCommentPost : ITraktCommentPost

public abstract Task<string> ToJson(CancellationToken cancellationToken = default);

public abstract void Validate();
public virtual void Validate()
{
if (Comment == null)
throw new ArgumentNullException(nameof(Comment));

if (Comment.WordCount() < 5)
throw new ArgumentOutOfRangeException(nameof(Comment), "comment has too few words - at least five words are required");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace TraktNet.Objects.Post.Comments
{
using Extensions;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -21,7 +23,11 @@ public virtual Task<string> ToJson(CancellationToken cancellationToken = default

public virtual void Validate()
{
// TODO
if (Comment == null)
throw new ArgumentNullException(nameof(Comment));

if (Comment.WordCount() < 5)
throw new ArgumentOutOfRangeException(nameof(Comment), "comment has too few words - at least five words are required");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Get.Episodes;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,7 +23,10 @@ public override Task<string> ToJson(CancellationToken cancellationToken = defaul

public override void Validate()
{
// TODO
base.Validate();

if (Episode == null)
throw new ArgumentNullException(nameof(Episode));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Get.Lists;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,7 +23,10 @@ public override Task<string> ToJson(CancellationToken cancellationToken = defaul

public override void Validate()
{
// TODO
base.Validate();

if (List == null)
throw new ArgumentNullException(nameof(List));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Get.Movies;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,7 +23,10 @@ public override Task<string> ToJson(CancellationToken cancellationToken = defaul

public override void Validate()
{
// TODO
base.Validate();

if (Movie == null)
throw new ArgumentNullException(nameof(Movie));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Get.Seasons;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,7 +23,10 @@ public override Task<string> ToJson(CancellationToken cancellationToken = defaul

public override void Validate()
{
// TODO
base.Validate();

if (Season == null)
throw new ArgumentNullException(nameof(Season));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Get.Shows;
using Objects.Json;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -22,7 +23,10 @@ public override Task<string> ToJson(CancellationToken cancellationToken = defaul

public override void Validate()
{
// TODO
base.Validate();

if (Show == null)
throw new ArgumentNullException(nameof(Show));
}
}
}

0 comments on commit c8ef5be

Please sign in to comment.