Skip to content

Commit 41d3580

Browse files
Merge pull request #531 from XeroAPI/Fix-513-Dotnet-SDK
Fix-513 | System.MissingMethodException with latest RestSharp client
2 parents a29b8cf + 399fb37 commit 41d3580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1362
-1050
lines changed

Xero.NetStandard.OAuth2.Test/Api/AccountingApiTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using System.Collections.ObjectModel;
1515
using System.Linq;
1616
using System.Reflection;
17-
using RestSharp;
1817
using Xunit;
1918
using System.Threading.Tasks;
2019
using AutoBogus;

Xero.NetStandard.OAuth2.Test/Api/BankFeedsApiTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using System.Collections.ObjectModel;
1515
using System.Linq;
1616
using System.Reflection;
17-
using RestSharp;
1817
using Xunit;
1918

2019
using Xero.NetStandard.OAuth2.Client;

Xero.NetStandard.OAuth2.Test/Api/PayrollAuApiTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System.Linq;
1616
using System.Reflection;
1717
using System.Threading.Tasks;
18-
using RestSharp;
1918
using Xunit;
2019

2120
using Xero.NetStandard.OAuth2.Client;

Xero.NetStandard.OAuth2.Test/Api/PayrollNzApiTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using System.Collections.ObjectModel;
1515
using System.Linq;
1616
using System.Reflection;
17-
using RestSharp;
1817
using Xunit;
1918

2019
using Xero.NetStandard.OAuth2.Client;

Xero.NetStandard.OAuth2.Test/Client/ApiClientTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using System.Collections.ObjectModel;
1515
using System.Linq;
1616
using System.Reflection;
17-
using RestSharp;
1817
using Xunit;
1918
using System.Threading.Tasks;
2019
using AutoBogus;

Xero.NetStandard.OAuth2.Test/Helpers/JsonDoc.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2-
using RestSharp;
2+
using System.Net;
3+
using System.Net.Http;
4+
using System.Text;
5+
using System.Threading.Tasks;
36
using Xero.NetStandard.OAuth2.Client;
47
using Xunit;
58
using Xunit.Sdk;
@@ -75,23 +78,33 @@ public string GetJsonRepresentation()
7578
}
7679
}
7780

78-
public static void Assert<TModel, TProperty>(IJsonValue input, Func<TModel, TProperty> toProperty, TProperty shouldBe)
81+
public static async Task Assert<TModel, TProperty>(IJsonValue input, Func<TModel, TProperty> toProperty, TProperty shouldBe)
7982
{
80-
var response = new RestResponse();
81-
83+
HttpResponseMessage response;
8284
if (input is NotPresent)
8385
{
84-
response.Content = "{}";
86+
response = new HttpResponseMessage(HttpStatusCode.OK)
87+
{
88+
Content = new StringContent("{}", Encoding.UTF8, "application/json")
89+
};
8590
}
8691
else
8792
{
88-
response.Content = $@"{{
93+
var jsonContent = $@"{{
8994
""{input.PropertyName}"": {input.GetJsonRepresentation()}
9095
}}";
96+
97+
response = new HttpResponseMessage(HttpStatusCode.OK)
98+
{
99+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
100+
};
91101
}
92-
response.StatusCode = System.Net.HttpStatusCode.OK;
102+
103+
response.EnsureSuccessStatusCode();
104+
93105
var deserializer = new CustomJsonCodec(new Configuration());
94-
var output = deserializer.Deserialize<TModel>(response);
106+
var output = await deserializer.Deserialize<TModel>(response);
107+
95108
Xunit.Assert.Equal(shouldBe, toProperty(output));
96109
}
97110
}

Xero.NetStandard.OAuth2.Test/Model/Accounting/InvoiceTests.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
using System.Linq;
1616
using System.IO;
1717
using System.Collections.Generic;
18+
using System.Net;
19+
using System.Net.Http;
1820
using Xero.NetStandard.OAuth2.Api;
1921
using Xero.NetStandard.OAuth2.Model;
2022
using Xero.NetStandard.OAuth2.Client;
2123
using System.Reflection;
24+
using System.Text;
25+
using System.Threading.Tasks;
2226
using Newtonsoft.Json;
23-
using RestSharp;
2427
using Xero.NetStandard.OAuth2.Model.Accounting;
2528

2629
namespace Xero.NetStandard.OAuth2.Test.Model.Accounting
@@ -193,16 +196,22 @@ public void PlannedPaymentDateTest()
193196
[Theory]
194197
[InlineData("20.00")]
195198
[InlineData("20")]
196-
public void CISDeduction_IsNumber_DeserializesCorrectly(string number)
199+
public async Task CISDeduction_IsNumber_DeserializesCorrectly(string number)
197200
{
198-
var response = new RestResponse();
199-
response.Content = $@"{{
201+
string jsonContent = $@"{{
200202
""CISDeduction"": {number}
201203
}}";
202-
response.StatusCode = System.Net.HttpStatusCode.OK;
204+
205+
var response = new HttpResponseMessage(HttpStatusCode.OK)
206+
{
207+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
208+
};
209+
210+
response.EnsureSuccessStatusCode();
203211

204212
var deserializer = new CustomJsonCodec(new Configuration());
205-
var invoices = deserializer.Deserialize<Invoice>(response);
213+
var invoices = await deserializer.Deserialize<Invoice>(response);
214+
206215

207216
Assert.Equal(20, invoices.CISDeduction);
208217
}

Xero.NetStandard.OAuth2.Test/Model/Bankfeeds/CountryCodeTests.cs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
using System.Linq;
1616
using System.IO;
1717
using System.Collections.Generic;
18+
using System.Net;
19+
using System.Net.Http;
1820
using Xero.NetStandard.OAuth2.Api;
1921
using Xero.NetStandard.OAuth2.Model.Bankfeeds;
2022
using Xero.NetStandard.OAuth2.Client;
2123
using System.Reflection;
24+
using System.Text;
25+
using System.Threading.Tasks;
2226
using Newtonsoft.Json;
23-
using RestSharp;
2427

2528
namespace Xero.NetStandard.OAuth2.Test.Model.Bankfeeds
2629
{
@@ -50,31 +53,41 @@ public void Dispose()
5053
[Theory]
5154
[InlineData("AU", CountryCode.AU)]
5255
[InlineData("NZ", CountryCode.NZ)]
53-
public void CountryCode_ValidInput_Deserialises(string input, CountryCode expected)
56+
public async Task CountryCode_ValidInput_Deserialises(string input, CountryCode expected)
5457
{
55-
var response = new RestResponse();
56-
response.Content = $@"""{input}""";
57-
response.StatusCode = System.Net.HttpStatusCode.OK;
58-
58+
string jsonContent = $@"""{input}""";
59+
60+
var response = new HttpResponseMessage(HttpStatusCode.OK)
61+
{
62+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
63+
};
64+
65+
response.EnsureSuccessStatusCode();
66+
5967
var deserializer = new CustomJsonCodec(new Configuration());
60-
var actual = deserializer.Deserialize<CountryCode>(response);
61-
68+
var actual = await deserializer.Deserialize<CountryCode>(response);
69+
6270
Assert.Equal(expected, actual);
6371
}
6472

6573
/// <summary>
6674
/// Test that CountryCode can be deserialised from null into 0
6775
/// </summary>
6876
[Fact]
69-
public void CountryCode_NullInput_Deserialises()
77+
public async Task CountryCode_NullInput_Deserialises()
7078
{
71-
var response = new RestResponse();
72-
response.Content = "null";
73-
response.StatusCode = System.Net.HttpStatusCode.OK;
74-
79+
string jsonContent = "null";
80+
81+
var response = new HttpResponseMessage(HttpStatusCode.OK)
82+
{
83+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
84+
};
85+
86+
response.EnsureSuccessStatusCode();
87+
7588
var deserializer = new CustomJsonCodec(new Configuration());
76-
var actual = deserializer.Deserialize<CountryCode>(response);
77-
89+
var actual = await deserializer.Deserialize<CountryCode>(response);
90+
7891
Assert.Equal(0, (int)actual);
7992
}
8093

Xero.NetStandard.OAuth2.Test/Model/Bankfeeds/CreditDebitIndicatorTests.cs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
using System.Linq;
1616
using System.IO;
1717
using System.Collections.Generic;
18+
using System.Net;
19+
using System.Net.Http;
1820
using Xero.NetStandard.OAuth2.Api;
1921
using Xero.NetStandard.OAuth2.Model.Bankfeeds;
2022
using Xero.NetStandard.OAuth2.Client;
2123
using System.Reflection;
24+
using System.Text;
25+
using System.Threading.Tasks;
2226
using Newtonsoft.Json;
23-
using RestSharp;
2427

2528
namespace Xero.NetStandard.OAuth2.Test.Model.Bankfeeds
2629
{
@@ -50,31 +53,41 @@ public void Dispose()
5053
[Theory]
5154
[InlineData("CREDIT", CreditDebitIndicator.CREDIT)]
5255
[InlineData("DEBIT", CreditDebitIndicator.DEBIT)]
53-
public void CreditDebitIndicator_ValidInput_Deserialises(string input, CreditDebitIndicator expected)
56+
public async Task CreditDebitIndicator_ValidInput_Deserialises(string input, CreditDebitIndicator expected)
5457
{
55-
var response = new RestResponse();
56-
response.Content = $@"""{input}""";
57-
response.StatusCode = System.Net.HttpStatusCode.OK;
58-
58+
string jsonContent = $@"""{input}""";
59+
60+
var response = new HttpResponseMessage(HttpStatusCode.OK)
61+
{
62+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
63+
};
64+
65+
response.EnsureSuccessStatusCode();
66+
5967
var deserializer = new CustomJsonCodec(new Configuration());
60-
var actual = deserializer.Deserialize<CreditDebitIndicator>(response);
61-
68+
var actual = await deserializer.Deserialize<CreditDebitIndicator>(response);
69+
6270
Assert.Equal(expected, actual);
6371
}
6472

6573
/// <summary>
6674
/// Test that CreditDebitIndicator can be deserialised from null into 0
6775
/// </summary>
6876
[Fact]
69-
public void CreditDebitIndicator_NullInput_Deserialises()
77+
public async Task CreditDebitIndicator_NullInput_Deserialises()
7078
{
71-
var response = new RestResponse();
72-
response.Content = "null";
73-
response.StatusCode = System.Net.HttpStatusCode.OK;
74-
79+
string jsonContent = "null";
80+
81+
var response = new HttpResponseMessage(HttpStatusCode.OK)
82+
{
83+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
84+
};
85+
86+
response.EnsureSuccessStatusCode();
87+
7588
var deserializer = new CustomJsonCodec(new Configuration());
76-
var actual = deserializer.Deserialize<CreditDebitIndicator>(response);
77-
89+
var actual = await deserializer.Deserialize<CreditDebitIndicator>(response);
90+
7891
Assert.Equal(0, (int)actual);
7992
}
8093

Xero.NetStandard.OAuth2.Test/Model/Bankfeeds/CurrencyCodeTests.cs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
using System.Linq;
1616
using System.IO;
1717
using System.Collections.Generic;
18+
using System.Net;
19+
using System.Net.Http;
1820
using Xero.NetStandard.OAuth2.Api;
1921
using Xero.NetStandard.OAuth2.Model.Bankfeeds;
2022
using Xero.NetStandard.OAuth2.Client;
2123
using System.Reflection;
24+
using System.Text;
25+
using System.Threading.Tasks;
2226
using Newtonsoft.Json;
23-
using RestSharp;
2427

2528
namespace Xero.NetStandard.OAuth2.Test.Model.Bankfeeds
2629
{
@@ -50,31 +53,41 @@ public void Dispose()
5053
[Theory]
5154
[InlineData("AUD", CurrencyCode.AUD)]
5255
[InlineData("NZD", CurrencyCode.NZD)]
53-
public void CurrencyCode_ValidInput_Deserialises(string input, CurrencyCode expected)
56+
public async Task CurrencyCode_ValidInput_Deserialises(string input, CurrencyCode expected)
5457
{
55-
var response = new RestResponse();
56-
response.Content = $@"""{input}""";
57-
response.StatusCode = System.Net.HttpStatusCode.OK;
58-
58+
string jsonContent = $@"""{input}""";
59+
60+
var response = new HttpResponseMessage(HttpStatusCode.OK)
61+
{
62+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
63+
};
64+
65+
response.EnsureSuccessStatusCode();
66+
5967
var deserializer = new CustomJsonCodec(new Configuration());
60-
var actual = deserializer.Deserialize<CurrencyCode>(response);
61-
68+
var actual = await deserializer.Deserialize<CurrencyCode>(response);
69+
6270
Assert.Equal(expected, actual);
6371
}
6472

6573
/// <summary>
6674
/// Test that CurrencyCode can be deserialised from null into 0
6775
/// </summary>
6876
[Fact]
69-
public void CurrencyCode_NullInput_Deserialises()
77+
public async Task CurrencyCode_NullInput_Deserialises()
7078
{
71-
var response = new RestResponse();
72-
response.Content = "null";
73-
response.StatusCode = System.Net.HttpStatusCode.OK;
74-
79+
string jsonContent = "null";
80+
81+
var response = new HttpResponseMessage(HttpStatusCode.OK)
82+
{
83+
Content = new StringContent(jsonContent, Encoding.UTF8, "application/json")
84+
};
85+
86+
response.EnsureSuccessStatusCode();
87+
7588
var deserializer = new CustomJsonCodec(new Configuration());
76-
var actual = deserializer.Deserialize<CurrencyCode>(response);
77-
89+
var actual = await deserializer.Deserialize<CurrencyCode>(response);
90+
7891
Assert.Equal(0, (int)actual);
7992
}
8093

0 commit comments

Comments
 (0)