public void TestTraktSerializationServiceSerializeTraktAuthorization()
        {
            var jsonAuthorization = TraktSerializationService.Serialize(AUTHORIZATION);

            jsonAuthorization.Should().NotBeNullOrEmpty();
            jsonAuthorization.Should().Be(AUTHORIZATION_JSON);
        }
        public void TestTraktSerializationServiceSerializeTraktDevice()
        {
            var jsonDevice = TraktSerializationService.Serialize(DEVICE);

            jsonDevice.Should().NotBeNullOrEmpty();
            jsonDevice.Should().Be(DEVICE_JSON);
        }
        static void Main(string[] args)
        {
            TraktClient client = new TraktClient(CLIENT_ID, CLIENT_SECRET);

            TraktAuthorization fakeAuthorization = new TraktAuthorization
            {
                AccessToken      = "FakeAccessToken",
                RefreshToken     = "FakeRefreshToken",
                ExpiresInSeconds = 90 * 24 * 3600,
                AccessScope      = TraktAccessScope.Public,
                TokenType        = TraktAccessTokenType.Bearer
            };

            Console.WriteLine("Fake Authorization:");
            Console.WriteLine($"Created (UTC): {fakeAuthorization.Created}");
            Console.WriteLine($"Access Scope: {fakeAuthorization.AccessScope.DisplayName}");
            Console.WriteLine($"Refresh Possible: {fakeAuthorization.IsRefreshPossible}");
            Console.WriteLine($"Valid: {fakeAuthorization.IsValid}");
            Console.WriteLine($"Token Type: {fakeAuthorization.TokenType.DisplayName}");
            Console.WriteLine($"Access Token: {fakeAuthorization.AccessToken}");
            Console.WriteLine($"Refresh Token: {fakeAuthorization.RefreshToken}");
            Console.WriteLine($"Token Expired: {fakeAuthorization.IsExpired}");
            Console.WriteLine($"Expires in {fakeAuthorization.ExpiresInSeconds / 3600 / 24} days");

            Console.WriteLine("-------------------------------------------------------------");

            //string fakeAuthorizationJson = TraktSerializationService.Serialize(client.Authorization);
            string fakeAuthorizationJson = TraktSerializationService.Serialize(fakeAuthorization);

            if (!string.IsNullOrEmpty(fakeAuthorizationJson))
            {
                Console.WriteLine("Serialized Fake Authorization:");
                Console.WriteLine(fakeAuthorizationJson);

                Console.WriteLine("-------------------------------------------------------------");

                TraktAuthorization deserializedFakeAuthorization = TraktSerializationService.DeserializeAuthorization(fakeAuthorizationJson);

                if (deserializedFakeAuthorization != null)
                {
                    client.Authorization = deserializedFakeAuthorization;

                    Console.WriteLine("Deserialized Fake Authorization:");
                    Console.WriteLine($"Created (UTC): {deserializedFakeAuthorization.Created}");
                    Console.WriteLine($"Access Scope: {deserializedFakeAuthorization.AccessScope.DisplayName}");
                    Console.WriteLine($"Refresh Possible: {deserializedFakeAuthorization.IsRefreshPossible}");
                    Console.WriteLine($"Valid: {deserializedFakeAuthorization.IsValid}");
                    Console.WriteLine($"Token Type: {deserializedFakeAuthorization.TokenType.DisplayName}");
                    Console.WriteLine($"Access Token: {deserializedFakeAuthorization.AccessToken}");
                    Console.WriteLine($"Refresh Token: {deserializedFakeAuthorization.RefreshToken}");
                    Console.WriteLine($"Token Expired: {deserializedFakeAuthorization.IsExpired}");
                    Console.WriteLine($"Expires in {deserializedFakeAuthorization.ExpiresInSeconds / 3600 / 24} days");
                }
            }

            Console.ReadLine();
        }
        public void TestTraktSerializationServiceSerializeEmptyTraktDevice()
        {
            var emptyDevice = new TraktDevice();

            string emptyDeviceJson =
                "{" +
                $"\"UserCode\":\"\"," +
                $"\"DeviceCode\":\"\"," +
                $"\"VerificationUrl\":\"\"," +
                $"\"ExpiresInSeconds\":0," +
                $"\"IntervalInSeconds\":0," +
                $"\"CreatedAtTicks\":{emptyDevice.Created.Ticks}" +
                "}";

            Action act = () => TraktSerializationService.Serialize(emptyDevice);

            act.ShouldNotThrow();

            var jsonDevice = TraktSerializationService.Serialize(emptyDevice);

            jsonDevice.Should().NotBeNullOrEmpty();
            jsonDevice.Should().Be(emptyDeviceJson);
        }
        public void TestTraktSerializationServiceSerializeEmptyTraktAuthorization()
        {
            var emptyAuthorization = new TraktAuthorization();

            string emptyAuthorizationJson =
                "{" +
                $"\"AccessToken\":\"\"," +
                $"\"RefreshToken\":\"\"," +
                $"\"ExpiresIn\":0," +
                $"\"Scope\":\"public\"," +
                $"\"TokenType\":\"bearer\"," +
                $"\"CreatedAtTicks\":{emptyAuthorization.Created.Ticks}," +
                $"\"IgnoreExpiration\":false" +
                "}";

            Action act = () => TraktSerializationService.Serialize(emptyAuthorization);

            act.ShouldNotThrow();

            var jsonAuthorization = TraktSerializationService.Serialize(emptyAuthorization);

            jsonAuthorization.Should().NotBeNullOrEmpty();
            jsonAuthorization.Should().Be(emptyAuthorizationJson);
        }
        public void TestTraktSerializationServiceSerializeTraktAuthorizationArgumentExceptions()
        {
            Action act = () => TraktSerializationService.Serialize(default(TraktAuthorization));

            act.ShouldThrow <ArgumentNullException>();
        }