Skip to content

Commit 2cb7d4b

Browse files
committed
release v1.0
1 parent e57f2d3 commit 2cb7d4b

File tree

6 files changed

+194
-283
lines changed

6 files changed

+194
-283
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defaults:
1010

1111
env:
1212
dotnet-version: "3.1.x"
13-
build_version: "0.0.3.${{ github.run_number }}-preview"
13+
build_version: "1.0.0.${{ github.run_number }}-preview"
1414

1515
jobs:
1616
pub-pkgs:

.github/workflows/ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,15 @@ defaults:
1010

1111
env:
1212
dotnet-version: "3.1.x"
13-
build_version: "0.0.3.${{ github.run_number }}-preview"
13+
build_version: "1.0.0.${{ github.run_number }}-preview"
1414

1515
jobs:
1616
ci:
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
apiVersion: ["1.9.0", "1.8.0", "1.7.1", "1.7.0", "1.6.0"]
21-
experimental: [false]
22-
include:
23-
- apiVersion: "1.5.0"
24-
experimental: true
2521
runs-on: ubuntu-latest
26-
continue-on-error: ${{ matrix.experimental }}
2722
steps:
2823
- name: Checkout
2924
uses: actions/checkout@v2

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defaults:
1010

1111
env:
1212
dotnet-version: "3.1.x"
13-
build_version: "0.0.3"
13+
build_version: "1.0.0"
1414

1515
jobs:
1616
pub-pkgs:

README.md

Lines changed: 191 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22

33
![CI](https://github.com/StardustDL/judge0-dotnet/workflows/CI/badge.svg) ![CD](https://github.com/StardustDL/judge0-dotnet/workflows/CD/badge.svg) ![License](https://img.shields.io/github/license/StardustDL/judge0-dotnet.svg) ![downloads](https://img.shields.io/nuget/dt/Judge0)
44

5-
Client SDK for Judge0 RESTful API.
5+
Client SDK for [Judge0](https://github.com/judge0/api) RESTful API.
6+
7+
## Features
8+
9+
- Authentication
10+
- Authorization
11+
- Submissions
12+
- Statuses and Languages
13+
- System and Configuration
14+
- Statistics
15+
- Health Check
16+
- Information
17+
18+
## Versions
619

720
Judge0 version supported status:
821

@@ -11,7 +24,6 @@ Judge0 version supported status:
1124
- [x] 1.7.1
1225
- [x] 1.7.0
1326
- [x] 1.6.0
14-
- [x] 1.5.0 (partially)
1527

1628
## Install
1729

@@ -21,16 +33,190 @@ dotnet add package Judge0
2133

2234
## Usage
2335

36+
### Create Service
37+
2438
```csharp
2539
var client = new HttpClient
2640
{
2741
BaseAddress = new Uri("apiUri")
2842
};
2943
IJudge0Service service = new Judge0Service(client);
44+
```
45+
46+
### Authentication & Authorization
47+
48+
```csharp
49+
public async Task AuthenticateAndAuthorize()
50+
{
51+
var result = await service.AuthenticationService.Authenticate("token");
52+
Assert.IsTrue(result.IsSuccessStatusCode);
53+
54+
result = await service.AuthenticationService.Authorize("user");
55+
Assert.IsTrue(result.IsSuccessStatusCode);
56+
}
57+
```
58+
59+
60+
### Submission
61+
62+
```csharp
63+
public async Task CreateGetAndDelete()
64+
{
65+
var result = await service.SubmissionsService.Create(new Submission
66+
{
67+
source_code = "#include <stdio.h>\n\nint main(void) {\n char name[10];\n scanf(\"%s\", name);\n printf(\"hello, %s\\n\", name);\n return 0;\n}",
68+
stdin = "world",
69+
language_id = 50,
70+
});
71+
Assert.IsTrue(result.IsSuccessStatusCode);
72+
string token = result.Result.token;
73+
74+
while (true)
75+
{
76+
await Task.Delay(TimeSpan.FromSeconds(1));
77+
var res = await service.SubmissionsService.Get(token);
78+
Assert.IsTrue(res.IsSuccessStatusCode);
79+
if(res.Result.status?.id > 2)
80+
{
81+
Assert.IsNotNull(res.Result.stdout);
82+
StringAssert.StartsWith(res.Result.stdout, "hello, world");
83+
break;
84+
}
85+
}
86+
87+
var del = await service.SubmissionsService.Delete(token);
88+
Assert.IsTrue(del.IsSuccessStatusCode);
89+
}
90+
91+
public async Task CreateWaitGetAndDelete()
92+
{
93+
var result = await service.SubmissionsService.CreateAndWait(new Submission
94+
{
95+
source_code = "#include <stdio.h>\n\nint main(void) {\n char name[10];\n scanf(\"%s\", name);\n printf(\"hello, %s\\n\", name);\n return 0;\n}",
96+
stdin = "world",
97+
language_id = 50,
98+
});
99+
Assert.IsTrue(result.IsSuccessStatusCode);
100+
string token = result.Result.token;
101+
102+
Assert.IsNotNull(result.Result.stdout);
103+
StringAssert.StartsWith(result.Result.stdout, "hello, world");
104+
105+
var del = await service.SubmissionsService.Delete(token);
106+
Assert.IsTrue(del.IsSuccessStatusCode);
107+
}
108+
109+
public async Task GetPaging()
110+
{
111+
var result = await service.SubmissionsService.GetPaging();
112+
Assert.IsTrue(result.IsSuccessStatusCode);
113+
}
114+
115+
public async Task Batch()
116+
{
117+
var result = await service.SubmissionsService.BatchCreate(new SubmissionBatch
118+
{
119+
submissions = new[]{
120+
new Submission
121+
{
122+
source_code = "#include <stdio.h>\n\nint main(void) {\n char name[10];\n scanf(\"%s\", name);\n printf(\"hello, %s\\n\", name);\n return 0;\n}",
123+
stdin = "world",
124+
language_id = 50,
125+
},
126+
new Submission
127+
{
128+
source_code = "#include <stdio.h>\n\nint main(void) {\n char name[10];\n scanf(\"%s\", name);\n printf(\"hello, %s\\n\", name);\n return 0;\n}",
129+
stdin = "world",
130+
language_id = 50,
131+
}
132+
}
133+
});
134+
Assert.IsTrue(result.IsSuccessStatusCode);
135+
var getres = await service.SubmissionsService.BatchGet(result.Result.Select(x => x.token));
136+
Assert.IsTrue(getres.IsSuccessStatusCode);
137+
}
138+
```
139+
140+
### Language
141+
142+
```csharp
143+
public async Task Get()
144+
{
145+
var result = await service.LanguagesService.Get();
146+
Assert.IsTrue(result.IsSuccessStatusCode);
147+
}
148+
149+
public async Task GetById()
150+
{
151+
var result = await service.LanguagesService.Get(50);
152+
Assert.IsTrue(result.IsSuccessStatusCode);
153+
}
154+
155+
public async Task GetAll()
156+
{
157+
var result = await service.LanguagesService.GetAll();
158+
Assert.IsTrue(result.IsSuccessStatusCode);
159+
}
160+
```
161+
162+
### Status
30163

31-
var result = await service.LanguagesService.Get();
32-
foreach(Language lang in result.Result)
164+
```csharp
165+
public async Task Get()
33166
{
34-
Console.WriteLine(lang.name);
167+
var result = await service.StatusesService.Get();
168+
Assert.IsTrue(result.IsSuccessStatusCode);
35169
}
36170
```
171+
172+
### System & Configuration & Statistics & Health Check & Information
173+
174+
```csharp
175+
public async Task GetSystemInfo()
176+
{
177+
var result = await service.SystemService.GetSystemInfo();
178+
Assert.IsTrue(result.IsSuccessStatusCode);
179+
}
180+
181+
public async Task GetAbout()
182+
{
183+
var result = await service.SystemService.GetAbout();
184+
Assert.IsTrue(result.IsSuccessStatusCode);
185+
}
186+
187+
public async Task GetConfigInfo()
188+
{
189+
var result = await service.SystemService.GetConfigInfo();
190+
Assert.IsTrue(result.IsSuccessStatusCode);
191+
}
192+
193+
public async Task GetIsolate()
194+
{
195+
var result = await service.SystemService.GetIsolate();
196+
Assert.IsTrue(result.IsSuccessStatusCode);
197+
}
198+
199+
public async Task GetLicense()
200+
{
201+
var result = await service.SystemService.GetLicense();
202+
Assert.IsTrue(result.IsSuccessStatusCode);
203+
}
204+
205+
public async Task GetStatistics()
206+
{
207+
var result = await service.SystemService.GetStatistics();
208+
Assert.IsTrue(result.IsSuccessStatusCode);
209+
}
210+
211+
public async Task GetWorkerHealthCheck()
212+
{
213+
var result = await service.SystemService.GetWorkerHealthCheck();
214+
Assert.IsTrue(result.IsSuccessStatusCode);
215+
}
216+
217+
public async Task GetVersion()
218+
{
219+
var result = await service.SystemService.GetVersion();
220+
Assert.IsTrue(result.IsSuccessStatusCode);
221+
}
222+
```

test/docker/1.5.0/docker-compose.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)