public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_Object_Complete() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Number = 1, Aired = 24, Completed = 12, Episodes = new List <ITraktEpisodeWatchedProgress> { new TraktEpisodeWatchedProgress { Number = 1, Completed = true, LastWatchedAt = LAST_WATCHED_AT }, new TraktEpisodeWatchedProgress { Number = 2, Completed = true, LastWatchedAt = LAST_WATCHED_AT } } }; var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktSeasonWatchedProgress); json.Should().Be(@"{""number"":1,""aired"":24,""completed"":12," + @"""episodes"":[" + $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," + $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" + "]}"); }
public void Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_Object_Exceptions() { var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(ITraktSeasonWatchedProgress)); action.Should().Throw <ArgumentNullException>(); }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_JsonWriter_Only_Episodes_Property() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Episodes = new List <ITraktEpisodeWatchedProgress> { new TraktEpisodeWatchedProgress { Number = 1, Completed = true, LastWatchedAt = LAST_WATCHED_AT }, new TraktEpisodeWatchedProgress { Number = 2, Completed = true, LastWatchedAt = LAST_WATCHED_AT } } }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSeasonWatchedProgress); stringWriter.ToString().Should().Be(@"{""episodes"":[" + $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," + $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" + "]}"); } }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_JsonWriter_Exceptions() { var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress(); Func <Task> action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktSeasonWatchedProgress); await action.Should().ThrowAsync <ArgumentNullException>(); }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_Object_Only_Completed_Property() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Completed = 12 }; var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktSeasonWatchedProgress); json.Should().Be(@"{""completed"":12}"); }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_Object_Only_Number_Property() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Number = 1 }; var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktSeasonWatchedProgress); json.Should().Be(@"{""number"":1}"); }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_StringWriter_Only_Aired_Property() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Aired = 24 }; using (var stringWriter = new StringWriter()) { var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktSeasonWatchedProgress); json.Should().Be(@"{""aired"":24}"); } }
public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_JsonWriter_Only_Completed_Property() { ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress { Completed = 12 }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSeasonWatchedProgress); stringWriter.ToString().Should().Be(@"{""completed"":12}"); } }