Browse Source

Reduce line length.

pull/878/head
Sebastian 4 years ago
parent
commit
bd981e4908
  1. 5
      backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs
  2. 30
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs
  3. 17
      backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs
  4. 40
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  5. 5
      backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs

5
backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs

@ -70,7 +70,10 @@ namespace TestSuite.ApiTests
// STEP 2: Create again and fail // STEP 2: Create again and fail
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => _.Apps.PostAppAsync(createRequest)); var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Apps.PostAppAsync(createRequest);
});
Assert.Equal(400, ex.StatusCode); Assert.Equal(400, ex.StatusCode);
} }

30
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs

@ -148,7 +148,10 @@ namespace TestSuite.ApiTests
// STEP 2: Create a new item with a custom id. // STEP 2: Create a new item with a custom id.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id)); var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id);
});
Assert.Equal(409, ex.StatusCode); Assert.Equal(409, ex.StatusCode);
} }
@ -161,7 +164,10 @@ namespace TestSuite.ApiTests
// STEP 2: Create big asset // STEP 2: Create big asset
var ex = await Assert.ThrowsAnyAsync<Exception>(() => _.UploadFileAsync(10_000_000)); var ex = await Assert.ThrowsAnyAsync<Exception>(() =>
{
return _.UploadFileAsync(10_000_000);
});
// Client library cannot catch this exception properly. // Client library cannot catch this exception properly.
Assert.True(ex is HttpRequestException || ex is SquidexManagementException); Assert.True(ex is HttpRequestException || ex is SquidexManagementException);
@ -350,7 +356,10 @@ namespace TestSuite.ApiTests
// STEP 5: Download asset without key. // STEP 5: Download asset without key.
await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open))
{ {
var ex = await Assert.ThrowsAnyAsync<HttpRequestException>(() => _.DownloadAsync(asset_1)); var ex = await Assert.ThrowsAnyAsync<HttpRequestException>(() =>
{
return _.DownloadAsync(asset_1);
});
// Should return 403 when not authenticated. // Should return 403 when not authenticated.
Assert.Contains("403", ex.Message, StringComparison.Ordinal); Assert.Contains("403", ex.Message, StringComparison.Ordinal);
@ -360,7 +369,10 @@ namespace TestSuite.ApiTests
// STEP 6: Download asset without key and version. // STEP 6: Download asset without key and version.
await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open))
{ {
var ex = await Assert.ThrowsAnyAsync<HttpRequestException>(() => _.DownloadAsync(asset_1, 0)); var ex = await Assert.ThrowsAnyAsync<HttpRequestException>(() =>
{
return _.DownloadAsync(asset_1, 0);
});
// Should return 403 when not authenticated. // Should return 403 when not authenticated.
Assert.Contains("403", ex.Message, StringComparison.Ordinal); Assert.Contains("403", ex.Message, StringComparison.Ordinal);
@ -468,7 +480,10 @@ namespace TestSuite.ApiTests
// STEP 5: Wait for recursive deleter to delete the asset. // STEP 5: Wait for recursive deleter to delete the asset.
await Task.Delay(5000); await Task.Delay(5000);
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => _.Assets.GetAssetAsync(_.AppName, asset_1.Id)); var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Assets.GetAssetAsync(_.AppName, asset_1.Id);
});
Assert.Equal(404, ex.StatusCode); Assert.Equal(404, ex.StatusCode);
} }
@ -486,7 +501,10 @@ namespace TestSuite.ApiTests
await _.Assets.DeleteAssetAsync(_.AppName, asset.Id, permanent: permanent); await _.Assets.DeleteAssetAsync(_.AppName, asset.Id, permanent: permanent);
// Should return 404 when asset deleted. // Should return 404 when asset deleted.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => _.Assets.GetAssetAsync(_.AppName, asset.Id)); var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Assets.GetAssetAsync(_.AppName, asset.Id);
});
Assert.Equal(404, ex.StatusCode); Assert.Equal(404, ex.StatusCode);

17
backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs

@ -73,10 +73,12 @@ namespace TestSuite.ApiTests
// STEP 3: Try to delete with referrer check. // STEP 3: Try to delete with referrer check.
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.DeleteAsync(contentA_1.Id, new ContentDeleteOptions var options = new ContentDeleteOptions { CheckReferrers = true };
await Assert.ThrowsAnyAsync<SquidexException>(() =>
{ {
CheckReferrers = true return _.Contents.DeleteAsync(contentA_1.Id, options);
})); });
// STEP 4: Delete without referrer check // STEP 4: Delete without referrer check
@ -99,17 +101,22 @@ namespace TestSuite.ApiTests
// STEP 3: Try to ThrowsAnyAsync with referrer check. // STEP 3: Try to ThrowsAnyAsync with referrer check.
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus
{ {
Status = "Draft", Status = "Draft",
// Ensure that the flag is true.
CheckReferrers = true CheckReferrers = true
})); });
});
// STEP 4: Delete without referrer check // STEP 4: Delete without referrer check
await _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus await _.Contents.ChangeStatusAsync(contentA_1.Id, new ChangeStatus
{ {
Status = "Draft", Status = "Draft",
// It is the default anyway, just to make it more explicit.
CheckReferrers = false CheckReferrers = false
}); });
} }

40
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. // STEP 3. Get a 404 for the item because it is not published anymore.
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Contents.GetAsync(content.Id);
});
} }
finally finally
{ {
@ -106,7 +109,10 @@ namespace TestSuite.ApiTests
// STEP 3. Get a 404 for the item because it is not published anymore. // STEP 3. Get a 404 for the item because it is not published anymore.
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Contents.GetAsync(content.Id);
});
} }
finally finally
{ {
@ -211,7 +217,10 @@ namespace TestSuite.ApiTests
// STEP 2. Get a 404 for the item because it is not published. // STEP 2. Get a 404 for the item because it is not published.
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Contents.GetAsync(content.Id);
});
} }
finally finally
{ {
@ -253,7 +262,9 @@ namespace TestSuite.ApiTests
try try
{ {
// STEP 1: Create a new item with a custom id. // 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); Assert.Equal(id, content.Id);
} }
@ -275,13 +286,18 @@ namespace TestSuite.ApiTests
try try
{ {
// STEP 1: Create a new item with a custom id. // 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); Assert.Equal(id, content.Id);
// STEP 2: Create a new item with a custom id. // STEP 2: Create a new item with a custom id.
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.CreateAsync(new TestEntityData { Number = 1 }, new ContentCreateOptions { Id = id, Publish = true })); var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Contents.CreateAsync(new TestEntityData { Number = 1 }, options);
});
Assert.Contains("\"statusCode\":409", ex.Message, StringComparison.Ordinal); Assert.Contains("\"statusCode\":409", ex.Message, StringComparison.Ordinal);
} }
@ -650,11 +666,15 @@ namespace TestSuite.ApiTests
// STEP 2: Delete the item. // 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. // 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); Assert.Equal(Status.Published, content_2.Status);
@ -675,7 +695,9 @@ namespace TestSuite.ApiTests
// STEP 2: Delete the item. // 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. // STEP 3: Recreate the item with the same id.

5
backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs

@ -57,7 +57,10 @@ namespace TestSuite.ApiTests
// STEP 2: Create again and fail // STEP 2: Create again and fail
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => _.Schemas.PostSchemaAsync(_.AppName, createRequest)); var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Schemas.PostSchemaAsync(_.AppName, createRequest);
});
Assert.Equal(400, ex.StatusCode); Assert.Equal(400, ex.StatusCode);
} }

Loading…
Cancel
Save