Example #1
0
 public async Task Test_CastMemberObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
 {
     var traktJsonWriter = new CastMemberObjectJsonWriter();
     ITraktCastMember traktCastMember = new TraktCastMember();
     Func <Task>      action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktCastMember);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Example #2
0
        public async Task Test_CastMemberObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktCastMember traktCastMember = new TraktCastMember
            {
                Characters = new List <string>
                {
                    "Character"
                },
                Person = new TraktPerson
                {
                    Name = "Person",
                    Ids  = new TraktPersonIds
                    {
                        Slug = "person"
                    }
                }
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new CastMemberObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktCastMember);

                    stringWriter.ToString().Should().Be(@"{""characters"":[""Character""],""person"":{""name"":""Person"",""ids"":{""trakt"":0,""slug"":""person""}}}");
                }
        }
Example #3
0
        public void Test_CastMemberObjectJsonWriter_WriteObject_StringWriter_Exceptions()
        {
            var traktJsonWriter = new CastMemberObjectJsonWriter();
            ITraktCastMember      traktCastMember = new TraktCastMember();
            Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktCastMember);

            action.Should().Throw <ArgumentNullException>();
        }
        public async Task Test_CastMemberObjectJsonWriter_WriteObject_StringWriter_Empty()
        {
            ITraktCastMember traktCastMember = new TraktCastMember();

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new CastMemberObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktCastMember);

                json.Should().Be("{}");
            }
        }
Example #5
0
        public async Task Test_CastMemberObjectJsonWriter_WriteObject_JsonWriter_Empty()
        {
            ITraktCastMember traktCastMember = new TraktCastMember();

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new CastMemberObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktCastMember);

                    stringWriter.ToString().Should().Be("{}");
                }
        }
        public async Task Test_CastMemberObjectJsonWriter_WriteObject_StringWriter_Only_Characters_Property()
        {
            ITraktCastMember traktCastMember = new TraktCastMember
            {
                Characters = new List <string>
                {
                    "Character"
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new CastMemberObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktCastMember);

                json.Should().Be(@"{""characters"":[""Character""]}");
            }
        }
        public async Task Test_CastMemberObjectJsonWriter_WriteObject_StringWriter_Only_Person_Property()
        {
            ITraktCastMember traktCastMember = new TraktCastMember
            {
                Person = new TraktPerson
                {
                    Name = "Person",
                    Ids  = new TraktPersonIds
                    {
                        Slug = "person"
                    }
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new CastMemberObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktCastMember);

                json.Should().Be(@"{""person"":{""name"":""Person"",""ids"":{""trakt"":0,""slug"":""person""}}}");
            }
        }