Skip to content

Commit f4c77dd

Browse files
committed
Set at all async method Cancellationtoken ct = default
1 parent fb3d029 commit f4c77dd

6 files changed

Lines changed: 17 additions & 17 deletions

File tree

API.Test/AuthentificationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public void Authentification()
3333
try
3434
{
3535
using WebUntisClient client = new("WebUntisAPI_TEST");
36-
client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password, CancellationToken.None).Wait();
37-
client.LogoutAsync(CancellationToken.None).Wait();
36+
client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
37+
client.LogoutAsync().Wait();
3838
}
3939
catch
4040
{

API.Test/SchoolSearchTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class SchoolSearchTests
1717
[Test]
1818
public void NormalSearch()
1919
{
20-
Task<School[]> schools = SchoolSearch.SearchAsync("Marie-Curie", CancellationToken.None);
20+
Task<School[]> schools = SchoolSearch.SearchAsync("Marie-Curie");
2121
schools.Wait();
2222
if (schools.Result.Length > 0)
2323
Assert.Pass();
@@ -29,7 +29,7 @@ public void NormalSearch()
2929
[Test]
3030
public void ToManySchoolsFound()
3131
{
32-
Task<School[]> schools = SchoolSearch.SearchAsync("M", CancellationToken.None);
32+
Task<School[]> schools = SchoolSearch.SearchAsync("M");
3333
schools.Wait();
3434
if (schools.Result == null)
3535
Assert.Pass();
@@ -41,7 +41,7 @@ public void ToManySchoolsFound()
4141
[Test]
4242
public void NoSchoolsFound()
4343
{
44-
Task<School[]> schools = SchoolSearch.SearchAsync("MMMMMMMMMMMMMMMMMMMMMMMMMMM", CancellationToken.None);
44+
Task<School[]> schools = SchoolSearch.SearchAsync("MMMMMMMMMMMMMMMMMMMMMMMMMMM");
4545
schools.Wait();
4646
if (schools.Result.Length == 0)
4747
Assert.Pass();

API.Test/UserTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public void Setup()
2727
[Order(1)]
2828
public void GetStudents()
2929
{
30-
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password, CancellationToken.None).Wait();
30+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
3131

32-
Task<Student[]> students = Client.GetAllStudentsAsync(CancellationToken.None);
32+
Task<Student[]> students = Client.GetAllStudentsAsync();
3333
students.Wait();
3434
if (students.Result.Length > 0)
3535
Assert.Pass();
@@ -41,6 +41,6 @@ public void GetStudents()
4141
[Test]
4242
public void TearUp()
4343
{
44-
Client.LogoutAsync(CancellationToken.None).Wait();
44+
Client.LogoutAsync().Wait();
4545
}
4646
}

WebUntisAPI.Client/SchoolSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static class SchoolSearch
3333
/// <returns>All schools found, an empty array when no school found or <see langword="null"/> when too many schools found</returns>
3434
/// <exception cref="WebUntisException">Throws when the WebUntis API returned an error</exception>
3535
/// <exception cref="HttpRequestException">Throws when an error happend while request</exception>
36-
public static async Task<School[]> SearchAsync(string name, CancellationToken ct, string id = "search")
36+
public static async Task<School[]> SearchAsync(string name, string id = "getStudents", CancellationToken ct = default)
3737
{
3838
// Write request content
3939
JSONRPCRequestModel<SchoolSearchModel[]> requestModel = new JSONRPCRequestModel<SchoolSearchModel[]>()

WebUntisAPI.Client/WebUntisClient.User.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class WebUntisClient
2323
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
2424
/// <exception cref="UnauthorizedAccessException">Thrown when you don't logged in</exception>
2525
/// <exception cref="HttpRequestException">Thrown when there was an error while the http request</exception>
26-
public async Task<Student[]> GetAllStudentsAsync(CancellationToken ct, string id = "getStudents")
26+
public async Task<Student[]> GetAllStudentsAsync(string id = "getStudents", CancellationToken ct = default)
2727
{
2828
if (!LoggedIn)
2929
throw new UnauthorizedAccessException("You're not logged in");

WebUntisAPI.Client/WebUntisClient.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace WebUntisAPI.Client
2121
/// </summary>
2222
/// <remarks>
2323
/// <para>
24-
/// Please use this class in a using declaration. When you dont use it in a using declaration please call <see cref="LogoutAsync(CancellationToken, string)"/> and <see cref="Dispose()"/> when you don't need the connection.
24+
/// Please use this class in a using declaration. When you dont use it in a using declaration please call <see cref="LogoutAsync(string, CancellationToken)"/> and <see cref="Dispose()"/> when you don't need the connection.
2525
/// </para>
2626
/// <para>
2727
/// Under no circumstances should 10 req. per sec., more than 1800req. per hr (but in no case more than 3600 req. per hr). If the specifications are exceeded, access to WebUntis is permanently blocked by the WebUntis API.
@@ -85,7 +85,7 @@ public WebUntisClient(string clientName, int timeout = 500)
8585
/// <summary>
8686
/// Login as a user in a school to get and write data
8787
/// </summary>
88-
/// <param name="school">The school to login (Use only returned instances from <see cref="SchoolSearch.SearchAsync(string, CancellationToken, string)"/>)</param>
88+
/// <param name="school">The school to login (Use only returned instances from <see cref="SchoolSearch.SearchAsync(string, string, CancellationToken)"/>)</param>
8989
/// <param name="username">Name of the user to login</param>
9090
/// <param name="password">Password of the user to login</param>
9191
/// <param name="ct">Cancelationtoken</param>
@@ -94,8 +94,8 @@ public WebUntisClient(string clientName, int timeout = 500)
9494
/// <exception cref="ArgumentException">The server name is invalid</exception>
9595
/// <exception cref="HttpRequestException">There was an error while the request</exception>
9696
/// <exception cref="WebUntisException">The WebUntis server returned an error</exception>
97-
public async Task<bool> LoginAsync(School school, string username, string password, CancellationToken ct, string id = "login") =>
98-
await LoginAsync(school.Server, school.LoginName, username, password, ct, id);
97+
public async Task<bool> LoginAsync(School school, string username, string password, string id = "getStudents", CancellationToken ct = default) =>
98+
await LoginAsync(school.Server, school.LoginName, username, password, id, ct);
9999

100100
/// <summary>
101101
/// Login as a user in a school to get and write data
@@ -110,7 +110,7 @@ public async Task<bool> LoginAsync(School school, string username, string passwo
110110
/// <exception cref="ArgumentException">The server name is invalid</exception>
111111
/// <exception cref="HttpRequestException">There was an error while the request</exception>
112112
/// <exception cref="WebUntisException">The WebUntis server returned an error</exception>
113-
public async Task<bool> LoginAsync(string server, string loginName, string username, string password, CancellationToken ct, string id = "login")
113+
public async Task<bool> LoginAsync(string server, string loginName, string username, string password, string id = "getStudents", CancellationToken ct = default)
114114
{
115115
// Check if you already logged in
116116
if (LoggedIn)
@@ -175,7 +175,7 @@ public async Task<bool> LoginAsync(string server, string loginName, string usern
175175
/// <param name="ct">Cancellation token</param>
176176
/// <returns>Task for the proccess</returns>
177177
/// <exception cref="HttpRequestException">There was an error while the request</exception>
178-
public async Task LogoutAsync(CancellationToken ct, string id = "logout")
178+
public async Task LogoutAsync(string id = "getStudents", CancellationToken ct = default)
179179
{
180180
// Check if you logged in
181181
if (!LoggedIn)
@@ -225,7 +225,7 @@ protected virtual void Dispose(bool disposing)
225225
{
226226
// When not manually logged out then logout
227227
if (LoggedIn)
228-
_ = LogoutAsync(CancellationToken.None);
228+
_ = LogoutAsync();
229229

230230
if (disposing)
231231
{

0 commit comments

Comments
 (0)