Beispiel #1
0
        public async Task Throws_HttpContentSerializationException_If_Content_Is_Null()
        {
            var         serializer = new MockedHttpContentSerializer();
            Func <Task> testCode   = async() => await serializer.DeserializeAsync(null, typeof(object));

            await testCode.Should().ThrowAsync <HttpContentSerializationException>();
        }
Beispiel #2
0
        public void Serializes_NoContent_To_Null()
        {
            var serializer  = new MockedHttpContentSerializer();
            var httpContent = serializer.Serialize(new NoContent(), encoding: null);

            httpContent.Should().BeNull();
        }
Beispiel #3
0
        public async Task Deserializes_NoContent()
        {
            var serializer = new MockedHttpContentSerializer();
            var content    = new ByteArrayContent(new byte[0]);
            var result     = await serializer.DeserializeAsync(content, typeof(NoContent));

            result.Should().BeOfType <NoContent>();
        }
Beispiel #4
0
        public async Task Throws_ArgumentNullException_For_ContentType()
        {
            var serializer = new MockedHttpContentSerializer();
            var content    = new ByteArrayContent(new byte[0]);

            Func <Task> testCode = async() => await serializer.DeserializeAsync(content, null);

            await testCode.Should().ThrowAsync <ArgumentNullException>();
        }
Beispiel #5
0
        public void Uses_DefaultEncoding_If_No_Encoding_Is_Specified()
        {
            Encoding encoding   = null;
            var      serializer = new MockedHttpContentSerializer()
            {
                SerializeCoreImpl = (c, e) => { encoding = e; return(null); }
            };

            serializer.Serialize(null, contentType: null, encoding: null);
            encoding.Should().BeSameAs(serializer.DefaultEncoding);
        }
Beispiel #6
0
 public async Task Doesnt_Throw_HttpContentSerializationException_If_Content_Is_Null_And_Deserializing_NoContent()
 {
     var serializer = new MockedHttpContentSerializer();
     await serializer.DeserializeAsync(null, typeof(NoContent)); // Should not throw.
 }