From bd981e4908f3617aafa7de681a0084c51f5b79f8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 3 May 2022 22:42:03 +0200 Subject: [PATCH] Reduce line length. --- .../TestSuite.ApiTests/AppCreationTests.cs | 5 ++- .../TestSuite.ApiTests/AssetTests.cs | 30 +++++++++++--- .../ContentReferencesTests.cs | 21 ++++++---- .../TestSuite.ApiTests/ContentUpdateTests.cs | 40 ++++++++++++++----- .../TestSuite.ApiTests/SchemaTests.cs | 5 ++- 5 files changed, 77 insertions(+), 24 deletions(-) diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs index 661a924bb..e40580dfa 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs @@ -70,7 +70,10 @@ namespace TestSuite.ApiTests // STEP 2: Create again and fail - var ex = await Assert.ThrowsAnyAsync(() => _.Apps.PostAppAsync(createRequest)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.Apps.PostAppAsync(createRequest); + }); Assert.Equal(400, ex.StatusCode); } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs index 8cc6a88a5..37573bdaa 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs @@ -148,7 +148,10 @@ namespace TestSuite.ApiTests // STEP 2: Create a new item with a custom id. - var ex = await Assert.ThrowsAnyAsync(() => _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id); + }); Assert.Equal(409, ex.StatusCode); } @@ -161,7 +164,10 @@ namespace TestSuite.ApiTests // STEP 2: Create big asset - var ex = await Assert.ThrowsAnyAsync(() => _.UploadFileAsync(10_000_000)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.UploadFileAsync(10_000_000); + }); // Client library cannot catch this exception properly. Assert.True(ex is HttpRequestException || ex is SquidexManagementException); @@ -350,7 +356,10 @@ namespace TestSuite.ApiTests // STEP 5: Download asset without key. await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) { - var ex = await Assert.ThrowsAnyAsync(() => _.DownloadAsync(asset_1)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.DownloadAsync(asset_1); + }); // Should return 403 when not authenticated. Assert.Contains("403", ex.Message, StringComparison.Ordinal); @@ -360,7 +369,10 @@ namespace TestSuite.ApiTests // STEP 6: Download asset without key and version. await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) { - var ex = await Assert.ThrowsAnyAsync(() => _.DownloadAsync(asset_1, 0)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.DownloadAsync(asset_1, 0); + }); // Should return 403 when not authenticated. Assert.Contains("403", ex.Message, StringComparison.Ordinal); @@ -468,7 +480,10 @@ namespace TestSuite.ApiTests // STEP 5: Wait for recursive deleter to delete the asset. await Task.Delay(5000); - var ex = await Assert.ThrowsAnyAsync(() => _.Assets.GetAssetAsync(_.AppName, asset_1.Id)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.Assets.GetAssetAsync(_.AppName, asset_1.Id); + }); Assert.Equal(404, ex.StatusCode); } @@ -486,7 +501,10 @@ namespace TestSuite.ApiTests await _.Assets.DeleteAssetAsync(_.AppName, asset.Id, permanent: permanent); // Should return 404 when asset deleted. - var ex = await Assert.ThrowsAnyAsync(() => _.Assets.GetAssetAsync(_.AppName, asset.Id)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.Assets.GetAssetAsync(_.AppName, asset.Id); + }); Assert.Equal(404, ex.StatusCode); diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs index 20b2cbc46..307916fb3 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs @@ -73,10 +73,12 @@ namespace TestSuite.ApiTests // STEP 3: Try to delete with referrer check. - await Assert.ThrowsAnyAsync(() => _.Contents.DeleteAsync(contentA_1.Id, new ContentDeleteOptions + var options = new ContentDeleteOptions { CheckReferrers = true }; + + await Assert.ThrowsAnyAsync(() => { - CheckReferrers = true - })); + return _.Contents.DeleteAsync(contentA_1.Id, options); + }); // STEP 4: Delete without referrer check @@ -99,17 +101,22 @@ namespace TestSuite.ApiTests // STEP 3: Try to ThrowsAnyAsync with referrer check. - await Assert.ThrowsAnyAsync(() => _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus + await Assert.ThrowsAnyAsync(() => { - Status = "Draft", - CheckReferrers = true - })); + return _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus + { + Status = "Draft", + // Ensure that the flag is true. + CheckReferrers = true + }); + }); // STEP 4: Delete without referrer check await _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus { Status = "Draft", + // It is the default anyway, just to make it more explicit. CheckReferrers = false }); } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs index 32e810709..7803f6c28 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs @@ -73,7 +73,10 @@ namespace TestSuite.ApiTests // STEP 3. Get a 404 for the item because it is not published anymore. - await Assert.ThrowsAnyAsync(() => _.Contents.GetAsync(content.Id)); + await Assert.ThrowsAnyAsync(() => + { + return _.Contents.GetAsync(content.Id); + }); } finally { @@ -106,7 +109,10 @@ namespace TestSuite.ApiTests // STEP 3. Get a 404 for the item because it is not published anymore. - await Assert.ThrowsAnyAsync(() => _.Contents.GetAsync(content.Id)); + await Assert.ThrowsAnyAsync(() => + { + return _.Contents.GetAsync(content.Id); + }); } finally { @@ -211,7 +217,10 @@ namespace TestSuite.ApiTests // STEP 2. Get a 404 for the item because it is not published. - await Assert.ThrowsAnyAsync(() => _.Contents.GetAsync(content.Id)); + await Assert.ThrowsAnyAsync(() => + { + return _.Contents.GetAsync(content.Id); + }); } finally { @@ -253,7 +262,9 @@ namespace TestSuite.ApiTests try { // STEP 1: Create a new item with a custom id. - content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, new ContentCreateOptions { Id = id, Publish = true }); + var options = new ContentCreateOptions { Id = id, Publish = true }; + + content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, options); Assert.Equal(id, content.Id); } @@ -275,13 +286,18 @@ namespace TestSuite.ApiTests try { // STEP 1: Create a new item with a custom id. - content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, new ContentCreateOptions { Id = id, Publish = true }); + var options = new ContentCreateOptions { Id = id, Publish = true }; + + content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, options); Assert.Equal(id, content.Id); // STEP 2: Create a new item with a custom id. - var ex = await Assert.ThrowsAnyAsync(() => _.Contents.CreateAsync(new TestEntityData { Number = 1 }, new ContentCreateOptions { Id = id, Publish = true })); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.Contents.CreateAsync(new TestEntityData { Number = 1 }, options); + }); Assert.Contains("\"statusCode\":409", ex.Message, StringComparison.Ordinal); } @@ -650,11 +666,15 @@ namespace TestSuite.ApiTests // STEP 2: Delete the item. - await _.Contents.DeleteAsync(content_1.Id, new ContentDeleteOptions { Permanent = permanent }); + var createOptions = new ContentDeleteOptions { Permanent = permanent }; + + await _.Contents.DeleteAsync(content_1.Id, createOptions); // STEP 3: Recreate the item with the same id. - var content_2 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, new ContentCreateOptions { Id = content_1.Id, Publish = true }); + var deleteOptions = new ContentCreateOptions { Id = content_1.Id, Publish = true }; + + var content_2 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, deleteOptions); Assert.Equal(Status.Published, content_2.Status); @@ -675,7 +695,9 @@ namespace TestSuite.ApiTests // STEP 2: Delete the item. - await _.Contents.DeleteAsync(content_1.Id, new ContentDeleteOptions { Permanent = permanent }); + var deleteOptions = new ContentDeleteOptions { Permanent = permanent }; + + await _.Contents.DeleteAsync(content_1.Id, deleteOptions); // STEP 3: Recreate the item with the same id. diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs index 6121e7098..9b648b34f 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs @@ -57,7 +57,10 @@ namespace TestSuite.ApiTests // STEP 2: Create again and fail - var ex = await Assert.ThrowsAnyAsync(() => _.Schemas.PostSchemaAsync(_.AppName, createRequest)); + var ex = await Assert.ThrowsAnyAsync(() => + { + return _.Schemas.PostSchemaAsync(_.AppName, createRequest); + }); Assert.Equal(400, ex.StatusCode); }