public void Test_ImageObjectJsonReader_ReadObject_From_JsonReader_Null() { var traktJsonReader = new ImageObjectJsonReader(); Func <Task <ITraktImage> > traktImage = () => traktJsonReader.ReadObjectAsync(default(JsonTextReader)); traktImage.Should().Throw <ArgumentNullException>(); }
public override async Task <ITraktUserImages> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserImages))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var imageReader = new ImageObjectJsonReader(); ITraktUserImages traktUserImage = new TraktUserImages(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_IMAGES_PROPERTY_NAME_AVATAR: traktUserImage.Avatar = await imageReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserImage); } return(await Task.FromResult(default(ITraktUserImages))); }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Json_String_Empty() { var jsonReader = new ImageObjectJsonReader(); var traktImage = await jsonReader.ReadObjectAsync(string.Empty); traktImage.Should().BeNull(); }
public async Task Test_TraktImage_From_Json() { var jsonReader = new ImageObjectJsonReader(); var traktImage = await jsonReader.ReadObjectAsync(JSON) as TraktImage; traktImage.Should().NotBeNull(); traktImage.Full.Should().Be("https://walter.trakt.us/images/shows/000/060/300/logos/original/ab151d1043.png"); }
public async Task Test_ImageObjectJsonReader_ReadObject_From_JsonReader_Null() { var traktJsonReader = new ImageObjectJsonReader(); var traktImage = await traktJsonReader.ReadObjectAsync(default(JsonTextReader)); traktImage.Should().BeNull(); }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Json_String_Not_Valid() { var jsonReader = new ImageObjectJsonReader(); var traktImage = await jsonReader.ReadObjectAsync(JSON_NOT_VALID); traktImage.Should().NotBeNull(); traktImage.Full.Should().BeNull(); }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Json_String_Complete() { var jsonReader = new ImageObjectJsonReader(); var traktImage = await jsonReader.ReadObjectAsync(JSON_COMPLETE); traktImage.Should().NotBeNull(); traktImage.Full.Should().Be("https://walter.trakt.us/images/shows/000/060/300/logos/original/ab151d1043.png"); }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Stream_Empty() { var traktJsonReader = new ImageObjectJsonReader(); using (var stream = string.Empty.ToStream()) { var traktImage = await traktJsonReader.ReadObjectAsync(stream); traktImage.Should().BeNull(); } }
public async Task Test_ImageObjectJsonReader_ReadObject_From_JsonReader_Empty() { var traktJsonReader = new ImageObjectJsonReader(); using (var reader = new StringReader(string.Empty)) using (var jsonReader = new JsonTextReader(reader)) { var traktImage = await traktJsonReader.ReadObjectAsync(jsonReader); traktImage.Should().BeNull(); } }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Stream_Not_Valid() { var traktJsonReader = new ImageObjectJsonReader(); using (var stream = JSON_NOT_VALID.ToStream()) { var traktImage = await traktJsonReader.ReadObjectAsync(stream); traktImage.Should().NotBeNull(); traktImage.Full.Should().BeNull(); } }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Stream_Complete() { var traktJsonReader = new ImageObjectJsonReader(); using (var stream = JSON_COMPLETE.ToStream()) { var traktImage = await traktJsonReader.ReadObjectAsync(stream); traktImage.Should().NotBeNull(); traktImage.Full.Should().Be("https://walter.trakt.us/images/shows/000/060/300/logos/original/ab151d1043.png"); } }
public async Task Test_ImageObjectJsonReader_ReadObject_From_JsonReader_Not_Valid() { var traktJsonReader = new ImageObjectJsonReader(); using (var reader = new StringReader(JSON_NOT_VALID)) using (var jsonReader = new JsonTextReader(reader)) { var traktImage = await traktJsonReader.ReadObjectAsync(jsonReader); traktImage.Should().NotBeNull(); traktImage.Full.Should().BeNull(); } }
public async Task Test_ImageObjectJsonReader_ReadObject_From_Json_String_Null() { var jsonReader = new ImageObjectJsonReader(); Func <Task <ITraktImage> > traktImage = () => jsonReader.ReadObjectAsync(default(string)); await traktImage.Should().ThrowAsync <ArgumentNullException>(); }