Ejemplo n.º 1
0
        public void UnitTests_V2_Fax_Download()
        {
            var pdfInBytes = BinaryFixtures.GetTestPdf();

            Action <IRestRequest> parameterAsserts = req =>
            {
                var parameters = ParametersHelper.ToDictionary(req.Parameters);

                Assert.AreEqual(parameters["thumbnail"], "l");
            };

            var requestAsserts = new RequestAsserts()
                                 .Auth()
                                 .Get()
                                 .Custom(parameterAsserts)
                                 .Resource("faxes/123456/file")
                                 .Build();

            var restClient = new RestClientBuilder()
                             .WithRequestAsserts(requestAsserts)
                             .AsPdf()
                             .RawBytes(pdfInBytes)
                             .Ok()
                             .Build();

            var phaxio = new PhaxioClient(RestClientBuilder.TEST_KEY, RestClientBuilder.TEST_SECRET, restClient);

            var fax = new FaxFile(123456, thumbnail: "l");

            fax.PhaxioClient = phaxio;

            var faxBytes = fax.Bytes;

            Assert.AreEqual(pdfInBytes, faxBytes, "Fax bytes should be the same");
        }
Ejemplo n.º 2
0
        public void UnitTests_V2_Fax_DeleteFiles()
        {
            var requestAsserts = new RequestAsserts()
                                 .Auth()
                                 .Delete()
                                 .Resource("faxes/123456/file")
                                 .Build();

            var restClient = new RestClientBuilder()
                             .WithRequestAsserts(requestAsserts)
                             .AsPdf()
                             .Content(JsonResponseFixtures.FromFile("V2/generic_success"))
                             .Ok()
                             .Build <Response <object> >();

            var phaxio = new PhaxioClient(RestClientBuilder.TEST_KEY, RestClientBuilder.TEST_SECRET, restClient);

            var file = new FaxFile(123456);

            file.PhaxioClient = phaxio;

            file.Delete();
        }
Ejemplo n.º 3
0
        public void UnitTests_V2_FileDownloadThrowsError()
        {
            var requestAsserts = new RequestAsserts()
                                 .Auth()
                                 .Get()
                                 .Resource("faxes/123456/file")
                                 .Build();

            var restClient = new RestClientBuilder()
                             .WithRequestAsserts(requestAsserts)
                             .AsJson()
                             .Content(JsonResponseFixtures.FromFile("V2/error_rate_limited"))
                             .RateLimited()
                             .Build();

            var phaxio = new PhaxioClient(RestClientBuilder.TEST_KEY, RestClientBuilder.TEST_SECRET, restClient);

            var fax = new FaxFile(123456);

            fax.PhaxioClient = phaxio;

            Assert.Throws(typeof(RateLimitException), () => Console.Write(fax.Pdf.Bytes));
        }