From 34e87a41f80f8d5bf48d44f9d19fa2bc963166fc Mon Sep 17 00:00:00 2001 From: Louis Zanella Date: Tue, 15 Oct 2024 09:46:54 -0400 Subject: [PATCH] Properly await tasks before disposing of resources (#771) Properly await tasks before disposing of resources in repository mock tests Co-authored-by: Thomas Cortes <78750681+Toa741@users.noreply.github.com> --- NGitLab.Mock.Tests/RepositoryMockTests.cs | 1 - .../UsingVerify/RepositoryMockTests.cs | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/NGitLab.Mock.Tests/RepositoryMockTests.cs b/NGitLab.Mock.Tests/RepositoryMockTests.cs index 6ce42e02..8071f84a 100644 --- a/NGitLab.Mock.Tests/RepositoryMockTests.cs +++ b/NGitLab.Mock.Tests/RepositoryMockTests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Net; using FluentAssertions; using NGitLab.Mock.Clients; using NGitLab.Models; diff --git a/NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs b/NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs index 6bec3bcc..4dfa8937 100644 --- a/NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs +++ b/NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs @@ -33,7 +33,7 @@ public void Test_get_tree_when_subdirectory_does_not_exist_throws_not_found() } [Test] - public Task Test_get_tree_item_has_id_and_mode() + public async Task Test_get_tree_item_has_id_and_mode() { // Arrange using var server = new GitLabConfig() @@ -50,11 +50,11 @@ public Task Test_get_tree_item_has_id_and_mode() var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions()); // Assert - return Verify(tree); + await Verify(tree); } [Test] - public Task Test_get_tree_item_in_sub_folder() + public async Task Test_get_tree_item_in_sub_folder() { // Arrange using var server = new GitLabConfig() @@ -72,11 +72,11 @@ public Task Test_get_tree_item_in_sub_folder() var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Path = "subFolder" }); // Assert - return Verify(tree); + await Verify(tree); } [Test] - public Task Test_get_tree_with_recurse() + public async Task Test_get_tree_with_recurse() { // Arrange using var server = new GitLabConfig() @@ -94,11 +94,11 @@ public Task Test_get_tree_with_recurse() var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Recursive = true }); // Assert - return Verify(tree); + await Verify(tree); } [Test] - public Task Test_get_tree_not_in_main_branch() + public async Task Test_get_tree_not_in_main_branch() { // Arrange using var server = new GitLabConfig() @@ -117,11 +117,11 @@ public Task Test_get_tree_not_in_main_branch() var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Ref = "feature", Recursive = true }); // Assert - return Verify(tree); + await Verify(tree); } [Test] - public Task Test_get_raw_blob_content() + public async Task Test_get_raw_blob_content() { // Arrange using var server = new GitLabConfig() @@ -143,6 +143,6 @@ public Task Test_get_raw_blob_content() repository.GetRawBlob(item.Id.ToString(), source => source.CopyTo(destination)); // Assert - return Verify(destination); + await Verify(destination); } }