Esempio n. 1
0
        public async Task Test_CommentLikeObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktCommentLike traktCommentLike = new TraktCommentLike
            {
                LikedAt = LIKED_AT,
                User    = new TraktUser
                {
                    Username  = "******",
                    IsPrivate = false,
                    Name      = "Sean Rudford",
                    IsVIP     = true,
                    IsVIP_EP  = true,
                    Ids       = new TraktUserIds
                    {
                        Slug = "sean"
                    }
                }
            };

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

                    stringWriter.ToString().Should().Be($"{{\"liked_at\":\"{LIKED_AT.ToTraktLongDateTimeString()}\"," +
                                                        @"""user"":{""username"":""sean"",""private"":false,""ids"":{""slug"":""sean""}," +
                                                        @"""name"":""Sean Rudford"",""vip"":true,""vip_ep"":true}}");
                }
        }
Esempio n. 2
0
 public async Task Test_CommentLikeObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var traktJsonWriter = new CommentLikeObjectJsonWriter();
     ITraktCommentLike     traktCommentLike = new TraktCommentLike();
     Func <Task <string> > action           = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktCommentLike);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Esempio n. 3
0
        public async Task Test_CommentLikeObjectJsonWriter_WriteObject_JsonWriter_Only_User_Property()
        {
            ITraktCommentLike traktCommentLike = new TraktCommentLike
            {
                User = new TraktUser
                {
                    Username  = "******",
                    IsPrivate = false,
                    Name      = "Sean Rudford",
                    IsVIP     = true,
                    IsVIP_EP  = true,
                    Ids       = new TraktUserIds
                    {
                        Slug = "sean"
                    }
                }
            };

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

                    stringWriter.ToString().Should().Be(@"{""user"":{""username"":""sean"",""private"":false,""ids"":{""slug"":""sean""}," +
                                                        @"""name"":""Sean Rudford"",""vip"":true,""vip_ep"":true}}");
                }
        }
Esempio n. 4
0
        public void Test_CommentLikeObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var traktJsonWriter = new CommentLikeObjectJsonWriter();
            ITraktCommentLike traktCommentLike = new TraktCommentLike();
            Func <Task>       action           = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktCommentLike);

            action.Should().Throw <ArgumentNullException>();
        }
Esempio n. 5
0
        public async Task Test_CommentLikeObjectJsonWriter_WriteObject_StringWriter_Empty()
        {
            ITraktCommentLike traktCommentLike = new TraktCommentLike();

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

                json.Should().Be(@"{}");
            }
        }
Esempio n. 6
0
        public async Task Test_CommentLikeObjectJsonWriter_WriteObject_JsonWriter_Empty()
        {
            ITraktCommentLike traktCommentLike = new TraktCommentLike();

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

                    stringWriter.ToString().Should().Be(@"{}");
                }
        }
Esempio n. 7
0
        public async Task Test_CommentLikeObjectJsonWriter_WriteObject_StringWriter_Only_LikedAt_Property()
        {
            ITraktCommentLike traktCommentLike = new TraktCommentLike
            {
                LikedAt = LIKED_AT
            };

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

                json.Should().Be($"{{\"liked_at\":\"{LIKED_AT.ToTraktLongDateTimeString()}\"}}");
            }
        }
 public void Test_CommentLikeObjectJsonWriter_WriteObject_Object_Exceptions()
 {
     var traktJsonWriter          = new CommentLikeObjectJsonWriter();
     Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default);