Example #1
0
        async public Task CanExtractCompressedJsonEntityAsync()
        {
            // arrange
            var uri     = "http://localhost/";
            var factory = new TestWebRequestFactory();

            factory.RegisterCompressedResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            var res = await handler.MakeRequestAsync(uri);

            // assert
            Assert.IsNotNull(res.Item2);
            Assert.AreEqual("Paul", res.Item2.Name);
        }
Example #2
0
        public void CanExtractCompressedJsonEntity()
        {
            // arrange
            var uri     = "http://localhost/";
            var factory = new TestWebRequestFactory();

            factory.RegisterCompressedResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            UserContract data = null;

            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNotNull(data);
            Assert.AreEqual("Paul", data.Name);
        }
Example #3
0
        public void GetPdf_GZipped_ReturnsGZippedStream([ValueSource("_getFormPdfActions")] Tuple <string, Func <TestInvoiceService, CompanyFile, Stream> > action)
        {
            // Arrange
            var cf = new CompanyFile {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };
            var expectedPdf = new MemoryStream(new byte[] { 0, 1, 2, 3 });
            var uri         = cf.Uri.AbsoluteUri + "/" + Route + "/" + _uid + "?templatename=tn";

            _webFactory.RegisterCompressedResultForUri(uri, expectedPdf);

            // Act
            var received = action.Item2(_service, cf);

            // Assert
            Assert.IsInstanceOf <GZipStream>(received);
            using (var actualPdf = new MemoryStream())
            {
                received.CopyTo(actualPdf);
                Assert.AreEqual(expectedPdf, actualPdf);
            }
        }
        public void CanExtractCompressedJsonEntity()
        {
            // arrange
            var uri = "http://localhost/";
            var factory = new TestWebRequestFactory();
            factory.RegisterCompressedResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            UserContract data = null;
            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNotNull(data);
            Assert.AreEqual("Paul", data.Name);
        }
        async public void CanExtractCompressedJsonEntityAsync()
        {
            // arrange
            var uri = "http://localhost/";
            var factory = new TestWebRequestFactory();
            factory.RegisterCompressedResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            var res = await handler.MakeRequestAsync(uri);

            // assert
            Assert.IsNotNull(res.Item2);
            Assert.AreEqual("Paul", res.Item2.Name);
        }