public async Task Test_NetworkObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var                   traktJsonWriter = new NetworkObjectJsonWriter();
     ITraktNetwork         traktNetwork    = new TraktNetwork();
     Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktNetwork);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Ejemplo n.º 2
0
        public override async Task <ITraktNetwork> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktNetwork traktNetwork = new TraktNetwork();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_NAME:
                        traktNetwork.Name = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktNetwork);
            }

            return(await Task.FromResult(default(ITraktNetwork)));
        }
Ejemplo n.º 3
0
        public void Test_NetworkObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var           traktJsonWriter = new NetworkObjectJsonWriter();
            ITraktNetwork traktNetwork    = new TraktNetwork();
            Func <Task>   action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktNetwork);

            action.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 4
0
        private static TraktNetwork CreateNetworkData(TraktUser user)
        {
            TraktNetwork network = new TraktNetwork
            {
                Username = TraktSettings.Username,
                Password = TraktSettings.Password,
                User     = user.Username
            };

            return(network);
        }
        public async Task Test_NetworkObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktNetwork traktNetwork = new TraktNetwork
            {
                Network = "network"
            };

            var    traktJsonWriter = new NetworkObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktNetwork);

            json.Should().Be(@"{""network"":""network""}");
        }
        public async Task Test_NetworkObjectJsonWriter_WriteObject_StringWriter_Complete()
        {
            ITraktNetwork traktNetwork = new TraktNetwork
            {
                Name = "network"
            };

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

                json.Should().Be(@"{""name"":""network""}");
            }
        }
        public async Task Test_NetworkObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktNetwork traktNetwork = new TraktNetwork
            {
                Network = "network"
            };

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

                    stringWriter.ToString().Should().Be(@"{""network"":""network""}");
                }
        }
Ejemplo n.º 8
0
        public void TestTraktNetworkDefaultConstructor()
        {
            var network = new TraktNetwork();

            network.Name.Should().BeNullOrEmpty();
        }
Ejemplo n.º 9
0
        public void Test_TraktNetwork_Default_Constructor()
        {
            var traktNetwork = new TraktNetwork();

            traktNetwork.Network.Should().BeNull();
        }