public async Task Test_AuthorizationArrayJsonWriter_WriteArray_StringWriter_SingleObject()
        {
            IEnumerable <ITraktAuthorization> traktAuthorizations = new List <ITraktAuthorization>
            {
                new TraktAuthorization
                {
                    AccessToken        = "mockAccessToken1",
                    RefreshToken       = "mockRefreshToken1",
                    Scope              = TraktAccessScope.Public,
                    ExpiresInSeconds   = 7200,
                    TokenType          = TraktAccessTokenType.Bearer,
                    CreatedAtTimestamp = 1506271312UL,
                    IgnoreExpiration   = true
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var traktJsonWriter = new AuthorizationArrayJsonWriter
                {
                    CompleteSerialization = true
                };

                string json = await traktJsonWriter.WriteArrayAsync(stringWriter, traktAuthorizations);

                json.Should().Be(@"[{""access_token"":""mockAccessToken1"",""refresh_token"":""mockRefreshToken1""," +
                                 @"""scope"":""public"",""expires_in"":7200,""token_type"":""bearer""," +
                                 @"""created_at"":1506271312,""ignore_expiration"":true}]");
            }
        }
 public async Task Test_AuthorizationArrayJsonWriter_WriteArray_StringWriter_Exceptions()
 {
     var traktJsonWriter = new AuthorizationArrayJsonWriter();
     IEnumerable <ITraktAuthorization> traktAuthorizations = new List <TraktAuthorization>();
     Func <Task <string> >             action = () => traktJsonWriter.WriteArrayAsync(default(StringWriter), traktAuthorizations);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
        public async Task Test_AuthorizationArrayJsonWriter_WriteArray_Object_Empty()
        {
            IEnumerable <ITraktAuthorization> traktAuthorizations = new List <TraktAuthorization>();
            var    traktJsonWriter = new AuthorizationArrayJsonWriter();
            string json            = await traktJsonWriter.WriteArrayAsync(traktAuthorizations);

            json.Should().Be("[]");
        }
        public void Test_AuthorizationArrayJsonWriter_WriteArray_Object_Exceptions()
        {
            var traktJsonWriter = new AuthorizationArrayJsonWriter();
            IEnumerable <ITraktAuthorization> traktAuthorizations = new List <TraktAuthorization>();
            Func <Task <string> >             action = () => traktJsonWriter.WriteArrayAsync(default(IEnumerable <ITraktAuthorization>));

            action.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 5
0
        public async Task Test_AuthorizationArrayJsonWriter_WriteArray_JsonWriter_Empty()
        {
            IEnumerable <ITraktAuthorization> traktAuthorizations = new List <TraktAuthorization>();

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new AuthorizationArrayJsonWriter();
                    await traktJsonWriter.WriteArrayAsync(jsonWriter, traktAuthorizations);

                    stringWriter.ToString().Should().Be("[]");
                }
        }