Skip to content

Commit 0878dcd

Browse files
Feature/prism changes dotnet (#603)
Feature/prism changes dotnet (#603)
1 parent 2a17514 commit 0878dcd

File tree

28 files changed

+2047
-393
lines changed

28 files changed

+2047
-393
lines changed

.github/workflows/build-test-lint.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ jobs:
2323
run: dotnet build
2424
working-directory: Xero-NetStandard
2525

26-
- name: Check for Outdated Packages
27-
run: |
28-
dotnet list package --outdated
29-
working-directory: Xero-NetStandard
30-
3126
# - name: Validate Lint
3227
# run: dotnet format --verify-no-changes
3328
# working-directory: Xero-NetStandard

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The Xero-NetStandard SDK makes it easy for developers to access Xero's APIs in t
1717
- [API Clients](#api-clients)
1818
- [Helper Methods](#helper-methods)
1919
- [Usage Examples](#usage-examples)
20+
- [Running Test(s) in Local](#running-tests-in-local)
2021
- [SDK conventions](#sdk-conventions)
2122
- [Contributing](#contributing)
2223

@@ -796,6 +797,16 @@ await FilesApi.DeleteFileAssociationAsync(accessToken, xeroTenantId, fileIdGuid,
796797
```
797798

798799
---
800+
## Running Test(s) in Local
801+
For Running Test cases PRISM Mock Server needs to be started in the local machine.
802+
Steps to Run Test(s)
803+
* Install PRISM from npm using the command: **npm install -g @stoplight/prism-cli**
804+
* Verify Installation: **prism --version**
805+
* Navigate to **Xero-NetStandard--> Xero.NetStandard.OAuth2.Test--> util** folder in the terminal
806+
* Execute the script **./start-prism.sh**
807+
* This will start the PRISM Server in Local
808+
* Run **dotnet test** to run the dotnet test cases.
809+
799810
## SDK conventions
800811

801812
## Security (state check & Jwt validation)

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

Lines changed: 192 additions & 34 deletions
Large diffs are not rendered by default.

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

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ public void InstanceTest()
7676
[Fact]
7777
public async Task CreateEmployeeTest()
7878
{
79-
List<Employee> employee =
80-
new List<Employee> { new Employee() };
81-
var response = await instance.CreateEmployeeAsync(accessToken, xeroTenantId, employee);
79+
List<Employee> employees = new List<Employee> { new Employee()
80+
{
81+
FirstName = "Adam",
82+
LastName = "Adamson",
83+
DateOfBirth = new DateTime(2000, 10, 10)
84+
}};
85+
var response = await instance.CreateEmployeeAsync(accessToken, xeroTenantId, employees);
8286
Assert.IsType<Employees>(response);
8387
}
8488

@@ -111,7 +115,10 @@ public async Task CreatePayItemTest()
111115
[Fact]
112116
public async Task CreatePayRunTest()
113117
{
114-
List<PayRun> payRun = new List<PayRun> { new PayRun() };
118+
List<PayRun> payRun = new List<PayRun> { new PayRun()
119+
{
120+
PayrollCalendarID = Guid.Parse("00000000-0000-0000-0000-000000000000")
121+
}};
115122
var response = await instance.CreatePayRunAsync(accessToken, xeroTenantId, payRun);
116123
Assert.IsType<PayRuns>(response);
117124
}
@@ -133,7 +140,10 @@ public async Task CreatePayrollCalendarTest()
133140
[Fact]
134141
public async Task CreateSuperfundTest()
135142
{
136-
List<SuperFund> superFund = new List<SuperFund> { new SuperFund() };
143+
List<SuperFund> superFund = new List<SuperFund> { new SuperFund()
144+
{
145+
Type = SuperFundType.REGULATED
146+
}};
137147
var response = await instance.CreateSuperfundAsync(accessToken, xeroTenantId, superFund);
138148
Assert.IsType<SuperFunds>(response);
139149
}
@@ -144,7 +154,14 @@ public async Task CreateSuperfundTest()
144154
[Fact]
145155
public async Task CreateTimesheetTest()
146156
{
147-
List<Timesheet> timesheet = new List<Timesheet> { new Timesheet() };
157+
var startDate = new DateTime(2020, 10, 23);
158+
var endDate = new DateTime(2020, 10, 30);
159+
List<Timesheet> timesheet = new List<Timesheet> { new Timesheet()
160+
{
161+
EmployeeID = Guid.Parse("00000000-0000-0000-0000-000000000000"),
162+
StartDate = startDate,
163+
EndDate = endDate,
164+
}};
148165
var response = await instance.CreateTimesheetAsync(accessToken, xeroTenantId, timesheet);
149166
Assert.IsType<Timesheets>(response);
150167
}
@@ -353,7 +370,12 @@ public async Task GetTimesheetsTest()
353370
public async Task UpdateEmployeeTest()
354371
{
355372
Guid employeeId = AutoFaker.Generate<Guid>();
356-
List<Employee> employee = new List<Employee> { new Employee() };
373+
List<Employee> employee = new List<Employee> { new Employee()
374+
{
375+
FirstName = "Adam",
376+
LastName = "Adamson",
377+
DateOfBirth = new DateTime(2000, 10, 10)
378+
}};
357379
string idempotencyKey = AutoFaker.Generate<string>();
358380
var response = await instance.UpdateEmployeeAsync(accessToken, xeroTenantId, employeeId, employee, idempotencyKey);
359381
Assert.IsType<Employees>(response);
@@ -379,7 +401,10 @@ public async Task UpdatePayRunTest()
379401
{
380402
Guid payRunID = AutoFaker.Generate<Guid>();
381403
string idempotencyKey = AutoFaker.Generate<string>();
382-
List<PayRun> payRun = new List<PayRun> { new PayRun() };
404+
List<PayRun> payRun = new List<PayRun> { new PayRun()
405+
{
406+
PayrollCalendarID = Guid.Parse("00000000-0000-0000-0000-000000000000")
407+
}};
383408
var response = await instance.UpdatePayRunAsync(accessToken, xeroTenantId, payRunID, payRun, idempotencyKey);
384409
Assert.IsType<PayRuns>(response);
385410
}
@@ -405,7 +430,10 @@ public async Task UpdateSuperfundTest()
405430
{
406431
Guid superFundID = AutoFaker.Generate<Guid>();
407432
string idempotencyKey = AutoFaker.Generate<string>();
408-
List<SuperFund> superFund = new List<SuperFund> { new SuperFund() };
433+
List<SuperFund> superFund = new List<SuperFund> { new SuperFund()
434+
{
435+
Type = SuperFundType.REGULATED
436+
}};
409437
var response = await instance.UpdateSuperfundAsync(accessToken, xeroTenantId, superFundID, superFund, idempotencyKey);
410438
Assert.IsType<SuperFunds>(response);
411439
}
@@ -418,7 +446,14 @@ public async Task UpdateTimesheetTest()
418446
{
419447
Guid timesheetID = AutoFaker.Generate<Guid>();
420448
string idempotencyKey = AutoFaker.Generate<string>();
421-
List<Timesheet> timesheet = new List<Timesheet> { new Timesheet() };
449+
var startDate = new DateTime(2020, 10, 23);
450+
var endDate = new DateTime(2020, 10, 30);
451+
List<Timesheet> timesheet = new List<Timesheet> { new Timesheet()
452+
{
453+
EmployeeID = Guid.Parse("00000000-0000-0000-0000-000000000000"),
454+
StartDate = startDate,
455+
EndDate = endDate,
456+
}};
422457
var response = await instance.UpdateTimesheetAsync(accessToken, xeroTenantId, timesheetID, timesheet, idempotencyKey);
423458
Assert.IsType<Timesheets>(response);
424459
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"XeroConfiguration": {
3-
"AccountingBaseUrl": "https://25faf04a-c71e-40e7-b7ce-f1fae0149465.mock.pstmn.io/api.xro/2.0",
4-
"BankfeedsBaseUrl": "https://3e140044-4914-47dd-b4e1-df0cc040a44f.mock.pstmn.io/bankfeeds.xro/1.0",
5-
"PayrollAuBaseUrl": "https://5f9f95f1-25c8-40dd-8b10-8192c658dd79.mock.pstmn.io/payroll.xro/1.0"
3+
"AccountingBaseUrl": "http://127.0.0.1:4010",
4+
"BankfeedsBaseUrl": "http://127.0.0.1:4013",
5+
"PayrollAuBaseUrl": "http://127.0.0.1:4017"
66
}
77
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/bash
2+
branchName=${1:-"master"}
23

3-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero_accounting.yaml --host 127.0.0.1 --port 4010 &
4-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-app-store.yaml --host 127.0.0.1 --port 4011 &
5-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero_assets.yaml --host 127.0.0.1 --port 4012 &
6-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero_bankfeeds.yaml --host 127.0.0.1 --port 4013 &
7-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-finance.yaml --host 127.0.0.1 --port 4014 &
8-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-payroll-uk.yaml --host 127.0.0.1 --port 4015 &
9-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-payroll-nz.yaml --host 127.0.0.1 --port 4016 &
10-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-payroll-au.yaml --host 127.0.0.1 --port 4017 &
11-
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero-projects.yaml --host 127.0.0.1 --port 4018
4+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero_accounting.yaml --host 127.0.0.1 --port 4010 &
5+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-app-store.yaml --host 127.0.0.1 --port 4011 &
6+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero_assets.yaml --host 127.0.0.1 --port 4012 &
7+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero_bankfeeds.yaml --host 127.0.0.1 --port 4013 &
8+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-finance.yaml --host 127.0.0.1 --port 4014 &
9+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-payroll-uk.yaml --host 127.0.0.1 --port 4015 &
10+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-payroll-nz.yaml --host 127.0.0.1 --port 4016 &
11+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-payroll-au.yaml --host 127.0.0.1 --port 4017 &
12+
prism mock https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/$branchName/xero-projects.yaml --host 127.0.0.1 --port 4018

0 commit comments

Comments
 (0)