|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | +using Xunit; |
| 5 | +using System.Text.Json; |
| 6 | + |
| 7 | +using Dropbox.Sign.Api; |
| 8 | +using Dropbox.Sign.Model; |
| 9 | + |
| 10 | +namespace Dropbox.Sign.Test.Api |
| 11 | +{ |
| 12 | + public class FaxApiTests |
| 13 | + { |
| 14 | + [Fact] |
| 15 | + public void SendFaxTest() |
| 16 | + { |
| 17 | + var requestData = TestHelper.GetJsonContents(nameof(FaxSendRequest)); |
| 18 | + var responseData = TestHelper.GetJsonContents(nameof(FaxGetResponse)); |
| 19 | + |
| 20 | + var obj = FaxSendRequest.Init( |
| 21 | + requestData.ToString() |
| 22 | + ); |
| 23 | + |
| 24 | + obj.Files = new List<Stream> { |
| 25 | + new FileStream( |
| 26 | + TestHelper.RootPath + "/pdf-sample.pdf", |
| 27 | + FileMode.Open, |
| 28 | + FileAccess.Read, |
| 29 | + FileShare.Read |
| 30 | + ) |
| 31 | + }; |
| 32 | + |
| 33 | + var responseObj = FaxGetResponse.Init(responseData.ToString()); |
| 34 | + |
| 35 | + var api = MockRestClientHelper.CreateApiExpectMultiFormRequest<FaxGetResponse, FaxApi>(responseObj); |
| 36 | + var response = api.FaxSend(obj); |
| 37 | + |
| 38 | + TestHelper.AssertJsonSame(responseData.ToString(), response.ToJson()); |
| 39 | + } |
| 40 | + |
| 41 | + [Fact] |
| 42 | + public void FaxListTest() |
| 43 | + { |
| 44 | + var responseData = TestHelper.GetJsonContents(nameof(FaxListResponse)); |
| 45 | + |
| 46 | + var api = MockRestClientHelper.CreateApi<FaxApi>(responseData); |
| 47 | + var response = api.FaxList(); |
| 48 | + |
| 49 | + TestHelper.AssertJsonSame(responseData.ToString(), response.ToJson()); |
| 50 | + } |
| 51 | + |
| 52 | + [Fact] |
| 53 | + public void FaxGetTest() |
| 54 | + { |
| 55 | + var faxId = "c2e9691c85d9d6fa6ae773842e3680b2b8650f1d"; |
| 56 | + |
| 57 | + var responseData = TestHelper.GetJsonContents(nameof(FaxGetResponse)); |
| 58 | + |
| 59 | + var api = MockRestClientHelper.CreateApi<FaxApi>(responseData); |
| 60 | + var response = api.FaxGet(faxId); |
| 61 | + |
| 62 | + TestHelper.AssertJsonSame(responseData.ToString(), response.ToJson()); |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments