コード例 #1
0
        public void Doesnt_Wrap_HttpContentSerializationException()
        {
            var ex         = new HttpContentSerializationException("To be thrown...");
            var serializer = new MockedHttpContentSerializer()
            {
                SerializeCoreImpl = (c, e) => throw ex,
            };

            Action testCode = () => serializer.Serialize(null, contentType: null, encoding: null);

            testCode.Should().Throw <HttpContentSerializationException>().Which.Should().BeSameAs(ex);
        }
コード例 #2
0
        public async Task Doesnt_Wrap_HttpContentSerializationException()
        {
            var ex         = new HttpContentSerializationException("To be thrown...");
            var content    = new ByteArrayContent(new byte[0]);
            var serializer = new MockedHttpContentSerializer()
            {
                DeserializeCoreImpl = (c, e) => throw ex,
            };

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

            (await testCode.Should().ThrowAsync <HttpContentSerializationException>())
            .Which.Should().BeSameAs(ex);
        }