Exemplo n.º 1
0
        private void SetDefaultSettings()
        {
            RequestFormatter  = new ModelAsJsonFormatter();
            ResponseFormatter = new ModelAsJsonFormatter();
            HeadersHandler    = new DefaultHeadersHandler();
            ResourceHandler   = new DefaultResourceHandler();

            DecompressionMethods = DecompressionMethods.Deflate | DecompressionMethods.GZip;
        }
Exemplo n.º 2
0
        public async Task Given_ModelAsJsonFormatter_When_Deserialize_IsCaller_WithValid_StreamAsJson_Then_Return_Model()
        {
            var sut             = new ModelAsJsonFormatter();
            var testExpectation = new SimpleModel
            {
                Name    = "Foo",
                Surname = "Bar"
            };

            var testEntry  = BuildMemoryStream(testExpectation);
            var testResult = await sut.Deserialize <SimpleModel>(testEntry).ConfigureAwait(false);

            testResult.Should().BeEquivalentTo(testExpectation);
        }
Exemplo n.º 3
0
        public async Task Given_ModelAsJsonFormatter_When_Serialize_IsCaller_WithValid_Model_Then_Return_StreamAsJson()
        {
            var sut       = new ModelAsJsonFormatter();
            var testModel = new SimpleModel
            {
                Name    = "Foo",
                Surname = "Bar"
            };

            var testExpectation = BuildMemoryStream(testModel);
            var testResult      = new MemoryStream();
            await sut.Serialize(testModel, testResult).ConfigureAwait(false);

            testResult.ToArray().Should().BeEquivalentTo(testExpectation.ToArray());
        }