Browse Source

Update client library. (#979)

* Update client library.

* Fix tests.

* Another fix.
pull/981/head
Sebastian Stehle 3 years ago
committed by GitHub
parent
commit
160a853b8c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      tools/TestSuite/TestSuite.ApiTests/AdminUsersTests.cs
  2. 42
      tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs
  3. 31
      tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs
  4. 35
      tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs
  5. 54
      tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs
  6. 59
      tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs
  7. 22
      tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs
  8. 18
      tools/TestSuite/TestSuite.ApiTests/AppTests.cs
  9. 31
      tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs
  10. 38
      tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs
  11. 116
      tools/TestSuite/TestSuite.ApiTests/AssetTests.cs
  12. 52
      tools/TestSuite/TestSuite.ApiTests/BackupTests.cs
  13. 12
      tools/TestSuite/TestSuite.ApiTests/CDNTests.cs
  14. 18
      tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs
  15. 10
      tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs
  16. 6
      tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs
  17. 22
      tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs
  18. 20
      tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs
  19. 35
      tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  20. 2
      tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs
  21. 2
      tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs
  22. 20
      tools/TestSuite/TestSuite.ApiTests/GraphQLFixture.cs
  23. 6
      tools/TestSuite/TestSuite.ApiTests/GraphQLSubscriptionTests.cs
  24. 18
      tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs
  25. 2
      tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs
  26. 2
      tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs
  27. 6
      tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs
  28. 6
      tools/TestSuite/TestSuite.ApiTests/PingTests.cs
  29. 2
      tools/TestSuite/TestSuite.ApiTests/PlansTests.cs
  30. 96
      tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs
  31. 34
      tools/TestSuite/TestSuite.ApiTests/RuleTests.cs
  32. 38
      tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs
  33. 12
      tools/TestSuite/TestSuite.ApiTests/SearchTests.cs
  34. 12
      tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
  35. 25
      tools/TestSuite/TestSuite.ApiTests/Verify/ContentUpdateTests.Should_get_content_by_version.verified.txt
  36. 3
      tools/TestSuite/TestSuite.LoadTests/ReadingBenchmarks.cs
  37. 4
      tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
  38. 34
      tools/TestSuite/TestSuite.Shared/ClientExtensions.cs
  39. 13
      tools/TestSuite/TestSuite.Shared/ClientWrapper.cs
  40. 12
      tools/TestSuite/TestSuite.Shared/Fixtures/ClientCloudFixture.cs
  41. 134
      tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs
  42. 33
      tools/TestSuite/TestSuite.Shared/Fixtures/CreatedAppFixture.cs
  43. 4
      tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaFixtureBase.cs
  44. 4
      tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaWithReferencesFixtureBase.cs
  45. 4
      tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs
  46. 4
      tools/TestSuite/TestSuite.Shared/Model/TestEntityWithReferences.cs
  47. 16
      tools/TestSuite/TestSuite.Shared/Strategies.cs
  48. 8
      tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

16
tools/TestSuite/TestSuite.ApiTests/AdminUsersTests.cs

@ -35,14 +35,14 @@ public sealed class AdminUsersTests : IClassFixture<ClientFixture>
// STEP 2: Get user by ID.
var userById = await _.UserManagement.GetUserAsync(user_0.Id);
var userById = await _.Client.UserManagement.GetUserAsync(user_0.Id);
Assert.Equal(email, userById.Email);
Assert.Equal(email, userById.DisplayName);
// STEP 2: Get users by email.
var usersByEmail = await _.UserManagement.GetUsersAsync(user_0.Email);
var usersByEmail = await _.Client.UserManagement.GetUsersAsync(user_0.Email);
Assert.Equal(email, usersByEmail.Items.First().Email);
Assert.Equal(email, usersByEmail.Items.First().DisplayName);
@ -63,7 +63,7 @@ public sealed class AdminUsersTests : IClassFixture<ClientFixture>
Email = email,
};
var user_1 = await _.UserManagement.PutUserAsync(user_0.Id, updateRequest);
var user_1 = await _.Client.UserManagement.PutUserAsync(user_0.Id, updateRequest);
Assert.Equal(updateRequest.DisplayName, user_1.DisplayName);
}
@ -76,13 +76,13 @@ public sealed class AdminUsersTests : IClassFixture<ClientFixture>
// STEP 1: Lock user.
var user_1 = await _.UserManagement.LockUserAsync(user_0.Id);
var user_1 = await _.Client.UserManagement.LockUserAsync(user_0.Id);
Assert.True(user_1.IsLocked);
// STEP 2: Unlock user.
var user_2 = await _.UserManagement.UnlockUserAsync(user_0.Id);
var user_2 = await _.Client.UserManagement.UnlockUserAsync(user_0.Id);
Assert.False(user_2.IsLocked);
}
@ -98,11 +98,11 @@ public sealed class AdminUsersTests : IClassFixture<ClientFixture>
// STEP 1: Delete user
await _.UserManagement.DeleteUserAsync(user_0.Id);
await _.Client.UserManagement.DeleteUserAsync(user_0.Id);
// STEP 2: Get user by email.
var usersByEmail = await _.UserManagement.GetUsersAsync(user_0.Email);
var usersByEmail = await _.Client.UserManagement.GetUsersAsync(user_0.Email);
Assert.Empty(usersByEmail.Items);
}
@ -118,6 +118,6 @@ public sealed class AdminUsersTests : IClassFixture<ClientFixture>
DisplayName = email,
};
return await _.UserManagement.PostUserAsync(createRequest);
return await _.Client.UserManagement.PostUserAsync(createRequest);
}
}

42
tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs

@ -17,6 +17,8 @@ namespace TestSuite.ApiTests;
[UsesVerify]
public class AnonymousTests : IClassFixture<ClientFixture>
{
private readonly string appName = Guid.NewGuid().ToString();
public ClientFixture _ { get; }
public AnonymousTests(ClientFixture fixture)
@ -27,18 +29,11 @@ public class AnonymousTests : IClassFixture<ClientFixture>
[Fact]
public async Task Should_create_app_with_anonymous_read_access()
{
var appName = Guid.NewGuid().ToString();
// STEP 1: Create app
var createRequest = new CreateAppDto
{
Name = appName
};
var app = await _.Apps.PostAppAsync(createRequest);
// STEP 1: Create app.
var (app, dto) = await _.PostAppAsync(appName);
// Should return create app with correct name.
Assert.Equal(appName, app.Name);
Assert.Equal(appName, app.Options.AppName);
// STEP 2: Make the client anonymous.
@ -47,11 +42,11 @@ public class AnonymousTests : IClassFixture<ClientFixture>
AllowAnonymous = true
};
await _.Apps.PutClientAsync(appName, "default", clientRequest);
await app.Apps.PutClientAsync("default", clientRequest);
// STEP 3: Check anonymous permission
var url = $"{_.ClientManager.Options.Url}api/apps/{appName}/settings";
var url = $"{_.Client.Options.Url}api/apps/{appName}/settings";
using (var httpClient = new HttpClient())
{
@ -60,24 +55,17 @@ public class AnonymousTests : IClassFixture<ClientFixture>
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
await Verify(app);
await Verify(dto);
}
[Fact]
public async Task Should_create_app_with_anonymous_write_access()
{
var appName = Guid.NewGuid().ToString();
// STEP 1: Create app
var createRequest = new CreateAppDto
{
Name = appName
};
var app = await _.Apps.PostAppAsync(createRequest);
// STEP 1: Create app.
var (app, dto) = await _.PostAppAsync(appName);
// Should return create app with correct name.
Assert.Equal(appName, app.Name);
Assert.Equal(appName, app.Options.AppName);
// STEP 2: Make the client anonymous.
@ -86,7 +74,7 @@ public class AnonymousTests : IClassFixture<ClientFixture>
AllowAnonymous = true
};
await _.Apps.PutClientAsync(appName, "default", clientRequest);
await app.Apps.PutClientAsync("default", clientRequest);
// STEP 3: Create schema
@ -97,11 +85,11 @@ public class AnonymousTests : IClassFixture<ClientFixture>
IsPublished = true
};
await _.Schemas.PostSchemaAsync(appName, schemaRequest);
await app.Schemas.PostSchemaAsync(schemaRequest);
// STEP 3: Create a content.
var url = $"{_.ClientManager.Options.Url}api/content/{appName}/my-content";
var url = $"{_.Client.Options.Url}api/content/{appName}/my-content";
using (var httpClient = new HttpClient())
{
@ -110,6 +98,6 @@ public class AnonymousTests : IClassFixture<ClientFixture>
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
}
await Verify(app);
await Verify(dto);
}
}

31
tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
@ -32,11 +33,11 @@ public sealed class AppClientsTests : IClassFixture<ClientFixture>
public async Task Should_create_client()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Create client.
var client = await CreateAsync();
var client = await CreateAsync(app);
// Should return client with correct name and id.
Assert.Equal(clientRole, client.Role);
@ -50,11 +51,11 @@ public sealed class AppClientsTests : IClassFixture<ClientFixture>
public async Task Should_update_client()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 0: Create client.
var client = await CreateAsync();
var client = await CreateAsync(app);
// STEP 1: Update client name.
@ -67,7 +68,7 @@ public sealed class AppClientsTests : IClassFixture<ClientFixture>
Role = "Owner"
};
var clients_2 = await _.Apps.PutClientAsync(appName, client.Id, updateNameRequest);
var clients_2 = await app.Apps.PutClientAsync(client.Id, updateNameRequest);
var client_2 = clients_2.Items.Find(x => x.Id == client.Id);
// Should update client name.
@ -85,15 +86,15 @@ public sealed class AppClientsTests : IClassFixture<ClientFixture>
public async Task Should_delete_client()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 0: Create client.
var client = await CreateAsync();
var client = await CreateAsync(app);
// STEP 1: Delete client
var clients_2 = await _.Apps.DeleteClientAsync(appName, client.Id);
var clients_2 = await app.Apps.DeleteClientAsync(client.Id);
// Should not return deleted client.
Assert.DoesNotContain(clients_2.Items, x => x.Id == client.Id);
@ -102,26 +103,16 @@ public sealed class AppClientsTests : IClassFixture<ClientFixture>
.IgnoreMember<ClientDto>(x => x.Secret);
}
private async Task<ClientDto> CreateAsync()
private async Task<ClientDto> CreateAsync(ISquidexClient app)
{
var createRequest = new CreateClientDto
{
Id = id
};
var clients = await _.Apps.PostClientAsync(appName, createRequest);
var clients = await app.Apps.PostClientAsync(createRequest);
var client = clients.Items.Find(x => x.Id == id);
return client;
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

35
tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
@ -30,7 +31,7 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
public async Task Should_not_invite_contributor_if_flag_is_false()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Do not invite contributors when flag is false.
@ -41,7 +42,7 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Apps.PostContributorAsync(appName, createRequest);
return app.Apps.PostContributorAsync(createRequest);
});
Assert.Equal(404, ex.StatusCode);
@ -51,11 +52,11 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
public async Task Should_invite_contributor()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Assign contributor.
ContributorDto contributor_1 = await InviteAsync();
ContributorDto contributor_1 = await InviteAsync(app);
Assert.Equal("Developer", contributor_1?.Role);
@ -69,11 +70,11 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
public async Task Should_update_contributor()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Assign contributor.
var contributor = await InviteAsync();
var contributor = await InviteAsync(app);
// STEP 1: Update contributor role.
@ -84,7 +85,7 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
Role = "Owner"
};
var contributors_2 = await _.Apps.PostContributorAsync(appName, updateRequest);
var contributors_2 = await app.Apps.PostContributorAsync(updateRequest);
var contributor_2 = contributors_2.Items.Find(x => x.ContributorId == contributor.ContributorId);
Assert.Equal(updateRequest.Role, contributor_2?.Role);
@ -94,22 +95,22 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
public async Task Should_remove_contributor()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Assign contributor.
var contributor = await InviteAsync();
var contributor = await InviteAsync(app);
// STEP 1: Remove contributor.
var contributors_2 = await _.Apps.DeleteContributorAsync(appName, contributor.ContributorId);
var contributors_2 = await app.Apps.DeleteContributorAsync(contributor.ContributorId);
Assert.DoesNotContain(contributors_2.Items, x => x.ContributorId == contributor.ContributorId);
await Verify(contributors_2);
}
private async Task<ContributorDto> InviteAsync()
private async Task<ContributorDto> InviteAsync(ISquidexClient app)
{
var createInviteRequest = new AssignContributorDto
{
@ -118,19 +119,9 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
Invite = true
};
var contributors = await _.Apps.PostContributorAsync(appName, createInviteRequest);
var contributors = await app.Apps.PostContributorAsync(createInviteRequest);
var contributor = contributors.Items.Find(x => x.ContributorName == email);
return contributor;
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

54
tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs

@ -29,56 +29,46 @@ public class AppCreationTests : IClassFixture<ClientFixture>
public async Task Should_create_app()
{
// STEP 1: Create app
var createRequest = new CreateAppDto
{
Name = appName
};
var app = await _.Apps.PostAppAsync(createRequest);
var (app, dto) = await _.PostAppAsync(appName);
// Should return created app with correct name.
Assert.Equal(appName, app.Name);
Assert.Equal(appName, app.Options.AppName);
// STEP 2: Get all apps
var apps = await _.Apps.GetAppsAsync();
var apps = await app.Apps.GetAppsAsync();
// Should provide new app when apps are queried.
Assert.Contains(apps, x => x.Name == appName);
// STEP 3: Check contributors
var contributors = await _.Apps.GetContributorsAsync(appName);
var contributors = await app.Apps.GetContributorsAsync();
// Should not add client itself as a contributor.
Assert.Empty(contributors.Items);
// STEP 4: Check clients
var clients = await _.Apps.GetClientsAsync(appName);
var clients = await app.Apps.GetClientsAsync();
// Should create default client.
Assert.Contains(clients.Items, x => x.Id == "default");
await Verify(app);
await Verify(dto);
}
[Fact]
public async Task Should_not_allow_creation_if_name_used()
{
// STEP 1: Create app
await CreateAppAsync();
await _.PostAppAsync(appName);
// STEP 2: Create again and fail
var createRequest = new CreateAppDto
{
Name = appName
};
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Apps.PostAppAsync(createRequest);
return _.PostAppAsync(appName);
});
Assert.Equal(400, ex.StatusCode);
@ -88,13 +78,13 @@ public class AppCreationTests : IClassFixture<ClientFixture>
public async Task Should_archive_app()
{
// STEP 1: Create app
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 2: Archive app
await _.Apps.DeleteAppAsync(appName);
await app.Apps.DeleteAppAsync();
var apps = await _.Apps.GetAppsAsync();
var apps = await app.Apps.GetAppsAsync();
// Should not provide deleted app when apps are queried.
Assert.DoesNotContain(apps, x => x.Name == appName);
@ -104,11 +94,11 @@ public class AppCreationTests : IClassFixture<ClientFixture>
public async Task Should_recreate_after_archived()
{
// STEP 1: Create app
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 2: Archive app
await _.Apps.DeleteAppAsync(appName);
await app.Apps.DeleteAppAsync();
// STEP 3: Create app again
@ -117,14 +107,14 @@ public class AppCreationTests : IClassFixture<ClientFixture>
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
await _.PostAppAsync(createRequest);
}
[Fact]
public async Task Should_create_app_from_templates()
{
// STEP 1: Get template.
var templates = await _.Templates.GetTemplatesAsync();
var templates = await _.Client.Templates.GetTemplatesAsync();
var template = templates.Items.First(x => x.IsStarter);
@ -137,24 +127,14 @@ public class AppCreationTests : IClassFixture<ClientFixture>
Template = template.Name
};
await _.Apps.PostAppAsync(createRequest);
var (app, _) = await _.PostAppAsync(createRequest);
// STEP 3: Get schemas
var schemas = await _.Schemas.GetSchemasAsync(appName);
var schemas = await app.Schemas.GetSchemasAsync();
Assert.NotEmpty(schemas.Items);
await Verify(schemas);
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

59
tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
@ -29,14 +30,14 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
public async Task Should_add_language()
{
// STEP 0: Add app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Add languages.
await AddLanguageAsync("de");
await AddLanguageAsync("it");
await AddLanguageAsync(app, "de");
await AddLanguageAsync(app, "it");
var languages_1 = await _.Apps.GetLanguagesAsync(appName);
var languages_1 = await app.Apps.GetLanguagesAsync();
Assert.Equal(new string[] { "en", "de", "it" }, languages_1.Items.Select(x => x.Iso2Code).ToArray());
@ -47,14 +48,14 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
public async Task Should_add_custom_language()
{
// STEP 0: Add app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Add languages.
await AddLanguageAsync("abc");
await AddLanguageAsync("xyz");
await AddLanguageAsync(app, "abc");
await AddLanguageAsync(app, "xyz");
var languages_1 = await _.Apps.GetLanguagesAsync(appName);
var languages_1 = await app.Apps.GetLanguagesAsync();
Assert.Equal(new string[] { "en", "abc", "xyz" }, languages_1.Items.Select(x => x.Iso2Code).ToArray());
@ -65,12 +66,12 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
public async Task Should_update_language()
{
// STEP 0: Add app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Add languages.
await AddLanguageAsync("de");
await AddLanguageAsync("it");
await AddLanguageAsync(app, "de");
await AddLanguageAsync(app, "it");
// STEP 3: Update German language.
@ -83,7 +84,7 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
IsOptional = true
};
var languages_2 = await _.Apps.PutLanguageAsync(appName, "de", updateRequest);
var languages_2 = await app.Apps.PutLanguageAsync("de", updateRequest);
var language_2_DE = languages_2.Items.Find(x => x.Iso2Code == "de");
Assert.Equal(updateRequest.Fallback, language_2_DE.Fallback);
@ -96,12 +97,12 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
public async Task Should_update_master_language()
{
// STEP 0: Add app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Add languages.
await AddLanguageAsync("de");
await AddLanguageAsync("it");
await AddLanguageAsync(app, "de");
await AddLanguageAsync(app, "it");
// STEP 2: Update Italian language.
@ -114,7 +115,7 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
IsOptional = true
};
await _.Apps.PutLanguageAsync(appName, "it", updateRequest);
await app.Apps.PutLanguageAsync("it", updateRequest);
// STEP 3: Change master language to Italian.
@ -123,7 +124,7 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
IsMaster = true
};
var languages_4 = await _.Apps.PutLanguageAsync(appName, "it", masterRequest);
var languages_4 = await app.Apps.PutLanguageAsync("it", masterRequest);
var language_4_IT = languages_4.Items.Find(x => x.Iso2Code == "it");
var language_4_EN = languages_4.Items.Find(x => x.Iso2Code == "en");
@ -145,12 +146,12 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
public async Task Should_delete_language()
{
// STEP 0: Add app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Add languages.
await AddLanguageAsync("de");
await AddLanguageAsync("it");
await AddLanguageAsync(app, "de");
await AddLanguageAsync(app, "it");
// STEP 2: Update Italian language.
@ -163,11 +164,11 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
IsOptional = true
};
await _.Apps.PutLanguageAsync(appName, "it", updateRequest);
await app.Apps.PutLanguageAsync("it", updateRequest);
// STEP 3: Remove language.
var languages_2 = await _.Apps.DeleteLanguageAsync(appName, "de");
var languages_2 = await app.Apps.DeleteLanguageAsync("de");
var language_2_IT = languages_2.Items.Find(x => x.Iso2Code == "it");
// Fallback language must be removed.
@ -178,23 +179,13 @@ public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
await Verify(languages_2);
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
private async Task AddLanguageAsync(string code)
private async Task AddLanguageAsync(ISquidexClient app, string code)
{
var createRequest = new AddLanguageDto
{
Language = code
};
await _.Apps.PostLanguageAsync(appName, createRequest);
await app.Apps.PostLanguageAsync(createRequest);
}
}

22
tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs

@ -66,7 +66,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
Permissions = new List<string> { "a", "b" }
};
var roles_2 = await _.Apps.PutRoleAsync(_.AppName, roleName, updateRequest);
var roles_2 = await _.Client.Apps.PutRoleAsync(roleName, updateRequest);
var role_2 = roles_2.Items.Find(x => x.Name == roleName);
// Should return role with correct name.
@ -89,11 +89,11 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
Id = client
};
await _.Apps.PostClientAsync(_.AppName, createClientRequest);
await _.Client.Apps.PostClientAsync(createClientRequest);
await AssignClient(roleName);
var roles_2 = await _.Apps.GetRolesAsync(_.AppName);
var roles_2 = await _.Client.Apps.GetRolesAsync();
var role_2 = roles_2.Items.Find(x => x.Name == roleName);
// Should return role with correct number of users and clients.
@ -104,7 +104,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 4: Try to delete role.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Apps.DeleteRoleAsync(_.AppName, roleName);
return _.Client.Apps.DeleteRoleAsync(roleName);
});
Assert.Equal(400, ex.StatusCode);
@ -113,7 +113,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 5: AssignClient client.
await AssignClient("Developer");
var roles_3 = await _.Apps.DeleteRoleAsync(_.AppName, roleName);
var roles_3 = await _.Client.Apps.DeleteRoleAsync(roleName);
Assert.DoesNotContain(roles_3.Items, x => x.Name == roleName);
}
@ -128,7 +128,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 2 Assign contributor.
await AssignContributor(roleName);
var roles_2 = await _.Apps.GetRolesAsync(_.AppName);
var roles_2 = await _.Client.Apps.GetRolesAsync();
var role_2 = roles_2.Items.Find(x => x.Name == roleName);
// Should return role with correct number of users and clients.
@ -139,7 +139,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 4: Try to delete role.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Apps.DeleteRoleAsync(_.AppName, roleName);
return _.Client.Apps.DeleteRoleAsync(roleName);
});
Assert.Equal(400, ex.StatusCode);
@ -148,7 +148,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 5: Remove role after contributor removed.
await AssignContributor("Developer");
var roles_3 = await _.Apps.DeleteRoleAsync(_.AppName, roleName);
var roles_3 = await _.Client.Apps.DeleteRoleAsync(roleName);
Assert.DoesNotContain(roles_3.Items, x => x.Name == roleName);
}
@ -164,7 +164,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
Invite = true
};
await _.Apps.PostContributorAsync(_.AppName, assignRequest);
await _.Client.Apps.PostContributorAsync(assignRequest);
}
private async Task AssignClient(string role = null)
@ -174,7 +174,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
Role = role
};
await _.Apps.PutClientAsync(_.AppName, client, updateRequest);
await _.Client.Apps.PutClientAsync(client, updateRequest);
}
private async Task<RoleDto> CreateRoleAsync(string name)
@ -184,7 +184,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
Name = name
};
var roles = await _.Apps.PostRoleAsync(_.AppName, createRequest);
var roles = await _.Client.Apps.PostRoleAsync(createRequest);
var role = roles.Items.Find(x => x.Name == name);
return role;

18
tools/TestSuite/TestSuite.ApiTests/AppTests.cs

@ -27,7 +27,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
public async Task Should_get_app()
{
// STEP 1: Get app.
var app = await _.Apps.GetAppAsync(_.AppName);
var app = await _.Client.Apps.GetAppAsync();
Assert.Equal(_.AppName, app.Name);
}
@ -41,7 +41,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
Label = Guid.NewGuid().ToString()
};
var app_1 = await _.Apps.PutAppAsync(_.AppName, updateRequest);
var app_1 = await _.Client.Apps.PutAppAsync(updateRequest);
Assert.Equal(updateRequest.Label, app_1.Label);
}
@ -55,7 +55,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
Description = Guid.NewGuid().ToString()
};
var app_1 = await _.Apps.PutAppAsync(_.AppName, updateRequest);
var app_1 = await _.Client.Apps.PutAppAsync(updateRequest);
Assert.Equal(updateRequest.Description, app_1.Description);
}
@ -68,7 +68,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
{
var file = new FileParameter(stream, "logo-squared.png", "image/png");
var app_1 = await _.Apps.UploadImageAsync(_.AppName, file);
var app_1 = await _.Client.Apps.UploadImageAsync(file);
// Should contain image link.
Assert.True(app_1._links.ContainsKey("image"));
@ -82,7 +82,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
var downloaded = new MemoryStream();
using (var imageStream = await _.Apps.GetImageAsync(_.AppName))
using (var imageStream = await _.Client.Apps.GetImageAsync())
{
await imageStream.Stream.CopyToAsync(downloaded);
}
@ -100,7 +100,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
{
var file = new FileParameter(stream, "logo-squared.png", "image/png");
var app_1 = await _.Apps.UploadImageAsync(_.AppName, file);
var app_1 = await _.Client.Apps.UploadImageAsync(file);
// Should contain image link.
Assert.True(app_1._links.ContainsKey("image"));
@ -108,7 +108,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
// STEP 2: Delete Image.
var app_2 = await _.Apps.DeleteImageAsync(_.AppName);
var app_2 = await _.Client.Apps.DeleteImageAsync();
// Should contain image link.
Assert.False(app_2._links.ContainsKey("image"));
@ -118,7 +118,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
public async Task Should_get_settings()
{
// STEP 1: Get initial settings.
var settings_0 = await _.Apps.GetSettingsAsync(_.AppName);
var settings_0 = await _.Client.Apps.GetSettingsAsync();
Assert.NotEmpty(settings_0.Patterns);
}
@ -139,7 +139,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
}
};
var settings_1 = await _.Apps.PutSettingsAsync(_.AppName, updateRequest);
var settings_1 = await _.Client.Apps.PutSettingsAsync(updateRequest);
Assert.NotEmpty(settings_1.Patterns);
Assert.NotEmpty(settings_1.Editors);

31
tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
@ -30,11 +31,11 @@ public sealed class AppWorkflowsTests : IClassFixture<ClientFixture>
public async Task Should_create_workflow()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Create workflow.
var workflow = await CreateAsync();
var workflow = await CreateAsync(app);
Assert.NotNull(workflow);
Assert.NotNull(workflow.Name);
@ -47,11 +48,11 @@ public sealed class AppWorkflowsTests : IClassFixture<ClientFixture>
public async Task Should_update_workflow()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 0: Create workflow.
var workflow = await CreateAsync();
var workflow = await CreateAsync(app);
// STEP 1: Update workflow.
@ -72,7 +73,7 @@ public sealed class AppWorkflowsTests : IClassFixture<ClientFixture>
Name = name
};
var workflows_2 = await _.Apps.PutWorkflowAsync(appName, workflow.Id, updateRequest);
var workflows_2 = await app.Apps.PutWorkflowAsync(workflow.Id, updateRequest);
var workflow_2 = workflows_2.Items.Find(x => x.Name == name);
Assert.NotNull(workflow_2);
@ -86,41 +87,31 @@ public sealed class AppWorkflowsTests : IClassFixture<ClientFixture>
public async Task Should_delete_workflow()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 0: Create workflow.
var workflow = await CreateAsync();
var workflow = await CreateAsync(app);
// STEP 1: Delete workflow.
var workflows_2 = await _.Apps.DeleteWorkflowAsync(appName, workflow.Id);
var workflows_2 = await app.Apps.DeleteWorkflowAsync(workflow.Id);
Assert.DoesNotContain(workflows_2.Items, x => x.Name == name);
await Verify(workflows_2);
}
private async Task<WorkflowDto> CreateAsync()
private async Task<WorkflowDto> CreateAsync(ISquidexClient app)
{
var createRequest = new AddWorkflowDto
{
Name = name
};
var workflows = await _.Apps.PostWorkflowAsync(appName, createRequest);
var workflows = await app.Apps.PostWorkflowAsync(createRequest);
var workflow = workflows.Items.Find(x => x.Name == name);
return workflow;
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

38
tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs

@ -26,7 +26,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_gif_without_extension()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_150kb.gif", "image/gif", Guid.NewGuid().ToString());
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_150kb.gif", "image/gif", Guid.NewGuid().ToString());
// Should parse image metadata.
Assert.True(asset.IsImage);
@ -45,7 +45,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_gif_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_150kb.gif", "image/gif");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_150kb.gif", "image/gif");
await AssertImageAsync(asset);
}
@ -53,7 +53,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_png_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_400kb.png", "image/png");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_400kb.png", "image/png");
await AssertImageAsync(asset);
}
@ -61,7 +61,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_jpg_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_62kb.jpg", "image/jpg");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_62kb.jpg", "image/jpg");
await AssertImageAsync(asset);
@ -71,7 +71,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_webp_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_100kb.webp", "image/jpg");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_100kb.webp", "image/jpg");
await AssertImageAsync(asset);
}
@ -79,7 +79,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_tiff_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_400kb.tiff", "image/jpg");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_400kb.tiff", "image/jpg");
await AssertImageAsync(asset);
}
@ -87,7 +87,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_tga_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_600kb.tga", "image/x-tga");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_600kb.tga", "image/x-tga");
await AssertImageAsync(asset);
}
@ -95,7 +95,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_bmp_and_resize()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_700kb.bmp", "image/bmp");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_700kb.bmp", "image/bmp");
await AssertImageAsync(asset);
}
@ -103,7 +103,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_image_bmp_and_encode_to_webp()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_700kb.bmp", "image/bmp");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleImage_700kb.bmp", "image/bmp");
var (size, type) = await GetReformattedLength(asset.Id, "WEBP");
@ -133,7 +133,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_fix_orientation()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide-rotated.jpg", "image/jpg");
var asset = await _.Client.Assets.UploadFileAsync("Assets/logo-wide-rotated.jpg", "image/jpg");
// Should parse image metadata and fix orientation.
Assert.True(asset.IsImage);
@ -150,7 +150,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_audio_mp3()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleAudio_0.4mb.mp3", "audio/mp3");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleAudio_0.4mb.mp3", "audio/mp3");
// Should parse audio metadata.
Assert.False(asset.IsImage);
@ -166,7 +166,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_video_mp4()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.mp4", "audio/mp4");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.mp4", "audio/mp4");
// Should parse video metadata.
Assert.False(asset.IsImage);
@ -184,7 +184,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_video_mkv()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.flv", "audio/webm");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.flv", "audio/webm");
// Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type);
@ -195,7 +195,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_video_flv()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.flv", "audio/x-flv");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.flv", "audio/x-flv");
// Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type);
@ -206,7 +206,7 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_upload_video_3gp()
{
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_176x144_1mb.3gp", "audio/3gpp");
var asset = await _.Client.Assets.UploadFileAsync("Assets/SampleVideo_176x144_1mb.3gp", "audio/3gpp");
// Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type);
@ -216,9 +216,9 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
private async Task<long> GetResizedLengthAsync(string imageId, int width, int height)
{
var url = $"{_.ClientManager.GenerateImageUrl(imageId)}?width={width}&height={height}";
var url = $"{_.Client.GenerateImageUrl(imageId)}?width={width}&height={height}";
var httpClient = _.ClientManager.CreateHttpClient();
var httpClient = _.Client.CreateHttpClient();
var response = await httpClient.GetAsync(url);
@ -234,9 +234,9 @@ public class AssetFormatTests : IClassFixture<CreatedAppFixture>
private async Task<(long, string)> GetReformattedLength(string imageId, string format)
{
var url = $"{_.ClientManager.GenerateImageUrl(imageId)}?format={format}";
var url = $"{_.Client.GenerateImageUrl(imageId)}?format={format}";
var httpClient = _.ClientManager.CreateHttpClient();
var httpClient = _.Client.CreateHttpClient();
var response = await httpClient.GetAsync(url);

116
tools/TestSuite/TestSuite.ApiTests/AssetTests.cs

@ -31,7 +31,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_upload_asset()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open))
{
@ -52,7 +52,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
await using (fileParameter.Data)
{
await _.Assets.UploadAssetAsync(_.AppName, fileParameter, progress.AsOptions());
await _.Client.Assets.UploadAssetAsync(fileParameter, progress.AsOptions());
}
Assert.Null(progress.Exception);
@ -101,7 +101,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
var id = Guid.NewGuid().ToString();
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id);
Assert.Equal(id, asset_1.Id);
@ -116,7 +116,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
// STEP 1: Create asset
var fileParameter = FileParameter.FromPath("Assets/logo-squared.png");
await _.Assets.UploadAssetAsync(_.AppName, fileParameter, progress.AsOptions(id));
await _.Client.Assets.UploadAssetAsync(fileParameter, progress.AsOptions(id));
Assert.Equal(id, progress.Asset?.Id);
}
@ -127,13 +127,13 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
var id = Guid.NewGuid().ToString();
// STEP 1: Create asset
await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id);
// STEP 2: Create a new item with a custom id.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
return _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id);
});
Assert.Equal(409, ex.StatusCode);
@ -143,13 +143,13 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_not_create_very_big_asset()
{
// STEP 1: Create small asset
await _.Assets.UploadRandomFileAsync(_.AppName, 1_000_000);
await _.Client.Assets.UploadRandomFileAsync(1_000_000);
// STEP 2: Create big asset
var ex = await Assert.ThrowsAnyAsync<Exception>(() =>
{
return _.Assets.UploadRandomFileAsync(_.AppName, 10_000_000);
return _.Client.Assets.UploadRandomFileAsync(10_000_000);
});
// Client library cannot catch this exception properly.
@ -160,11 +160,11 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_replace_asset()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset
var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", asset_1);
var asset_2 = await _.Client.Assets.UploadFileAsync("Assets/logo-wide.png", asset_1);
await using (var stream = new FileStream("Assets/logo-wide.png", FileMode.Open))
{
@ -181,7 +181,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_replace_asset_using_tus()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset
@ -189,7 +189,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
await using (fileParameter.Data)
{
await _.Assets.UploadAssetAsync(_.AppName, fileParameter, progress.AsOptions(asset_1.Id));
await _.Client.Assets.UploadAssetAsync(fileParameter, progress.AsOptions(asset_1.Id));
}
Assert.Null(progress.Exception);
@ -211,7 +211,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
for (var i = 0; i < 1; i++)
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset
@ -240,7 +240,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_annote_asset_file_name()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Annotate file name.
@ -249,7 +249,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
FileName = "My Image"
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, fileNameRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, fileNameRequest);
// Should provide updated file name.
Assert.Equal(fileNameRequest.FileName, asset_2.FileName);
@ -261,7 +261,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_annote_asset_metadata()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Annotate metadata.
@ -274,7 +274,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
}
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, metadataRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, metadataRequest);
// Should provide metadata.
Assert.Equal(metadataRequest.Metadata, asset_2.Metadata);
@ -286,7 +286,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_annote_asset_slug()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Annotate slug.
@ -295,7 +295,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
Slug = "my-image"
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, slugRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, slugRequest);
// Should provide updated slug.
Assert.Equal(slugRequest.Slug, asset_2.Slug);
@ -307,7 +307,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_annote_asset_tags()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Annotate tags.
@ -320,7 +320,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
}
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, tagsRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, tagsRequest);
// Should provide updated tags.
Assert.Equal(tagsRequest.Tags, asset_2.Tags);
@ -332,7 +332,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_annotate_asset_in_parallel()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 3: Make parallel upserts.
@ -352,7 +352,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
}
};
await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, randomMetadataRequest);
await _.Client.Assets.PutAssetAsync(asset_1.Id, randomMetadataRequest);
}
catch (SquidexManagementException ex) when (ex.StatusCode is 409 or 412)
{
@ -374,11 +374,11 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
}
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, metadataRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, metadataRequest);
// STEP 4: Check tags
var tags = await _.Assets.WaitForTagsAsync(_.AppName, tag1, TimeSpan.FromMinutes(2));
var tags = await _.Client.Assets.WaitForTagsAsync(tag1, TimeSpan.FromMinutes(2));
Assert.Contains(tag1, tags);
Assert.Contains(tag2, tags);
@ -394,7 +394,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_protect_asset()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Download asset
@ -413,7 +413,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
IsProtected = true
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, protectRequest);
var asset_2 = await _.Client.Assets.PutAssetAsync(asset_1.Id, protectRequest);
// STEP 5: Download asset with authentication.
@ -421,7 +421,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
{
var downloaded = new MemoryStream();
using (var assetStream = await _.Assets.GetAssetContentBySlugAsync(_.AppName, asset_2.Id, string.Empty))
using (var assetStream = await _.Client.Assets.GetAssetContentBySlugAsync(asset_2.Id, string.Empty))
{
await assetStream.Stream.CopyToAsync(downloaded);
}
@ -470,7 +470,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
Name = appName
};
await _.Apps.PostAppAsync(appRequest);
await _.PostAppAsync(appRequest);
// STEP 1: Create folder.
@ -479,11 +479,11 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
FolderName = "folder"
};
var folder = await _.Assets.PostAssetFolderAsync(appName, folderRequest);
var folder = await _.Client.Assets.PostAssetFolderAsync(folderRequest);
// STEP 2: Create asset
var asset_1 = await _.Assets.UploadFileAsync(appName, "Assets/logo-squared.png", "image/png", parentId: folder.Id);
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", parentId: folder.Id);
// STEP 3: Download asset
@ -505,7 +505,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
}}"
};
await _.Apps.PutAssetScriptsAsync(appName, scriptsRequest);
await _.Client.Apps.PutAssetScriptsAsync(scriptsRequest);
// STEP 5: Download asset.
@ -527,11 +527,11 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_query_asset_by_metadata()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Query asset by pixel width.
var assets_1 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery
var assets_1 = await _.Client.Assets.GetAssetsAsync(new AssetQuery
{
Filter = "metadata/pixelWidth eq 600"
});
@ -542,14 +542,14 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
// STEP 3: Add custom metadata.
asset_1.Metadata["custom"] = "foo";
await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, new AnnotateAssetDto
await _.Client.Assets.PutAssetAsync(asset_1.Id, new AnnotateAssetDto
{
Metadata = asset_1.Metadata
});
// STEP 4: Query asset by custom metadata
var assets_2 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery
var assets_2 = await _.Client.Assets.GetAssetsAsync(new AssetQuery
{
Filter = "metadata/custom eq 'foo'"
});
@ -561,11 +561,11 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_query_asset_by_root_folder()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Query asset by root folder.
var assets_1 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery
var assets_1 = await _.Client.Assets.GetAssetsAsync(new AssetQuery
{
ParentId = Guid.Empty.ToString()
});
@ -582,15 +582,15 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
FolderName = "sub"
};
var folder = await _.Assets.PostAssetFolderAsync(_.AppName, folderRequest);
var folder = await _.Client.Assets.PostAssetFolderAsync(folderRequest);
// STEP 1: Create asset in folder
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", parentId: folder.Id);
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", parentId: folder.Id);
// STEP 2: Query asset by root folder.
var assets_1 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery
var assets_1 = await _.Client.Assets.GetAssetsAsync(new AssetQuery
{
ParentId = folder.Id
});
@ -607,7 +607,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
FolderName = "folder1"
};
var folder_1 = await _.Assets.PostAssetFolderAsync(_.AppName, createRequest1);
var folder_1 = await _.Client.Assets.PostAssetFolderAsync(createRequest1);
// STEP 2: Create nested asset folder
@ -618,25 +618,25 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
ParentId = folder_1.Id
};
var folder_2 = await _.Assets.PostAssetFolderAsync(_.AppName, createRequest2);
var folder_2 = await _.Client.Assets.PostAssetFolderAsync(createRequest2);
// STEP 3: Create asset in folder
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", null, folder_2.Id);
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", null, folder_2.Id);
// STEP 4: Create asset outside folder
var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_2 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 5: Delete folder.
await _.Assets.DeleteAssetFolderAsync(_.AppName, folder_1.Id);
await _.Client.Assets.DeleteAssetFolderAsync(folder_1.Id);
// Ensure that asset in folder is deleted.
Assert.True(await _.Assets.WaitForDeletionAsync(_.AppName, asset_1.Id, TimeSpan.FromSeconds(30)));
Assert.True(await _.Client.Assets.WaitForDeletionAsync(asset_1.Id, TimeSpan.FromSeconds(30)));
// Ensure that other asset is not deleted.
Assert.NotNull(await _.Assets.GetAssetAsync(_.AppName, asset_2.Id));
Assert.NotNull(await _.Client.Assets.GetAssetAsync(asset_2.Id));
}
[Theory]
@ -645,29 +645,29 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_delete_asset(bool permanent)
{
// STEP 1: Create asset
var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Delete asset
await _.Assets.DeleteAssetAsync(_.AppName, asset.Id, permanent: permanent);
await _.Client.Assets.DeleteAssetAsync(asset.Id, permanent: permanent);
// Should return 404 when asset deleted.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Assets.GetAssetAsync(_.AppName, asset.Id);
return _.Client.Assets.GetAssetAsync(asset.Id);
});
Assert.Equal(404, ex.StatusCode);
// STEP 3: Retrieve all items and ensure that the deleted item does not exist.
var updated = await _.Assets.GetAssetsAsync(_.AppName, (AssetQuery)null);
var updated = await _.Client.Assets.GetAssetsAsync((AssetQuery)null);
Assert.DoesNotContain(updated.Items, x => x.Id == asset.Id);
// STEP 4: Retrieve all deleted items and check if found.
var deleted = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery
var deleted = await _.Client.Assets.GetAssetsAsync(new AssetQuery
{
Filter = "isDeleted eq true"
});
@ -681,15 +681,15 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
public async Task Should_recreate_deleted_asset(bool permanent)
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var asset_1 = await _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png");
// STEP 2: Delete asset
await _.Assets.DeleteAssetAsync(_.AppName, asset_1.Id, permanent: permanent);
await _.Client.Assets.DeleteAssetAsync(asset_1.Id, permanent: permanent);
// STEP 3: Recreate asset
var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", "image/png");
var asset_2 = await _.Client.Assets.UploadFileAsync("Assets/logo-wide.png", "image/png");
Assert.NotEqual(asset_1.FileSize, asset_2.FileSize);
}
@ -710,7 +710,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
{
pausingStream.Reset();
await _.Assets.UploadAssetAsync(_.AppName, pausingFile, progress.AsOptions(id), cts.Token);
await _.Client.Assets.UploadAssetAsync(pausingFile, progress.AsOptions(id), cts.Token);
progress.Uploaded();
}
}
@ -824,7 +824,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
if (remaining < buffer.Length)
{
buffer = buffer[.. (int)remaining];
buffer = buffer[..(int)remaining];
}
var bytesRead = await base.ReadAsync(buffer, cancellationToken);

52
tools/TestSuite/TestSuite.ApiTests/BackupTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
using TestSuite.Model;
@ -18,6 +19,7 @@ namespace TestSuite.ApiTests;
public class BackupTests : IClassFixture<ClientFixture>
{
private readonly string appName = Guid.NewGuid().ToString();
private readonly string appNameRestore = $"{Guid.NewGuid()}-restore";
private readonly string schemaName = $"schema-{Guid.NewGuid()}";
public ClientFixture _ { get; }
@ -33,25 +35,18 @@ public class BackupTests : IClassFixture<ClientFixture>
// Load the backup from another URL, because the public URL is might not be accessible for the server.
var backupUrl = TestHelpers.GetAndPrintValue("config:backupUrl", _.Url);
var appNameRestore = $"{appName}-restore";
// STEP 1: Create app
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
var (app, _) = await _.PostAppAsync(appName);
// STEP 2: Prepare app.
await PrepareAppAsync(appName);
await PrepareAppAsync(app);
// STEP 3: Create backup
await _.Backups.PostBackupAsync(appName);
await app.Backups.PostBackupAsync();
var backups = await _.Backups.WaitForBackupsAsync(appName, x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backups = await app.Backups.WaitForBackupsAsync(x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backup = backups.FirstOrDefault(x => x.Status is JobStatus.Completed or JobStatus.Failed);
Assert.Equal(JobStatus.Completed, backup?.Status);
@ -67,11 +62,11 @@ public class BackupTests : IClassFixture<ClientFixture>
Name = appNameRestore
};
await _.Backups.PostRestoreJobAsync(restoreRequest);
await _.Client.Backups.PostRestoreJobAsync(restoreRequest);
// STEP 5: Wait for the backup.
var restore = await _.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var restore = await app.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
Assert.Equal(JobStatus.Completed, restore?.Status);
}
@ -83,29 +78,24 @@ public class BackupTests : IClassFixture<ClientFixture>
var backupUrl = TestHelpers.GetAndPrintValue("config:backupUrl", _.Url);
// STEP 1: Create app
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
var (app, _) = await _.PostAppAsync(appNameRestore);
// STEP 2: Prepare app.
await PrepareAppAsync(appName);
await PrepareAppAsync(app);
// STEP 3: Create backup
await _.Backups.PostBackupAsync(appName);
await app.Backups.PostBackupAsync();
var backups = await _.Backups.WaitForBackupsAsync(appName, x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backups = await app.Backups.WaitForBackupsAsync(x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backup = backups.FirstOrDefault(x => x.Status is JobStatus.Completed or JobStatus.Failed);
Assert.Equal(JobStatus.Completed, backup?.Status);
// STEP 4: Delete app
await _.Apps.DeleteAppAsync(appName);
await app.Apps.DeleteAppAsync();
// STEP 5: Restore backup
@ -118,21 +108,21 @@ public class BackupTests : IClassFixture<ClientFixture>
Name = appName
};
await _.Backups.PostRestoreJobAsync(restoreRequest);
await app.Backups.PostRestoreJobAsync(restoreRequest);
// STEP 6: Wait for the backup.
var restore = await _.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var restore = await app.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
Assert.Equal(JobStatus.Completed, restore?.Status);
}
private async Task PrepareAppAsync(string appName)
private async Task PrepareAppAsync(ISquidexClient app)
{
// Create a test schema.
await TestEntity.CreateSchemaAsync(_.Schemas, appName, schemaName);
await TestEntity.CreateSchemaAsync(app.Schemas, schemaName);
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(appName, schemaName);
var contents = app.Contents<TestEntity, TestEntityData>(schemaName);
await contents.CreateAsync(new TestEntityData
{
@ -147,7 +137,7 @@ public class BackupTests : IClassFixture<ClientFixture>
{
var upload = new FileParameter(stream, fileInfo.Name, "image/png");
await _.Assets.PostAssetAsync(appName, file: upload);
await app.Assets.PostAssetAsync(file: upload);
}
@ -157,7 +147,7 @@ public class BackupTests : IClassFixture<ClientFixture>
Name = appName
};
await _.Apps.PostWorkflowAsync(appName, workflowRequest);
await app.Apps.PostWorkflowAsync(workflowRequest);
// Create a language
@ -166,6 +156,6 @@ public class BackupTests : IClassFixture<ClientFixture>
Language = "de"
};
await _.Apps.PostLanguageAsync(appName, languageRequest);
await app.Apps.PostLanguageAsync(languageRequest);
}
}

12
tools/TestSuite/TestSuite.ApiTests/CDNTests.cs

@ -27,7 +27,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
{
var id = "ef4286f9-8b1d-4dda-bd52-c5bd191c47bb";
var url = _.CDNClientManager.GenerateImageUrl(id);
var url = _.CDNClient.GenerateImageUrl(id);
Assert.StartsWith("https://assets.squidex.io/", url, StringComparison.Ordinal);
}
@ -37,7 +37,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
{
var id = "ef4286f9-8b1d-4dda-bd52-c5bd191c47bb";
var url = _.CDNClientManager.GenerateImageUrl(id);
var url = _.CDNClient.GenerateImageUrl(id);
await DownloadAsync(url);
}
@ -47,7 +47,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
{
var id = "ef4286f9-8b1d-4dda-bd52-c5bd191c47bb";
var url = _.ClientManager.GenerateImageUrl(id);
var url = _.CloudClient.GenerateImageUrl(id);
Assert.StartsWith("https://cloud.squidex.io/", url, StringComparison.Ordinal);
}
@ -57,7 +57,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
{
var id = "ef4286f9-8b1d-4dda-bd52-c5bd191c47bb";
var url = _.ClientManager.GenerateImageUrl(id);
var url = _.CloudClient.GenerateImageUrl(id);
await DownloadAsync(url);
}
@ -65,7 +65,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
[Fact]
public async Task Should_get_blog_items_from_cdn()
{
var client = _.CDNClientManager.CreateContentsClient<TestEntity, TestEntityData>("blog");
var client = _.CDNClient.Contents<TestEntity, TestEntityData>("blog");
var result = await client.GetAsync();
@ -75,7 +75,7 @@ public class CDNTests : IClassFixture<ClientCloudFixture>
[Fact]
public async Task Should_get_blog_items_from_cloud_when_cdn_not_configured()
{
var client = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>("blog");
var client = _.CloudClient.Contents<TestEntity, TestEntityData>("blog");
var result = await client.GetAsync();

18
tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs

@ -28,7 +28,7 @@ public class CommentsTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_make_watch_request()
{
var result = await _.Comments.GetWatchingUsersAsync(_.AppName, resource);
var result = await _.Client.Comments.GetWatchingUsersAsync(resource);
Assert.NotNull(result);
}
@ -42,11 +42,11 @@ public class CommentsTests : IClassFixture<CreatedAppFixture>
Text = resource
};
await _.Comments.PostCommentAsync(_.AppName, resource, createRequest);
await _.Client.Comments.PostCommentAsync(resource, createRequest);
// STEP 2: Get comments
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource);
var comments = await _.Client.Comments.GetCommentsAsync(resource);
Assert.Contains(comments.CreatedComments, x => x.Text == createRequest.Text);
@ -63,7 +63,7 @@ public class CommentsTests : IClassFixture<CreatedAppFixture>
Text = resource
};
var comment = await _.Comments.PostCommentAsync(_.AppName, resource, createRequest);
var comment = await _.Client.Comments.PostCommentAsync(resource, createRequest);
// STEP 2: Update comment.
@ -72,11 +72,11 @@ public class CommentsTests : IClassFixture<CreatedAppFixture>
Text = $"{resource}_Update"
};
await _.Comments.PutCommentAsync(_.AppName, resource, comment.Id, updateRequest);
await _.Client.Comments.PutCommentAsync(resource, comment.Id, updateRequest);
// STEP 3: Get comments since create.
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0);
var comments = await _.Client.Comments.GetCommentsAsync(resource, 0);
Assert.Contains(comments.UpdatedComments, x => x.Text == updateRequest.Text);
@ -93,15 +93,15 @@ public class CommentsTests : IClassFixture<CreatedAppFixture>
Text = resource
};
var comment = await _.Comments.PostCommentAsync(_.AppName, resource, createRequest);
var comment = await _.Client.Comments.PostCommentAsync(resource, createRequest);
// STEP 2: Delete comment.
await _.Comments.DeleteCommentAsync(_.AppName, resource, comment.Id);
await _.Client.Comments.DeleteCommentAsync(resource, comment.Id);
// STEP 3: Get comments since create.
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0);
var comments = await _.Client.Comments.GetCommentsAsync(resource, 0);
Assert.Contains(comment.Id, comments.DeletedComments);

10
tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs

@ -29,9 +29,9 @@ public class ContentCleanupTests : IClassFixture<CreatedAppFixture>
public async Task Should_cleanup_old_data_from_update_response()
{
// STEP 1: Create a schema.
var schema = await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName);
var schema = await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName);
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
// STEP 2: Create a content for this schema.
@ -44,7 +44,7 @@ public class ContentCleanupTests : IClassFixture<CreatedAppFixture>
// STEP 3: Delete a field from schema.
await _.Schemas.DeleteFieldAsync(_.AppName, schema.Name, schema.Fields.First(x => x.Name == TestEntityData.StringField).FieldId);
await _.Client.Schemas.DeleteFieldAsync(schema.Name, schema.Fields.First(x => x.Name == TestEntityData.StringField).FieldId);
// STEP 4: Make any update.
@ -61,9 +61,9 @@ public class ContentCleanupTests : IClassFixture<CreatedAppFixture>
public async Task Should_cleanup_old_references()
{
// STEP 1: Create a schema.
await TestEntityWithReferences.CreateSchemaAsync(_.Schemas, _.AppName, schemaName);
await TestEntityWithReferences.CreateSchemaAsync(_.Client.Schemas, schemaName);
var contents = _.ClientManager.CreateContentsClient<TestEntityWithReferences, TestEntityWithReferencesData>(schemaName);
var contents = _.Client.Contents<TestEntityWithReferences, TestEntityWithReferencesData>(schemaName);
// STEP 2: Create a referenced content.

6
tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs

@ -58,7 +58,7 @@ public class ContentLanguageTests : IClassFixture<ContentFixture>
// STEP 2: Get content.
var contents = _.ClientManager.CreateDynamicContentsClient(_.Contents.SchemaName);
var contents = _.Client.DynamicContents(_.Contents.SchemaName);
var contentFlatten = await contents.GetAsync(content.Id, QueryContext.Default.Flatten().WithLanguages(code));
@ -113,9 +113,9 @@ public class ContentLanguageTests : IClassFixture<ContentFixture>
private async Task<(string, string)> GetEtagAsync(string id, Dictionary<string, string> headers)
{
var url = $"{_.ClientManager.Options.Url}api/content/{_.AppName}/{_.SchemaName}/{id}";
var url = $"{_.Client.Options.Url}api/content/{_.AppName}/{_.SchemaName}/{id}";
var httpClient = _.ClientManager.CreateHttpClient();
var httpClient = _.Client.CreateHttpClient();
foreach (var (key, value) in headers)
{

22
tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs

@ -31,9 +31,9 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
{
var schemaName = $"schema-{Guid.NewGuid()}";
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName);
var contentClient = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contentClient = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var contentItems = await contentClient.GetAsync();
Assert.Equal(0, contentItems.Total);
@ -55,7 +55,6 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
foreach (var item in items_1.Items)
{
Assert.Equal(_.AppName, item.AppName);
Assert.Equal(_.SchemaName, item.SchemaName);
}
}
@ -68,14 +67,13 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
var items_0 = await _.Contents.GetAsync(q);
var itemsIds = items_0.Items.Take(3).Select(x => x.Id).ToHashSet();
var items_1 = await _.SharedContents.GetAsync(itemsIds);
var items_1 = await _.Client.SharedDynamicContents.GetAsync(itemsIds);
Assert.Equal(3, items_1.Items.Count);
Assert.Equal(3, items_1.Total);
foreach (var item in items_1.Items)
{
Assert.Equal(_.AppName, item.AppName);
Assert.Equal(_.SchemaName, item.SchemaName);
}
}
@ -528,7 +526,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JObject>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JObject>(query);
var value = result["createMyReadsContent"]["data"]["number"]["iv"].Value<int>();
@ -563,7 +561,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}
};
var result = await _.SharedContents.GraphQlAsync<JObject>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JObject>(query);
var value = result["createMyReadsContent"]["data"]["number"]["iv"].Value<int>();
@ -611,7 +609,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}
};
var results = await _.SharedContents.GraphQlAsync<QueryResult>(new[] { query1, query2 });
var results = await _.Client.SharedDynamicContents.GraphQlAsync<QueryResult>(new[] { query1, query2 });
var items1 = results.ElementAt(0).Data.Items;
var items2 = results.ElementAt(1).Data.Items;
@ -642,7 +640,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}
};
var result = await _.SharedContents.GraphQlAsync<QueryResult>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<QueryResult>(query);
var items = result.Items;
Assert.Equal(items.Select(x => x.Data.Number).ToArray(), new[] { 4, 5, 6 });
@ -670,7 +668,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}
};
var result = await _.SharedContents.GraphQlGetAsync<QueryResult>(query);
var result = await _.Client.SharedDynamicContents.GraphQlGetAsync<QueryResult>(query);
var items = result.Items;
Assert.Equal(items.Select(x => x.Data.Number).ToArray(), new[] { 4, 5, 6 });
@ -694,7 +692,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JObject>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JObject>(query);
var items = result["queryMyReadsContents"];
Assert.Equal(items.Select(x => x["data"]["number"]["iv"].Value<int>()).ToArray(), new[] { 4, 5, 6 });
@ -722,7 +720,7 @@ public class ContentQueryTests : IClassFixture<ContentQueryFixture>
}
};
await _.SharedContents.GraphQlAsync<QueryResult>(query);
await _.Client.SharedDynamicContents.GraphQlAsync<QueryResult>(query);
}
private sealed class QueryResult

20
tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs

@ -37,11 +37,11 @@ public class ContentScriptingTests : IClassFixture<CreatedAppFixture>
};
// STEP 1: Create a schema.
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName, scripts);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName, scripts);
// STEP 2: Create content
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var content = await contents.CreateAsync(new TestEntityData
{
@ -62,11 +62,11 @@ public class ContentScriptingTests : IClassFixture<CreatedAppFixture>
};
// STEP 1: Create a schema.
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName, scripts);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName, scripts);
// STEP 2: Create content
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var content = await contents.CreateAsync(new TestEntityData
{
@ -89,11 +89,11 @@ public class ContentScriptingTests : IClassFixture<CreatedAppFixture>
};
// STEP 1: Create a schema.
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName, scripts);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName, scripts);
// STEP 2: Create content
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var content = await contents.CreateAsync(new TestEntityData
{
@ -114,11 +114,11 @@ public class ContentScriptingTests : IClassFixture<CreatedAppFixture>
replace()"
};
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName, scripts);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName, scripts);
// STEP 2: Create content with a value that triggers the schema.
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var results = await contents.BulkUpdateAsync(new BulkUpdate
{
@ -162,11 +162,11 @@ public class ContentScriptingTests : IClassFixture<CreatedAppFixture>
replace()"
};
await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName, scripts);
await TestEntity.CreateSchemaAsync(_.Client.Schemas, schemaName, scripts);
// STEP 1: Create content with a value that triggers the schema.
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(schemaName);
var contents = _.Client.Contents<TestEntity, TestEntityData>(schemaName);
var results = await contents.BulkUpdateAsync(new BulkUpdate
{

35
tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

@ -7,6 +7,7 @@
using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.EnrichedEvents;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
@ -347,7 +348,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Update with selected strategy.
await _.ClientManager.UpdateAsync(content, new TestEntityData
await _.Client.UpdateAsync(content, new TestEntityData
{
Number = 200
}, strategy);
@ -377,7 +378,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Update with selected strategy.
await _.ClientManager.UpdateAsync(content, new TestEntityData
await _.Client.UpdateAsync(content, new TestEntityData
{
String = null
}, strategy);
@ -404,7 +405,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Patch with selected strategy.
await _.ClientManager.PatchAsync(content, new TestEntityData
await _.Client.PatchAsync(content, new TestEntityData
{
Number = 200
}, strategy);
@ -434,7 +435,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Patch with selected strategy.
await _.ClientManager.PatchAsync(content, new TestEntityData
await _.Client.PatchAsync(content, new TestEntityData
{
Id = "id2"
}, strategy);
@ -461,7 +462,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Patch with selected strategy.
await _.ClientManager.PatchAsync(content, new
await _.Client.PatchAsync(content, new
{
@string = new { iv = (string)null }
}, strategy);
@ -486,7 +487,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Delete with selected strategy.
await _.ClientManager.DeleteAsync(content, strategy);
await _.Client.DeleteAsync(content, strategy);
// STEP 3: Retrieve all items and ensure that the deleted item does not exist.
@ -524,7 +525,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Delete with selected strategy.
await _.ClientManager.DeleteAsync(content, strategy);
await _.Client.DeleteAsync(content, strategy);
// STEP 3: Retrieve all items and ensure that the deleted item does not exist.
@ -548,7 +549,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Delete with selected strategy.
await _.ClientManager.DeleteAsync(content_1, strategy);
await _.Client.DeleteAsync(content_1, strategy);
// STEP 3: Recreate the item with the same id.
@ -585,7 +586,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 2: Delete with selected strategy.
await _.ClientManager.DeleteAsync(content_1, strategy);
await _.Client.DeleteAsync(content_1, strategy);
// STEP 3: Recreate the item with the same id.
@ -629,7 +630,7 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 3: Permanently delete content with custom id again.
await _.ClientManager.DeleteAsync(content_2, strategy);
await _.Client.DeleteAsync(content_2, strategy);
}
[Fact]
@ -653,10 +654,10 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
}
};
await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
await _.Client.Schemas.PostSchemaAsync(createRequest);
var client = _.ClientManager.CreateDynamicContentsClient(schemaName);
var client = _.Client.DynamicContents(schemaName);
// STEP 2: Get content.
var content_1 = await client.GetAsync("_schemaId_");
@ -702,17 +703,17 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
// STEP 4: Get current version.
var data_2 = await _.Contents.GetDataAsync(content.Id, content.Version);
var content_2 = await _.Contents.GetAsync(content.Id, content.Version);
Assert.Equal(2, data_2.Number);
Assert.Equal(2, content_2.Data.Number);
// STEP 4: Get previous version
var data_1 = await _.Contents.GetDataAsync(content.Id, content.Version - 1);
var content_1 = await _.Contents.GetAsync(content.Id, content.Version - 1);
Assert.Equal(1, data_1.Number);
Assert.Equal(1, content_1.Data.Number);
await Verify(data_1);
await Verify(content_1);
}
[Fact]

2
tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs

@ -23,6 +23,6 @@ public class DiagnosticsTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_create_gc_dump()
{
await _.Diagnostics.GetGCDumpAsync();
await _.Client.Diagnostics.GetGCDumpAsync();
}
}

2
tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs

@ -50,7 +50,7 @@ public sealed class FrontendTests : IClassFixture<ClientFixture>
await using var page = await browser.NewPageAsync();
await page.GoToAsync(_.ClientManager.Options.Url + url + "?skip-setup");
await page.GoToAsync(_.Client.Options.Url + url + "?skip-setup");
await page.ScreenshotAsync($"__{name}.jpg");
var diff = ImageSharpCompare.CalcDiff($"__{name}.jpg", $"Assets/{name}.jpg");

20
tools/TestSuite/TestSuite.ApiTests/GraphQLFixture.cs

@ -32,7 +32,7 @@ public sealed class GraphQLFixture : ContentFixture
{
try
{
var response = await Schemas.PostSchemaAsync(AppName, request);
var response = await Client.Schemas.PostSchemaAsync(request);
return response.Id;
}
@ -43,7 +43,7 @@ public sealed class GraphQLFixture : ContentFixture
throw;
}
var schema = await Schemas.GetSchemaAsync(AppName, request.Name);
var schema = await Client.Schemas.GetSchemaAsync(request.Name);
return schema.Id;
}
@ -121,7 +121,7 @@ public sealed class GraphQLFixture : ContentFixture
private async Task CreateContentsAsync()
{
var countriesClient = ClientManager.CreateContentsClient<DynamicEntity, object>("countries");
var countriesClient = Client.Contents<DynamicEntity, object>("countries");
var countriesResponse = await countriesClient.GetAsync();
if (countriesResponse.Total > 0)
@ -139,11 +139,10 @@ public sealed class GraphQLFixture : ContentFixture
}
};
var citiesClient = ClientManager.CreateContentsClient<DynamicEntity, object>("cities");
var citiesClient = Client.Contents<DynamicEntity, object>("cities");
var cityResponse = await citiesClient.CreateAsync(citySAData, ContentCreateOptions.AsPublish);
var city = await citiesClient.CreateAsync(citySAData, ContentCreateOptions.AsPublish);
return city.Id;
return cityResponse.Id;
}
async Task<string> CreateStateAsync(string name, string cityId)
@ -160,11 +159,10 @@ public sealed class GraphQLFixture : ContentFixture
}
};
var statesClient = ClientManager.CreateContentsClient<DynamicEntity, object>("states");
var state = await statesClient.CreateAsync(citySAData, ContentCreateOptions.AsPublish);
var statesClient = Client.Contents<DynamicEntity, object>("states");
var stateResponse = await statesClient.CreateAsync(citySAData, ContentCreateOptions.AsPublish);
return state.Id;
return stateResponse.Id;
}
// STEP 1: Create state 1

6
tools/TestSuite/TestSuite.ApiTests/GraphQLSubscriptionTests.cs

@ -117,7 +117,7 @@ public class GraphQLSubscriptionTests : IClassFixture<ContentFixture>
await using (fileParameter.Data)
{
await _.Assets.UploadAssetAsync(_.AppName, fileParameter, new AssetUploadOptions { Id = assetId });
await _.Client.Assets.UploadAssetAsync(fileParameter, new AssetUploadOptions { Id = assetId });
}
// STEP 3: Wait for publication.
@ -128,11 +128,11 @@ public class GraphQLSubscriptionTests : IClassFixture<ContentFixture>
private async Task<GraphQLHttpClient> CreateClient()
{
var accessToken = await _.ClientManager.Options.Authenticator.GetBearerTokenAsync(_.AppName, default);
var accessToken = await _.Client.Options.Authenticator.GetBearerTokenAsync(_.AppName, default);
var options = new GraphQLHttpClientOptions
{
EndPoint = new Uri(_.ClientManager.GenerateUrl($"/api/content/{_.AppName}/graphql?access_token={accessToken}"))
EndPoint = new Uri(_.Client.GenerateUrl($"/api/content/{_.AppName}/graphql?access_token={accessToken}"))
};
var client = new GraphQLHttpClient(options, new NewtonsoftJsonSerializer());

18
tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs

@ -55,7 +55,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}".Replace("<ID>", content_0.Id, StringComparison.Ordinal)
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
Assert.Equal(1, result["findMyWritesContent"]["flatData"]["json"]["value"].Value<int>());
Assert.Equal(2, result["findMyWritesContent"]["flatData"]["json"]["obj"]["value"].Value<int>());
@ -86,7 +86,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
var cityNames =
result["countries"].ToObject<List<Country>>()[0].Data.States
@ -122,7 +122,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
var cityNames =
result["countries"]
@ -159,7 +159,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
var cityNames =
result["countries"]
@ -188,7 +188,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
var stateNames =
result["cities"]
@ -216,7 +216,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var result = await _.SharedContents.GraphQlAsync<JToken>(query);
var result = await _.Client.SharedDynamicContents.GraphQlAsync<JToken>(query);
var stateNames =
result["cities"]
@ -240,10 +240,10 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var httpClient = _.ClientManager.CreateHttpClient();
var httpClient = _.Client.CreateHttpClient();
// Create the request manually to check the content type.
var response = await httpClient.PostAsync(_.ClientManager.GenerateUrl($"api/content/{_.AppName}/graphql/batch"), query.ToContent());
var response = await httpClient.PostAsync(_.Client.GenerateUrl($"api/content/{_.AppName}/graphql/batch"), query.ToContent());
Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType);
}
@ -261,7 +261,7 @@ public sealed class GraphQLTests : IClassFixture<GraphQLFixture>
}"
};
var httpClient = _.ClientManager.CreateHttpClient();
var httpClient = _.Client.CreateHttpClient();
// Create the request manually to check the headers.
var response = await httpClient.PostAsJsonAsync($"api/content/{_.AppName}/graphql", query);

2
tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs

@ -23,7 +23,7 @@ public class HistoryTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_get_history()
{
var history = await _.History.WaitForHistoryAsync(_.AppName, null, x => true, TimeSpan.FromSeconds(30));
var history = await _.Client.History.WaitForHistoryAsync(null, x => true, TimeSpan.FromSeconds(30));
Assert.NotEmpty(history);
}

2
tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs

@ -23,7 +23,7 @@ public class LanguagesTests : IClassFixture<ClientFixture>
[Fact]
public async Task Should_provide_languages()
{
var languages = await _.Languages.GetLanguagesAsync();
var languages = await _.Client.Languages.GetLanguagesAsync();
Assert.True(languages.Count > 100);
}

6
tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs

@ -23,7 +23,7 @@ public class OpenApiTests : IClassFixture<ContentFixture>
[Fact]
public async Task Should_provide_general_spec()
{
var url = $"{_.ClientManager.Options.Url}api/swagger/v1/swagger.json";
var url = $"{_.Client.Options.Url}api/swagger/v1/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);
@ -33,7 +33,7 @@ public class OpenApiTests : IClassFixture<ContentFixture>
[Fact]
public async Task Should_provide_content_spec()
{
var url = $"{_.ClientManager.Options.Url}api/content/{_.AppName}/swagger/v1/swagger.json";
var url = $"{_.Client.Options.Url}api/content/{_.AppName}/swagger/v1/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);
@ -43,7 +43,7 @@ public class OpenApiTests : IClassFixture<ContentFixture>
[Fact]
public async Task Should_provide_flat_content_spec()
{
var url = $"{_.ClientManager.Options.Url}api/content/{_.AppName}/flat/swagger/v1/swagger.json";
var url = $"{_.Client.Options.Url}api/content/{_.AppName}/flat/swagger/v1/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);

6
tools/TestSuite/TestSuite.ApiTests/PingTests.cs

@ -23,19 +23,19 @@ public class PingTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_ping_service()
{
await _.Ping.GetPingAsync();
await _.Client.Ping.GetPingAsync();
}
[Fact]
public async Task Should_ping_app()
{
await _.Ping.GetAppPingAsync(_.AppName);
await _.Client.Ping.GetAppPingAsync();
}
[Fact]
public async Task Should_get_info()
{
var infos = await _.Ping.GetInfoAsync();
var infos = await _.Client.Ping.GetInfoAsync();
Assert.NotNull(infos);
}

2
tools/TestSuite/TestSuite.ApiTests/PlansTests.cs

@ -23,7 +23,7 @@ public class PlansTests : IClassFixture<CreatedAppFixture>
[Fact]
public async Task Should_get_plans()
{
var plans = await _.Plans.GetPlansAsync(_.AppName);
var plans = await _.Client.Plans.GetPlansAsync();
Assert.NotNull(plans);
}

96
tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs

@ -37,7 +37,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_rules_on_content_change()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -61,11 +61,11 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Create test content
await CreateContentAsync();
await CreateContentAsync(app);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromMinutes(2));
@ -77,8 +77,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.Single(eventsAll.Items);
Assert.Single(eventsRule.Items);
@ -88,7 +88,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_rules_on_reference_change()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -96,20 +96,20 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 2: Create contents
var referencedSchema = await TestEntity.CreateSchemaAsync(_.Schemas, appName, schemaName);
var referencedSchema = await TestEntity.CreateSchemaAsync(app.Schemas, schemaName);
// Create a test content.
var referencedContents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(appName, schemaName);
var referencedContents = app.Contents<TestEntity, TestEntityData>(schemaName);
var referencedContent = await referencedContents.CreateAsync(new TestEntityData
{
String = contentString
});
var parentSchema = await TestEntityWithReferences.CreateSchemaAsync(_.Schemas, appName, schemaNameRef);
var parentSchema = await TestEntityWithReferences.CreateSchemaAsync(app.Schemas, schemaNameRef);
// Create a test content that references the other schema.
var parentContents = _.ClientManager.CreateContentsClient<TestEntityWithReferences, TestEntityWithReferencesData>(appName, schemaNameRef);
var parentContents = app.Contents<TestEntityWithReferences, TestEntityWithReferencesData>(schemaNameRef);
await parentContents.CreateAsync(new TestEntityWithReferencesData
{
@ -157,7 +157,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Update referenced content
@ -178,8 +178,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.NotEmpty(eventsAll.Items);
Assert.NotEmpty(eventsRule.Items);
@ -189,7 +189,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_scripting_rule_on_content_change()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -211,11 +211,11 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Create test content
await CreateContentAsync();
await CreateContentAsync(app);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromMinutes(2));
@ -225,8 +225,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.Single(eventsAll.Items);
Assert.Single(eventsRule.Items);
@ -236,7 +236,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_rules_on_asset_change()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -257,11 +257,11 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
Trigger = new AssetChangedRuleTriggerDto()
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Create test asset
await CreateAssetAsync();
await CreateAssetAsync(app);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromMinutes(2));
@ -273,8 +273,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.Single(eventsAll.Items);
Assert.Single(eventsRule.Items);
@ -284,7 +284,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_rules_on_schema_change()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -305,11 +305,11 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
Trigger = new SchemaChangedRuleTriggerDto()
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Create test schema
await TestEntity.CreateSchemaAsync(_.Schemas, appName, schemaName);
await TestEntity.CreateSchemaAsync(app.Schemas, schemaName);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromMinutes(2));
@ -321,8 +321,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.Single(eventsAll.Items);
Assert.Single(eventsRule.Items);
@ -332,7 +332,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_run_rule_manually()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -353,11 +353,11 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
Trigger = new ManualRuleTriggerDto()
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// STEP 3: Trigger rule
await _.Rules.TriggerRuleAsync(appName, rule.Id);
await app.Rules.TriggerRuleAsync(rule.Id);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromSeconds(30));
@ -369,8 +369,8 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
// STEP 4: Get events
var eventsAll = await _.Rules.GetEventsAsync(appName, rule.Id);
var eventsRule = await _.Rules.GetEventsAsync(appName);
var eventsAll = await app.Rules.GetEventsAsync(rule.Id);
var eventsRule = await app.Rules.GetEventsAsync();
Assert.Single(eventsAll.Items);
Assert.Single(eventsRule.Items);
@ -382,7 +382,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
public async Task Should_rerun_rules(bool fromSnapshots)
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Start webhook session
@ -405,18 +405,18 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
// Disable rule, so that we do not create the event from the rule itself.
await _.Rules.DisableRuleAsync(appName, rule.Id);
await app.Rules.DisableRuleAsync(rule.Id);
// STEP 3: Create test content before rule
await CreateContentAsync();
await CreateContentAsync(app);
// STEP 4: Run rule.
await _.Rules.PutRuleRunAsync(appName, rule.Id, fromSnapshots);
await app.Rules.PutRuleRunAsync(rule.Id, fromSnapshots);
// Get requests.
var requests = await webhookCatcher.WaitForRequestsAsync(sessionId, TimeSpan.FromSeconds(30));
@ -424,12 +424,12 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
Assert.Contains(requests, x => x.Method == "POST" && x.Content.Contains(schemaName, StringComparison.OrdinalIgnoreCase));
}
private async Task CreateContentAsync()
private async Task CreateContentAsync(ISquidexClient app)
{
await TestEntity.CreateSchemaAsync(_.Schemas, appName, schemaName);
await TestEntity.CreateSchemaAsync(app.Schemas, schemaName);
// Create a test content.
var contents = _.ClientManager.CreateContentsClient<TestEntity, TestEntityData>(appName, schemaName);
var contents = app.Contents<TestEntity, TestEntityData>(schemaName);
await contents.CreateAsync(new TestEntityData
{
@ -437,7 +437,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
});
}
private async Task CreateAssetAsync()
private static async Task CreateAssetAsync(ISquidexClient app)
{
// Upload a test asset
var fileInfo = new FileInfo("Assets/logo-squared.png");
@ -446,17 +446,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
{
var upload = new FileParameter(stream, fileInfo.Name, "image/png");
await _.Assets.PostAssetAsync(appName, file: upload);
await app.Assets.PostAssetAsync(file: upload);
}
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

34
tools/TestSuite/TestSuite.ApiTests/RuleTests.cs

@ -30,7 +30,7 @@ public class RuleTests : IClassFixture<ClientFixture>
public async Task Should_create_rule()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Create rule
@ -49,7 +49,7 @@ public class RuleTests : IClassFixture<ClientFixture>
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRule);
var rule = await app.Rules.PostRuleAsync(createRule);
Assert.IsType<WebhookRuleActionDto>(rule.Action);
@ -60,7 +60,7 @@ public class RuleTests : IClassFixture<ClientFixture>
public async Task Should_update_rule()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Create rule
@ -79,7 +79,7 @@ public class RuleTests : IClassFixture<ClientFixture>
}
};
var rule_0 = await _.Rules.PostRuleAsync(appName, createRequest);
var rule_0 = await app.Rules.PostRuleAsync(createRequest);
// STEP 2: Update rule
@ -88,7 +88,7 @@ public class RuleTests : IClassFixture<ClientFixture>
Name = ruleName
};
var rule_1 = await _.Rules.PutRuleAsync(appName, rule_0.Id, updateRequest);
var rule_1 = await app.Rules.PutRuleAsync(rule_0.Id, updateRequest);
Assert.Equal(ruleName, rule_1.Name);
@ -99,7 +99,7 @@ public class RuleTests : IClassFixture<ClientFixture>
public async Task Should_delete_rule()
{
// STEP 0: Create app.
await CreateAppAsync();
var (app, _) = await _.PostAppAsync(appName);
// STEP 1: Create rule
@ -118,13 +118,13 @@ public class RuleTests : IClassFixture<ClientFixture>
}
};
var rule = await _.Rules.PostRuleAsync(appName, createRequest);
var rule = await app.Rules.PostRuleAsync(createRequest);
// STEP 2: Delete rule
await _.Rules.DeleteRuleAsync(appName, rule.Id);
await app.Rules.DeleteRuleAsync(rule.Id);
var rules = await _.Rules.GetRulesAsync(appName);
var rules = await app.Rules.GetRulesAsync();
Assert.DoesNotContain(rules.Items, x => x.Id == rule.Id);
}
@ -132,7 +132,7 @@ public class RuleTests : IClassFixture<ClientFixture>
[Fact]
public async Task Should_get_actions()
{
var actions = await _.Rules.GetActionsAsync();
var actions = await _.Client.Rules.GetActionsAsync();
Assert.NotEmpty(actions);
}
@ -140,7 +140,7 @@ public class RuleTests : IClassFixture<ClientFixture>
[Fact]
public async Task Should_get_event_schemas()
{
var schema = await _.Rules.GetEventSchemaAsync("EnrichedContentEvent");
var schema = await _.Client.Rules.GetEventSchemaAsync("EnrichedContentEvent");
Assert.NotNull(schema);
}
@ -148,18 +148,8 @@ public class RuleTests : IClassFixture<ClientFixture>
[Fact]
public async Task Should_get_event_types()
{
var eventTypes = await _.Rules.GetEventTypesAsync();
var eventTypes = await _.Client.Rules.GetEventTypesAsync();
Assert.NotEmpty(eventTypes);
}
private async Task CreateAppAsync()
{
var createRequest = new CreateAppDto
{
Name = appName
};
await _.Apps.PostAppAsync(createRequest);
}
}

38
tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs

@ -35,14 +35,14 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
Name = schemaName
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
// STEP 2: Get all schemas
var schemas = await _.Schemas.GetSchemasAsync(_.AppName);
var schemas = await _.Client.Schemas.GetSchemasAsync();
// Should provide new schema when apps are schemas.
Assert.Contains(schemas.Items, x => x.Name == schemaName);
@ -57,13 +57,13 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
Name = schemaName
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// STEP 2: Create again and fail
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{
return _.Schemas.PostSchemaAsync(_.AppName, createRequest);
return _.Client.Schemas.PostSchemaAsync(createRequest);
});
Assert.Equal(400, ex.StatusCode);
@ -82,7 +82,7 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
IsPublished = true
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
@ -92,16 +92,14 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
// STEP 2: Get all schemas
var schemas = await _.Schemas.GetSchemasAsync(_.AppName);
var schemas = await _.Client.Schemas.GetSchemasAsync();
// Should provide new schema when apps are schemas.
Assert.Contains(schemas.Items, x => x.Name == schemaName);
// STEP 3: Get singleton content
var client = _.ClientManager.CreateDynamicContentsClient(schemaName);
var content = await client.GetAsync(schema.Id);
var content = await _.Client.DynamicContents(schemaName).GetAsync(schema.Id);
Assert.NotNull(content);
}
@ -119,7 +117,7 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
IsPublished = true
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
@ -129,16 +127,14 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
// STEP 2: Get all schemas
var schemas = await _.Schemas.GetSchemasAsync(_.AppName);
var schemas = await _.Client.Schemas.GetSchemasAsync();
// Should provide new schema when apps are schemas.
Assert.Contains(schemas.Items, x => x.Name == schemaName);
// STEP 3: Get singleton content
var client = _.ClientManager.CreateDynamicContentsClient(schemaName);
var content = await client.GetAsync(schema.Id);
var content = await _.Client.DynamicContents(schemaName).GetAsync(schema.Id);
Assert.NotNull(content);
}
@ -174,7 +170,7 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
}
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
@ -189,16 +185,16 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
Name = schemaName
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
// STEP 2: Delete schema
await _.Schemas.DeleteSchemaAsync(_.AppName, schemaName);
await _.Client.Schemas.DeleteSchemaAsync(schemaName);
var schemas = await _.Schemas.GetSchemasAsync(_.AppName);
var schemas = await _.Client.Schemas.GetSchemasAsync();
// Should not provide deleted schema when schema are queried.
Assert.DoesNotContain(schemas.Items, x => x.Name == schemaName);
@ -213,17 +209,17 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
Name = schemaName
};
var schema = await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
var schema = await _.Client.Schemas.PostSchemaAsync(createRequest);
// Should return created schemas with correct name.
Assert.Equal(schemaName, schema.Name);
// STEP 2: Delete schema.
await _.Schemas.DeleteSchemaAsync(_.AppName, schemaName);
await _.Client.Schemas.DeleteSchemaAsync(schemaName);
// STEP 3: Create app again
await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
await _.Client.Schemas.PostSchemaAsync(createRequest);
}
}

12
tools/TestSuite/TestSuite.ApiTests/SearchTests.cs

@ -27,11 +27,11 @@ public class SearchTests : IClassFixture<ContentFixture>
public async Task Should_search_asset()
{
// STEP 1: Create asset
await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", "image/png");
await _.Client.Assets.UploadFileAsync("Assets/logo-wide.png", "image/png");
// STEP 2: Search for schema.
var result = await _.Search.GetSearchResultsAsync(_.AppName, "logo");
var result = await _.Client.Search.GetSearchResultsAsync("logo");
Assert.Contains(result, x => x.Type == SearchResultType.Asset);
}
@ -47,11 +47,11 @@ public class SearchTests : IClassFixture<ContentFixture>
Name = schemaName
};
await _.Schemas.PostSchemaAsync(_.AppName, createRequest);
await _.Client.Schemas.PostSchemaAsync(createRequest);
// STEP 2: Search for schema.
var result = await _.Search.WaitForSearchAsync(_.AppName, schemaName, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30));
var result = await _.Client.Search.WaitForSearchAsync(schemaName, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30));
Assert.NotEmpty(result);
}
@ -71,7 +71,7 @@ public class SearchTests : IClassFixture<ContentFixture>
// STEP 2: Search for schema.
var result = await _.Search.WaitForSearchAsync(_.AppName, contentString, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30));
var result = await _.Client.Search.WaitForSearchAsync(contentString, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30));
Assert.NotEmpty(result);
}
@ -90,7 +90,7 @@ public class SearchTests : IClassFixture<ContentFixture>
[InlineData(SearchResultType.Setting, "Workflows")]
public async Task Should_search_for_dashboard_pages(SearchResultType expectedType, string query)
{
var result = await _.Search.GetSearchResultsAsync(_.AppName, query);
var result = await _.Client.Search.GetSearchResultsAsync(query);
Assert.Contains(result, x => x.Type == expectedType);
}

12
tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj

@ -14,16 +14,16 @@
<None Remove="Assets\SampleImage_WEBP_350kb - Copy.webp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.76" />
<PackageReference Include="GraphQL.Client" Version="5.1.0" />
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="5.1.0" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.757">
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="3.0.118" />
<PackageReference Include="GraphQL.Client" Version="5.1.1" />
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="5.1.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.22">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NSwag.Core" Version="13.18.2" />
<PackageReference Include="PuppeteerSharp" Version="8.0.0" />
<PackageReference Include="PuppeteerSharp" Version="9.0.2" />
<PackageReference Include="Squidex.Assets" Version="5.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Verify.Xunit" Version="17.5.0" />

25
tools/TestSuite/TestSuite.ApiTests/Verify/ContentUpdateTests.Should_get_content_by_version.verified.txt

@ -1,5 +1,26 @@
{
Number: {
iv: 1
Data: {
Number: {
iv: 1
}
},
NewStatus: ,
Status: Published,
EditingStatus: Published,
Id: Guid_1,
Version: 1,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

3
tools/TestSuite/TestSuite.LoadTests/ReadingBenchmarks.cs

@ -10,6 +10,7 @@ using Xunit;
using Xunit.Abstractions;
#pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable xUnit1033 // Test classes decorated with 'Xunit.IClassFixture<TFixture>' or 'Xunit.ICollectionFixture<TFixture>' should add a constructor argument of type TFixture
namespace TestSuite.LoadTests;
@ -66,7 +67,7 @@ public class ReadingBenchmarks : IClassFixture<CreatedAppFixture>
{
await Run.Parallel(numUsers, numIterationsPerUser, async () =>
{
await _.Apps.GetClientsAsync(_.AppName);
await _.Client.Apps.GetClientsAsync();
}, 100, testOutput);
}
}

4
tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj

@ -6,11 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="1.0.757">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.22">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

34
tools/TestSuite/TestSuite.Shared/ClientExtensions.cs

@ -13,7 +13,7 @@ namespace TestSuite;
public static class ClientExtensions
{
public static async Task<bool> WaitForDeletionAsync(this IAssetsClient assetsClient, string app, string id, TimeSpan timeout)
public static async Task<bool> WaitForDeletionAsync(this IAssetsClient assetsClient, string id, TimeSpan timeout)
{
try
{
@ -23,7 +23,7 @@ public static class ClientExtensions
{
try
{
await assetsClient.GetAssetAsync(app, id, cts.Token);
await assetsClient.GetAssetAsync(id, cts.Token);
}
catch (SquidexManagementException ex) when (ex.StatusCode == 404)
{
@ -65,7 +65,7 @@ public static class ClientExtensions
return new ContentsResult<TEntity, TData>();
}
public static async Task<IList<SearchResultDto>> WaitForSearchAsync(this ISearchClient searchClient, string app, string query, Func<SearchResultDto, bool> predicate, TimeSpan timeout)
public static async Task<IList<SearchResultDto>> WaitForSearchAsync(this ISearchClient searchClient, string query, Func<SearchResultDto, bool> predicate, TimeSpan timeout)
{
try
{
@ -73,7 +73,7 @@ public static class ClientExtensions
while (!cts.IsCancellationRequested)
{
var result = await searchClient.GetSearchResultsAsync(app, query, cts.Token);
var result = await searchClient.GetSearchResultsAsync(query, cts.Token);
if (result.Any(predicate))
{
@ -90,7 +90,7 @@ public static class ClientExtensions
return new List<SearchResultDto>();
}
public static async Task<IList<HistoryEventDto>> WaitForHistoryAsync(this IHistoryClient historyClient, string app, string channel, Func<HistoryEventDto, bool> predicate, TimeSpan timeout)
public static async Task<IList<HistoryEventDto>> WaitForHistoryAsync(this IHistoryClient historyClient, string channel, Func<HistoryEventDto, bool> predicate, TimeSpan timeout)
{
try
{
@ -98,7 +98,7 @@ public static class ClientExtensions
while (!cts.IsCancellationRequested)
{
var result = await historyClient.GetAppHistoryAsync(app, channel, cts.Token);
var result = await historyClient.GetAppHistoryAsync(channel, cts.Token);
if (result.Any(predicate))
{
@ -115,7 +115,7 @@ public static class ClientExtensions
return new List<HistoryEventDto>();
}
public static async Task<IDictionary<string, int>> WaitForTagsAsync(this IAssetsClient assetsClient, string app, string id, TimeSpan timeout)
public static async Task<IDictionary<string, int>> WaitForTagsAsync(this IAssetsClient assetsClient, string id, TimeSpan timeout)
{
try
{
@ -123,7 +123,7 @@ public static class ClientExtensions
while (!cts.IsCancellationRequested)
{
var result = await assetsClient.GetTagsAsync(app, cts.Token);
var result = await assetsClient.GetTagsAsync(cts.Token);
if (result.TryGetValue(id, out var count) && count > 0)
{
@ -137,10 +137,10 @@ public static class ClientExtensions
{
}
return await assetsClient.GetTagsAsync(app);
return await assetsClient.GetTagsAsync();
}
public static async Task<IList<BackupJobDto>> WaitForBackupsAsync(this IBackupsClient backupsClient, string app, Func<BackupJobDto, bool> predicate, TimeSpan timeout)
public static async Task<IList<BackupJobDto>> WaitForBackupsAsync(this IBackupsClient backupsClient, Func<BackupJobDto, bool> predicate, TimeSpan timeout)
{
try
{
@ -148,7 +148,7 @@ public static class ClientExtensions
while (!cts.IsCancellationRequested)
{
var result = await backupsClient.GetBackupsAsync(app, cts.Token);
var result = await backupsClient.GetBackupsAsync(cts.Token);
if (result.Items.Any(predicate))
{
@ -219,7 +219,7 @@ public static class ClientExtensions
return temp;
}
public static async Task<AssetDto> UploadFileAsync(this IAssetsClient assetsClients, string app, string path, AssetDto asset, string fileName = null)
public static async Task<AssetDto> UploadFileAsync(this IAssetsClient assetsClients, string path, AssetDto asset, string fileName = null)
{
var fileInfo = new FileInfo(path);
@ -227,11 +227,11 @@ public static class ClientExtensions
{
var upload = new FileParameter(stream, fileName ?? fileInfo.Name, asset.MimeType);
return await assetsClients.PutAssetContentAsync(app, asset.Id, upload);
return await assetsClients.PutAssetContentAsync(asset.Id, upload);
}
}
public static async Task<AssetDto> UploadFileAsync(this IAssetsClient assetsClients, string app, string path, string fileType, string fileName = null, string parentId = null, string id = null)
public static async Task<AssetDto> UploadFileAsync(this IAssetsClient assetsClients, string path, string fileType, string fileName = null, string parentId = null, string id = null)
{
var fileInfo = new FileInfo(path);
@ -239,17 +239,17 @@ public static class ClientExtensions
{
var upload = new FileParameter(stream, fileName ?? fileInfo.Name, fileType);
return await assetsClients.PostAssetAsync(app, parentId, id, true, upload);
return await assetsClients.PostAssetAsync(parentId, id, true, upload);
}
}
public static async Task<AssetDto> UploadRandomFileAsync(this IAssetsClient assetsClients, string app, int size, string parentId = null, string id = null)
public static async Task<AssetDto> UploadRandomFileAsync(this IAssetsClient assetsClients, int size, string parentId = null, string id = null)
{
using (var stream = RandomAsset(size))
{
var upload = new FileParameter(stream, RandomName(".txt"), "text/csv");
return await assetsClients.PostAssetAsync(app, parentId, id, true, upload);
return await assetsClients.PostAssetAsync(parentId, id, true, upload);
}
}

13
tools/TestSuite/TestSuite.Shared/ClientManagerWrapper.cs → tools/TestSuite/TestSuite.Shared/ClientWrapper.cs

@ -12,11 +12,11 @@ using TestSuite.Utils;
namespace TestSuite;
public sealed class ClientManagerWrapper
public sealed class ClientWrapper
{
public ISquidexClientManager ClientManager { get; }
public ISquidexClient Client { get; }
public ClientManagerWrapper()
public ClientWrapper()
{
var services =
new ServiceCollection()
@ -38,10 +38,10 @@ public sealed class ClientManagerWrapper
}).Services
.BuildServiceProvider();
ClientManager = services.GetRequiredService<ISquidexClientManager>();
Client = services.GetRequiredService<ISquidexClient>();
}
public async Task<ClientManagerWrapper> ConnectAsync()
public async Task<ClientWrapper> ConnectAsync()
{
var waitSeconds = TestHelpers.Configuration.GetValue<int>("config:wait");
@ -49,7 +49,6 @@ public sealed class ClientManagerWrapper
{
Console.WriteLine("Waiting {0} seconds to access server", waitSeconds);
var pingClient = ClientManager.CreatePingClient();
try
{
using (var cts = new CancellationTokenSource(waitSeconds * 1000))
@ -58,7 +57,7 @@ public sealed class ClientManagerWrapper
{
try
{
await pingClient.GetPingAsync(cts.Token);
await Client.Ping.GetPingAsync(cts.Token);
break;
}
catch

12
tools/TestSuite/TestSuite.Shared/Fixtures/ClientCloudFixture.cs

@ -12,13 +12,13 @@ namespace TestSuite.Fixtures;
public sealed class ClientCloudFixture
{
public ISquidexClientManager ClientManager { get; private set; }
public ISquidexClient CloudClient { get; private set; }
public ISquidexClientManager CDNClientManager { get; private set; }
public ISquidexClient CDNClient { get; private set; }
public ClientCloudFixture()
{
ClientManager =
CloudClient =
new ServiceCollection()
.AddSquidexClient(options =>
{
@ -28,9 +28,9 @@ public sealed class ClientCloudFixture
options.ReadResponseAsString = true;
})
.BuildServiceProvider()
.GetRequiredService<ISquidexClientManager>();
.GetRequiredService<ISquidexClient>();
CDNClientManager =
CDNClient =
new ServiceCollection()
.AddSquidexClient(options =>
{
@ -41,6 +41,6 @@ public sealed class ClientCloudFixture
options.ContentCDN = "https://contents.squidex.io";
})
.BuildServiceProvider()
.GetRequiredService<ISquidexClientManager>();
.GetRequiredService<ISquidexClient>();
}
}

134
tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Microsoft.Extensions.DependencyInjection;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using Xunit;
@ -13,97 +14,17 @@ namespace TestSuite.Fixtures;
public class ClientFixture : IAsyncLifetime
{
public ClientManagerWrapper Squidex { get; private set; }
public ClientWrapper Squidex { get; private set; }
public string AppName => ClientManager.Options.AppName;
public string AppName => Client.Options.AppName;
public string ClientId => ClientManager.Options.ClientId;
public string ClientId => Client.Options.ClientId;
public string ClientSecret => ClientManager.Options.ClientSecret;
public string ClientSecret => Client.Options.ClientSecret;
public string Url => ClientManager.Options.Url;
public string Url => Client.Options.Url;
public ISquidexClientManager ClientManager => Squidex.ClientManager;
public IAppsClient Apps
{
get => ClientManager.CreateAppsClient();
}
public IAssetsClient Assets
{
get => ClientManager.CreateAssetsClient();
}
public IBackupsClient Backups
{
get => ClientManager.CreateBackupsClient();
}
public ICommentsClient Comments
{
get => ClientManager.CreateCommentsClient();
}
public IDiagnosticsClient Diagnostics
{
get => ClientManager.CreateDiagnosticsClient();
}
public IHistoryClient History
{
get => ClientManager.CreateHistoryClient();
}
public ILanguagesClient Languages
{
get => ClientManager.CreateLanguagesClient();
}
public IPingClient Ping
{
get => ClientManager.CreatePingClient();
}
public IPlansClient Plans
{
get => ClientManager.CreatePlansClient();
}
public IRulesClient Rules
{
get => ClientManager.CreateRulesClient();
}
public ISchemasClient Schemas
{
get => ClientManager.CreateSchemasClient();
}
public ISearchClient Search
{
get => ClientManager.CreateSearchClient();
}
public ITemplatesClient Templates
{
get => ClientManager.CreateTemplatesClient();
}
public ITranslationsClient Translations
{
get => ClientManager.CreateTranslationsClient();
}
public IUserManagementClient UserManagement
{
get => ClientManager.CreateUserManagementClient();
}
public IContentsSharedClient<DynamicContent, DynamicData> SharedContents
{
get => ClientManager.CreateSharedDynamicContentsClient();
}
public ISquidexClient Client => Squidex.Client;
static ClientFixture()
{
@ -119,11 +40,48 @@ public class ClientFixture : IAsyncLifetime
VerifierSettings.IgnoreMembersWithType<DateTimeOffset>();
}
public Task<(ISquidexClient, AppDto)> PostAppAsync(string name)
{
var createRequest = new CreateAppDto
{
Name = name
};
return PostAppAsync(createRequest);
}
public async Task<(ISquidexClient, AppDto)> PostAppAsync(CreateAppDto request)
{
var services =
new ServiceCollection()
.AddSquidexClient(options =>
{
options.AppName = request.Name;
options.ClientId = ClientId;
options.ClientSecret = ClientSecret;
options.Url = Client.Options.Url;
options.ReadResponseAsString = true;
})
.AddSquidexHttpClient()
.ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
}).Services
.BuildServiceProvider();
var client = services.GetRequiredService<ISquidexClient>();
return (client, await client.Apps.PostAppAsync(request));
}
public virtual async Task InitializeAsync()
{
Squidex = await Factories.CreateAsync(nameof(ClientManagerWrapper), async () =>
Squidex = await Factories.CreateAsync(nameof(ClientWrapper), async () =>
{
var clientManager = new ClientManagerWrapper();
var clientManager = new ClientWrapper();
await clientManager.ConnectAsync();

33
tools/TestSuite/TestSuite.Shared/Fixtures/CreatedAppFixture.cs

@ -15,29 +15,16 @@ public class CreatedAppFixture : ClientFixture
{
await base.InitializeAsync();
await Factories.CreateAsync(AppName, async () =>
async Task CreateLanguageAsync(string name)
{
try
{
await Apps.PostAppAsync(new CreateAppDto
{
Name = AppName
});
}
catch (SquidexManagementException ex)
{
if (ex.StatusCode != 400)
var createRequest = new AddLanguageDto
{
throw;
}
}
Language = name
};
try
{
await Apps.PostLanguageAsync(AppName, new AddLanguageDto
{
Language = "de"
});
await Client.Apps.PostLanguageAsync(createRequest);
}
catch (SquidexManagementException ex)
{
@ -46,12 +33,15 @@ public class CreatedAppFixture : ClientFixture
throw;
}
}
}
await Factories.CreateAsync(AppName, async () =>
{
try
{
await Apps.PostLanguageAsync(AppName, new AddLanguageDto
await Client.Apps.PostAppAsync(new CreateAppDto
{
Language = "custom"
Name = AppName
});
}
catch (SquidexManagementException ex)
@ -62,6 +52,9 @@ public class CreatedAppFixture : ClientFixture
}
}
await CreateLanguageAsync("de");
await CreateLanguageAsync("custom");
return true;
});
}

4
tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaFixtureBase.cs

@ -30,7 +30,7 @@ public abstract class TestSchemaFixtureBase : CreatedAppFixture
{
try
{
await TestEntity.CreateSchemaAsync(Schemas, AppName, SchemaName);
await TestEntity.CreateSchemaAsync(Client.Schemas, SchemaName);
}
catch (SquidexManagementException ex)
{
@ -43,6 +43,6 @@ public abstract class TestSchemaFixtureBase : CreatedAppFixture
return true;
});
Contents = ClientManager.CreateContentsClient<TestEntity, TestEntityData>(SchemaName);
Contents = Client.Contents<TestEntity, TestEntityData>(SchemaName);
}
}

4
tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaWithReferencesFixtureBase.cs

@ -30,7 +30,7 @@ public abstract class TestSchemaWithReferencesFixtureBase : CreatedAppFixture
{
try
{
await TestEntityWithReferences.CreateSchemaAsync(Schemas, AppName, SchemaName);
await TestEntityWithReferences.CreateSchemaAsync(Client.Schemas, SchemaName);
}
catch (SquidexManagementException ex)
{
@ -43,6 +43,6 @@ public abstract class TestSchemaWithReferencesFixtureBase : CreatedAppFixture
return true;
});
Contents = ClientManager.CreateContentsClient<TestEntityWithReferences, TestEntityWithReferencesData>(SchemaName);
Contents = Client.Contents<TestEntityWithReferences, TestEntityWithReferencesData>(SchemaName);
}
}

4
tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs

@ -19,9 +19,9 @@ public sealed class TestEntity : Content<TestEntityData>
{
public const int ScriptTrigger = -99;
public static async Task<SchemaDto> CreateSchemaAsync(ISchemasClient schemas, string appName, string name, SchemaScriptsDto scripts = null)
public static async Task<SchemaDto> CreateSchemaAsync(ISchemasClient schemas, string name, SchemaScriptsDto scripts = null)
{
var schema = await schemas.PostSchemaAsync(appName, new CreateSchemaDto
var schema = await schemas.PostSchemaAsync(new CreateSchemaDto
{
Name = name,
Fields = new List<UpsertSchemaFieldDto>

4
tools/TestSuite/TestSuite.Shared/Model/TestEntityWithReferences.cs

@ -15,9 +15,9 @@ namespace TestSuite.Model;
public sealed class TestEntityWithReferences : Content<TestEntityWithReferencesData>
{
public static async Task<SchemaDto> CreateSchemaAsync(ISchemasClient schemas, string appName, string name)
public static async Task<SchemaDto> CreateSchemaAsync(ISchemasClient schemas, string name)
{
var schema = await schemas.PostSchemaAsync(appName, new CreateSchemaDto
var schema = await schemas.PostSchemaAsync(new CreateSchemaDto
{
Name = name,
Fields = new List<UpsertSchemaFieldDto>

16
tools/TestSuite/TestSuite.Shared/Strategies.cs

@ -19,11 +19,11 @@ public static class Strategies
BulkPermanent
}
public static Task DeleteAsync(this ISquidexClientManager clientManager, ContentBase content, Deletion strategy)
public static Task DeleteAsync(this ISquidexClient client, ContentBase content, Deletion strategy)
{
IContentsClient<MyContent, object> GetClient()
{
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName);
return client.Contents<MyContent, object>(content.SchemaName);
}
switch (strategy)
@ -73,11 +73,11 @@ public static class Strategies
BulkShared
}
public static Task UpdateAsync(this ISquidexClientManager clientManager, ContentBase content, object data, Update strategy)
public static Task UpdateAsync(this ISquidexClient client, ContentBase content, object data, Update strategy)
{
IContentsClient<MyContent, object> GetClient()
{
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName);
return client.Contents<MyContent, object>(content.SchemaName);
}
switch (strategy)
@ -127,7 +127,7 @@ public static class Strategies
}
});
case Update.BulkShared:
return clientManager.CreateSharedContentsClient<MyContent, object>().BulkUpdateAsync(new BulkUpdate
return client.SharedContents<MyContent, object>().BulkUpdateAsync(new BulkUpdate
{
Jobs = new List<BulkUpdateJob>
{
@ -155,11 +155,11 @@ public static class Strategies
UpsertBulk
}
public static Task PatchAsync(this ISquidexClientManager clientManager, ContentBase content, object data, Patch strategy)
public static Task PatchAsync(this ISquidexClient client, ContentBase content, object data, Patch strategy)
{
IContentsClient<MyContent, object> GetClient()
{
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName);
return client.Contents<MyContent, object>(content.SchemaName);
}
switch (strategy)
@ -209,7 +209,7 @@ public static class Strategies
}
});
case Patch.BulkShared:
return clientManager.CreateSharedContentsClient<MyContent, object>().BulkUpdateAsync(new BulkUpdate
return client.SharedContents<MyContent, object>().BulkUpdateAsync(new BulkUpdate
{
Jobs = new List<BulkUpdateJob>
{

8
tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

@ -6,18 +6,18 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="1.0.757">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.22">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.ClientLibrary" Version="14.2.0" />
<PackageReference Include="Squidex.ClientLibrary.ServiceExtensions" Version="14.2.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="15.0.0-beta2" />
<PackageReference Include="Squidex.ClientLibrary.ServiceExtensions" Version="15.0.0-beta2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Verify" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />

Loading…
Cancel
Save