Browse Source

Feature/rule page (#688)

* UI refactoring

* Code cleanup.

* Minor fixes.

* Tests fixed and unified and code removed.

* Fix bug.

* Update terser to fix compile error.
pull/691/head
Sebastian Stehle 5 years ago
committed by GitHub
parent
commit
5517fea29c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      backend/i18n/frontend_en.json
  2. 4
      backend/i18n/frontend_it.json
  3. 4
      backend/i18n/frontend_nl.json
  4. 4
      backend/i18n/source/frontend_en.json
  5. 4
      backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs
  6. 9
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs
  7. 8
      backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs
  8. 8
      backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs
  9. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs
  10. 6
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs
  11. 14
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs
  12. 4
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs
  13. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs
  14. 4
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs
  15. 4
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs
  16. 24
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs
  17. 10
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs
  18. 38
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs
  19. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs
  20. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs
  21. 26
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs
  22. 12
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs
  23. 20
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs
  24. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs
  25. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs
  26. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs
  27. 16
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs
  28. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs
  29. 26
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs
  30. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs
  31. 12
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs
  32. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs
  33. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs
  34. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs
  35. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs
  36. 18
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs
  37. 10
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs
  38. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs
  39. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs
  40. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs
  41. 28
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs
  42. 28
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs
  43. 42
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs
  44. 18
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs
  45. 26
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs
  46. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs
  47. 38
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs
  48. 32
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs
  49. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs
  50. 14
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs
  51. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs
  52. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs
  53. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs
  54. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs
  55. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs
  56. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs
  57. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs
  58. 78
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs
  59. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs
  60. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs
  61. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs
  62. 10
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs
  63. 16
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs
  64. 14
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs
  65. 14
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs
  66. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs
  67. 8
      backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs
  68. 6
      backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs
  69. 6
      backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs
  70. 40
      backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs
  71. 4
      backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs
  72. 28
      backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs
  73. 2
      backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs
  74. 8
      backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs
  75. 28
      backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs
  76. 4
      backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs
  77. 6
      backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs
  78. 4
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs
  79. 44
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs
  80. 2
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs
  81. 6
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs
  82. 2
      backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs
  83. 26
      backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs
  84. 12
      backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs
  85. 10
      backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs
  86. 8
      backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs
  87. 4
      backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs
  88. 6
      backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs
  89. 2
      backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs
  90. 4
      backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs
  91. 6
      backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs
  92. 6
      backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs
  93. 1
      frontend/app/features/administration/declarations.ts
  94. 36
      frontend/app/features/administration/guards/unset-user.guard.spec.ts
  95. 24
      frontend/app/features/administration/guards/unset-user.guard.ts
  96. 63
      frontend/app/features/administration/guards/user-must-exist.guard.spec.ts
  97. 4
      frontend/app/features/administration/guards/user-must-exist.guard.ts
  98. 8
      frontend/app/features/administration/module.ts
  99. 24
      frontend/app/features/administration/state/event-consumers.state.spec.ts
  100. 2
      frontend/app/features/administration/state/event-consumers.state.ts

4
backend/i18n/frontend_en.json

@ -240,9 +240,11 @@
"common.delete": "Delete",
"common.description": "Description",
"common.designer": "Designer",
"common.disabled": "Disabled",
"common.displayName": "Display Name",
"common.edit": "Edit",
"common.email": "Email",
"common.enabled": "Enabled",
"common.error": "Error",
"common.errorBack": "Back to previous page.",
"common.errorNoPermission": "You do not have the permissions to do this.",
@ -316,6 +318,7 @@
"common.restore": "Restore",
"common.role": "Role",
"common.roles": "Roles",
"common.rule": "Rule",
"common.rules": "Rules",
"common.sampleCodeLabel": "Sample Code at",
"common.save": "Save",
@ -621,6 +624,7 @@
"rules.emptyAddRule": "Add Rule",
"rules.enableFailed": "Failed to enable rule. Please reload.",
"rules.enqueued": "Rule has been added to the queue.",
"rules.itemPageTitle": "Rule",
"rules.listPageTitle": "Rules",
"rules.loadFailed": "Failed to load Rules. Please reload.",
"rules.readMore": "Read More",

4
backend/i18n/frontend_it.json

@ -240,9 +240,11 @@
"common.delete": "Cancella",
"common.description": "Descrizione",
"common.designer": "Designer",
"common.disabled": "Disabled",
"common.displayName": "Nome visualizzato",
"common.edit": "Modifica",
"common.email": "Email",
"common.enabled": "Enabled",
"common.error": "Errore",
"common.errorBack": "Torna alla pagina precedente.",
"common.errorNoPermission": "Non hai i permessi per questo.",
@ -316,6 +318,7 @@
"common.restore": "Ripristina",
"common.role": "Ruolo",
"common.roles": "Ruoli",
"common.rule": "Rule",
"common.rules": "Regole",
"common.sampleCodeLabel": "Esempio di codice per",
"common.save": "Salva",
@ -621,6 +624,7 @@
"rules.emptyAddRule": "Aggiungi una regola",
"rules.enableFailed": "Non è stato possibile abilitare la regola. Per favore ricarica.",
"rules.enqueued": "La regola è stata aggiunta alle code.",
"rules.itemPageTitle": "Rule",
"rules.listPageTitle": "Regole",
"rules.loadFailed": "Non è stato possibile caricare le regole. Per favore ricarica.",
"rules.readMore": "Leggi di più",

4
backend/i18n/frontend_nl.json

@ -240,9 +240,11 @@
"common.delete": "Verwijderen",
"common.description": "Beschrijving",
"common.designer": "Designer",
"common.disabled": "Disabled",
"common.displayName": "Weergavenaam",
"common.edit": "Bewerken",
"common.email": "E-mail",
"common.enabled": "Enabled",
"common.error": "Fout",
"common.errorBack": "Terug naar de vorige pagina.",
"common.errorNoPermission": "Je hebt niet de permissies om dit te doen.",
@ -316,6 +318,7 @@
"common.restore": "Herstellen",
"common.role": "Rol",
"common.roles": "Rollen",
"common.rule": "Rule",
"common.rules": "Regels",
"common.sampleCodeLabel": "Voorbeeldcode bij",
"common.save": "Opslaan",
@ -621,6 +624,7 @@
"rules.emptyAddRule": "Regel toevoegen",
"rules.enableFailed": "Kan regel niet inschakelen. Laad opnieuw.",
"rules.enqueued": "Regel is toegevoegd aan de wachtrij.",
"rules.itemPageTitle": "Rule",
"rules.listPageTitle": "Regels",
"rules.loadFailed": "Laden van regels is mislukt. Laad opnieuw.",
"rules.readMore": "Lees meer",

4
backend/i18n/source/frontend_en.json

@ -240,9 +240,11 @@
"common.delete": "Delete",
"common.description": "Description",
"common.designer": "Designer",
"common.disabled": "Disabled",
"common.displayName": "Display Name",
"common.edit": "Edit",
"common.email": "Email",
"common.enabled": "Enabled",
"common.error": "Error",
"common.errorBack": "Back to previous page.",
"common.errorNoPermission": "You do not have the permissions to do this.",
@ -316,6 +318,7 @@
"common.restore": "Restore",
"common.role": "Role",
"common.roles": "Roles",
"common.rule": "Rule",
"common.rules": "Rules",
"common.sampleCodeLabel": "Sample Code at",
"common.save": "Save",
@ -621,6 +624,7 @@
"rules.emptyAddRule": "Add Rule",
"rules.enableFailed": "Failed to enable rule. Please reload.",
"rules.enqueued": "Rule has been added to the queue.",
"rules.itemPageTitle": "Rule",
"rules.listPageTitle": "Rules",
"rules.loadFailed": "Failed to load Rules. Please reload.",
"rules.readMore": "Read More",

4
backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs

@ -11,10 +11,12 @@ namespace Squidex.Domain.Apps.Entities.Rules.Commands
{
public abstract class RuleEditCommand : RuleCommand
{
public string? Name { get; set; }
public RuleTrigger Trigger { get; set; }
public RuleAction Action { get; set; }
public string? Name { get; set; }
public bool? IsEnabled { get; set; }
}
}

9
backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs

@ -64,6 +64,15 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
RuleDef = RuleDef.Rename(e.Name);
}
if (e.IsEnabled == true)
{
RuleDef = RuleDef.Enable();
}
else
{
RuleDef = RuleDef.Disable();
}
break;
}

8
backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs

@ -14,11 +14,13 @@ namespace Squidex.Domain.Apps.Events.Rules
[EventType(nameof(RuleUpdated))]
public sealed class RuleUpdated : RuleEvent, IMigrated<IEvent>
{
public RuleTrigger Trigger { get; set; }
public string? Name { get; set; }
public RuleAction Action { get; set; }
public RuleTrigger? Trigger { get; set; }
public string Name { get; set; }
public RuleAction? Action { get; set; }
public bool? IsEnabled { get; set; }
public IEvent Migrate()
{

8
backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs

@ -9,6 +9,7 @@ using Newtonsoft.Json;
using Squidex.Domain.Apps.Core.Rules;
using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Areas.Api.Controllers.Rules.Models
{
@ -30,9 +31,14 @@ namespace Squidex.Areas.Api.Controllers.Rules.Models
[JsonConverter(typeof(RuleActionConverter))]
public RuleAction Action { get; set; }
/// <summary>
/// Enable or disable the rule.
/// </summary>
public bool? IsEnabled { get; set; }
public UpdateRule ToCommand(DomainId id)
{
var command = new UpdateRule { RuleId = id, Action = Action, Name = Name };
var command = SimpleMapper.Map(this, new UpdateRule { RuleId = id });
if (Trigger != null)
{

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs

@ -187,7 +187,7 @@ namespace Squidex.Domain.Apps.Core.Model.Apps
}
[Fact]
public void Should_remove_fallbacks_when_removing_language()
public void Should_remove_fallbacks_if_removing_language()
{
var config_1 = config_0.Set(Language.DE);
var config_2 = config_1.Set(Language.IT, true, Language.UK);

6
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs

@ -74,7 +74,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents
}
[Fact]
public void Should_be_equal_when_data_have_same_structure()
public void Should_be_equal_if_data_have_same_structure()
{
var lhs =
new ContentData()
@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents
}
[Fact]
public void Should_not_be_equal_when_data_have_not_same_structure()
public void Should_not_be_equal_if_data_have_not_same_structure()
{
var lhs =
new ContentData()
@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents
}
[Fact]
public void Should_be_equal_fields_when_they_have_same_value()
public void Should_be_equal_fields_if_they_have_same_value()
{
var lhs =
new ContentFieldData()

14
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs

@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_set_enabled_to_true_when_enabling()
public void Should_set_enabled_to_true_if_enabling()
{
var rule_1 = rule_0.Disable();
var rule_2 = rule_1.Enable();
@ -95,7 +95,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_set_enabled_to_false_when_disabling()
public void Should_set_enabled_to_false_if_disabling()
{
var rule_1 = rule_0.Disable();
var rule_2 = rule_1.Disable();
@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_replace_name_when_renaming()
public void Should_replace_name_if_renaming()
{
var rule_1 = rule_0.Rename("MyName");
var rule_2 = rule_1.Rename("MyName");
@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_replace_trigger_when_updating()
public void Should_replace_trigger_if_updating()
{
var newTrigger1 = new ContentChangedTriggerV2 { HandleAll = true };
var newTrigger2 = new ContentChangedTriggerV2 { HandleAll = true };
@ -138,13 +138,13 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_throw_exception_when_new_trigger_has_other_type()
public void Should_throw_exception_if_new_trigger_has_other_type()
{
Assert.Throws<ArgumentException>(() => rule_0.Update(new OtherTrigger()));
}
[Fact]
public void Should_replace_action_when_updating()
public void Should_replace_action_if_updating()
{
var newAction1 = new TestAction1 { Property = "NewValue" };
var newAction2 = new TestAction1 { Property = "NewValue" };
@ -160,7 +160,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
}
[Fact]
public void Should_throw_exception_when_new_action_has_other_type()
public void Should_throw_exception_if_new_action_has_other_type()
{
Assert.Throws<ArgumentException>(() => rule_0.Update(new TestAction2()));
}

4
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs

@ -366,7 +366,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas
}
[Fact]
public void Should_also_set_list_fields_when_reordered()
public void Should_also_set_list_fields_if_reordered()
{
var schema_1 = schema_0.SetFieldsInLists("2", "1");
var schema_2 = schema_1.SetFieldsInLists("1", "2");
@ -388,7 +388,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas
}
[Fact]
public void Should_also_set_reference_fields_when_reordered()
public void Should_also_set_reference_fields_if_reordered()
{
var schema_1 = schema_0.SetFieldsInReferences("2", "1");
var schema_2 = schema_1.SetFieldsInReferences("1", "2");

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs

@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
}
[Fact]
public void Should_be_equal_fields_when_they_have_same_value()
public void Should_be_equal_fields_if_they_have_same_value()
{
var lhs =
new ContentFieldData()

4
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs

@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
}
[Fact]
public void Should_return_field_data_when_excluding_changed_types_and_all_values_are_valid()
public void Should_return_field_data_if_excluding_changed_types_and_all_values_are_valid()
{
var field = Fields.Number(1, "number", Partitioning.Invariant);
@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
}
[Fact]
public void Should_return_null_when_excluding_changed_types_and_one_value_is_invalid()
public void Should_return_null_if_excluding_changed_types_and_one_value_is_invalid()
{
var field = Fields.Number(1, "number", Partitioning.Invariant);

4
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs

@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
[Theory]
[InlineData("other")]
[InlineData("**")]
public void Should_not_convert_asset_ids_when_field_name_does_not_match(string path)
public void Should_not_convert_asset_ids_if_field_name_does_not_match(string path)
{
var field = Fields.Assets(1, "assets", Partitioning.Invariant);
@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
[InlineData("parent")]
[InlineData("parent.other")]
[InlineData("other.assets")]
public void Should_not_convert_nested_asset_ids_when_field_name_does_not_match(string path)
public void Should_not_convert_nested_asset_ids_if_field_name_does_not_match(string path)
{
var field = Fields.Array(1, "parent", Partitioning.Invariant, Fields.Assets(11, "assets"));

24
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs

@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_not_enrich_with_default_values_when_string_is_empty()
public void Should_not_enrich_with_default_values_if_string_is_empty()
{
var data =
new ContentData()
@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_assets_field_when_set()
public void Should_get_default_value_from_assets_field_if_set()
{
var field =
Fields.Assets(1, "1", Partitioning.Invariant,
@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_assets_field_when_localized()
public void Should_get_default_value_from_assets_field_if_localized()
{
var field =
Fields.Assets(1, "1", Partitioning.Invariant,
@ -127,7 +127,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_boolean_field_when_localized()
public void Should_get_default_value_from_boolean_field_if_localized()
{
var field =
Fields.Boolean(1, "1", Partitioning.Invariant,
@ -154,7 +154,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_datetime_field_when_set_to_today()
public void Should_get_default_value_from_datetime_field_if_set_to_today()
{
var field =
Fields.DateTime(1, "1", Partitioning.Invariant,
@ -164,7 +164,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_datetime_field_when_set_to_now()
public void Should_get_default_value_from_datetime_field_if_set_to_now()
{
var field =
Fields.DateTime(1, "1", Partitioning.Invariant,
@ -174,7 +174,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_datetime_field_when_localized()
public void Should_get_default_value_from_datetime_field_if_localized()
{
var field =
Fields.DateTime(1, "1", Partitioning.Invariant,
@ -221,7 +221,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_number_field_when_localized()
public void Should_get_default_value_from_number_field_if_localized()
{
var field =
Fields.Number(1, "1", Partitioning.Invariant,
@ -248,7 +248,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_references_field_when_set()
public void Should_get_default_value_from_references_field_if_set()
{
var field =
Fields.References(1, "1", Partitioning.Invariant,
@ -258,7 +258,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_references_field_when_localized()
public void Should_get_default_value_from_references_field_if_localized()
{
var field =
Fields.References(1, "1", Partitioning.Invariant,
@ -285,7 +285,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_string_field_when_localized()
public void Should_get_default_value_from_string_field_if_localized()
{
var field =
Fields.String(1, "1", Partitioning.Invariant,
@ -312,7 +312,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues
}
[Fact]
public void Should_get_default_value_from_tags_field_when_localized()
public void Should_get_default_value_from_tags_field_if_localized()
{
var field =
Fields.Tags(1, "1", Partitioning.Invariant,

10
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs

@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
[Theory]
[MemberData(nameof(ReferencingFields))]
public void Should_return_empty_list_from_field_when_value_item_is_invalid(IField field)
public void Should_return_empty_list_from_field_if_value_item_is_invalid(IField field)
{
var result = field.GetReferencedIds(JsonValue.Array(1)).ToArray();
@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
[Theory]
[MemberData(nameof(ReferencingFields))]
public void Should_return_empty_list_from_field_when_value_is_empty(IField field)
public void Should_return_empty_list_from_field_if_value_is_empty(IField field)
{
var result = field.GetReferencedIds(JsonValue.Array()).ToArray();
@ -164,7 +164,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
[Theory]
[MemberData(nameof(ReferencingFields))]
public void Should_return_empty_list_from_field_when_value_is_json_null(IField field)
public void Should_return_empty_list_from_field_if_value_is_json_null(IField field)
{
var result = field.GetReferencedIds(null).ToArray();
@ -173,7 +173,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
[Theory]
[MemberData(nameof(ReferencingFields))]
public void Should_return_empty_list_from_field_when_value_is_null(IField field)
public void Should_return_empty_list_from_field_if_value_is_null(IField field)
{
var result = field.GetReferencedIds(null).ToArray();
@ -196,7 +196,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
[Theory]
[MemberData(nameof(ReferencingFields))]
public void Should_return_same_value_from_field_when_value_is_json_null(IField field)
public void Should_return_same_value_from_field_if_value_is_json_null(IField field)
{
var result = ValueReferencesConverter.CleanReferences(RandomIds())(JsonValue.Null, field, null);

38
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs

@ -314,7 +314,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"Download at {{event.id | assetContentUrl | default: 'null'}}"
)]
[InlineData("Liquid(Download at {{event | assetContentUrl | default: 'null'}})")]
public async Task Should_return_null_when_asset_content_url_not_found(string script)
public async Task Should_return_null_if_asset_content_url_not_found(string script)
{
var @event = new EnrichedContentEvent();
@ -348,7 +348,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"Download at {{event.id | assetContentAppUrl | default: 'null'}}"
)]
[InlineData("Liquid(Download at {{event | assetContentAppUrl | default: 'null'}})")]
public async Task Should_return_null_when_asset_content_app_url_not_found(string script)
public async Task Should_return_null_if_asset_content_app_url_not_found(string script)
{
var @event = new EnrichedContentEvent();
@ -382,7 +382,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"Download at {{event.id | assetContentSlugUrl | default: 'null'}}"
)]
[InlineData("Liquid(Download at {{event | assetContentSlugUrl | default: 'null'}})")]
public async Task Should_return_null_when_asset_content_slug_url_not_found(string script)
public async Task Should_return_null_if_asset_content_slug_url_not_found(string script)
{
var @event = new EnrichedContentEvent();
@ -414,7 +414,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"Go to ${contentUrl()}",
"Go to {{event.id | contentUrl | default: 'null'}}"
)]
public async Task Should_return_null_when_content_url_when_not_found(string script)
public async Task Should_return_null_if_content_url_if_not_found(string script)
{
var @event = new EnrichedAssetEvent();
@ -430,7 +430,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${contentAction()}",
"{{event.status}}"
)]
public async Task Should_format_content_status_when_found(string script)
public async Task Should_format_content_status_if_found(string script)
{
var @event = new EnrichedContentEvent { Status = Status.Published };
@ -446,7 +446,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${contentAction()}",
"{{event.status | default: 'null'}}"
)]
public async Task Should_return_null_when_content_status_not_found(string script)
public async Task Should_return_null_if_content_status_not_found(string script)
{
var @event = new EnrichedAssetEvent();
@ -462,7 +462,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.type}",
"{{event.type}}"
)]
public async Task Should_format_content_actions_when_found(string script)
public async Task Should_format_content_actions_if_found(string script)
{
var @event = new EnrichedContentEvent { Type = EnrichedContentEventType.Created };
@ -478,7 +478,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${contentAction()}",
null
)]
public async Task Should_return_null_when_content_action_not_found(string script)
public async Task Should_return_null_if_content_action_not_found(string script)
{
var @event = new EnrichedAssetEvent();
@ -517,7 +517,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.country.iv}",
"{{event.data.country.iv | default: 'null'}}"
)]
public async Task Should_return_null_when_field_not_found(string script)
public async Task Should_return_null_if_field_not_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -540,7 +540,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.country.iv}",
"{{event.data.country.iv | default: 'null'}}"
)]
public async Task Should_return_null_when_partition_not_found(string script)
public async Task Should_return_null_if_partition_not_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -563,7 +563,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.country.iv[10]}",
"{{event.data.country.iv[10] | default: 'null'}}"
)]
public async Task Should_return_null_when_array_item_not_found(string script)
public async Task Should_return_null_if_array_item_not_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -586,7 +586,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.country.iv.Location}",
"{{event.data.country.iv.Location | default: 'null'}}"
)]
public async Task Should_return_null_when_property_not_found(string script)
public async Task Should_return_null_if_property_not_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -609,7 +609,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.city.iv}",
"{{event.data.city.iv}}"
)]
public async Task Should_return_plain_value_when_found(string script)
public async Task Should_return_plain_value_if_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -632,7 +632,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.city.iv[0]}",
"{{event.data.city.iv[0]}}"
)]
public async Task Should_return_plain_value_from_array_when_found(string script)
public async Task Should_return_plain_value_from_array_if_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -655,7 +655,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${event.data.city.iv.name}",
"{{event.data.city.iv.name}}"
)]
public async Task Should_return_plain_value_from_object_when_found(string script)
public async Task Should_return_plain_value_from_object_if_found(string script)
{
var @event = new EnrichedContentEvent
{
@ -678,7 +678,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${JSON.stringify(event.data.city.iv)}",
"{{event.data.city.iv}}"
)]
public async Task Should_return_json_string_when_object(string script)
public async Task Should_return_json_string_if_object(string script)
{
var @event = new EnrichedContentEvent
{
@ -701,7 +701,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${JSON.stringify(event.data.city.iv)}",
"{{event.data.city.iv}}"
)]
public async Task Should_return_json_string_when_array(string script)
public async Task Should_return_json_string_if_array(string script)
{
var @event = new EnrichedContentEvent
{
@ -724,7 +724,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${JSON.stringify(event.data)}",
null
)]
public async Task Should_return_json_string_when_data(string script)
public async Task Should_return_json_string_if_data(string script)
{
var @event = new EnrichedContentEvent
{
@ -778,7 +778,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
"${CONTENT_DATA.time.iv | timestamp}",
null,
"{{event.data.time.iv | timestamp}}")]
public async Task Should_return_timestamp_when_string(string script)
public async Task Should_return_timestamp_if_string(string script)
{
var @event = new EnrichedContentEvent
{

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs

@ -271,7 +271,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
}
[Fact]
public async Task Should_return_json_string_when_array()
public async Task Should_return_json_string_if_array()
{
var @event = new EnrichedContentEvent
{

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs

@ -491,7 +491,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
}
[Fact]
public async Task Should_return_succeeded_job_with_full_dump_when_handler_returns_no_exception()
public async Task Should_return_succeeded_job_with_full_dump_if_handler_returns_no_exception()
{
A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A<ValidData>.That.Matches(x => x.Value == 10), A<CancellationToken>._))
.Returns(Result.Success(actionDump));
@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
}
[Fact]
public async Task Should_return_failed_job_with_full_dump_when_handler_returns_exception()
public async Task Should_return_failed_job_with_full_dump_if_handler_returns_exception()
{
A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A<ValidData>.That.Matches(x => x.Value == 10), A<CancellationToken>._))
.Returns(Result.Failed(new InvalidOperationException(), actionDump));
@ -519,7 +519,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
}
[Fact]
public async Task Should_return_timedout_job_with_full_dump_when_exception_from_handler_indicates_timeout()
public async Task Should_return_timedout_job_with_full_dump_if_exception_from_handler_indicates_timeout()
{
A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A<ValidData>.That.Matches(x => x.Value == 10), A<CancellationToken>._))
.Returns(Result.Failed(new TimeoutException(), actionDump));
@ -535,7 +535,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
}
[Fact]
public async Task Should_create_exception_details_when_job_to_execute_failed()
public async Task Should_create_exception_details_if_job_to_execute_failed()
{
var ex = new InvalidOperationException();

26
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs

@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
public class ContentDataObjectTests
{
[Fact]
public void Should_update_data_when_setting_field()
public void Should_update_data_if_setting_field()
{
var original = new ContentData();
@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_lazy_field()
public void Should_update_data_if_setting_lazy_field()
{
var original = new ContentData();
@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_throw_exception_when_assigning_non_object_as_field()
public void Should_throw_exception_if_assigning_non_object_as_field()
{
var original = new ContentData();
@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_deleting_field()
public void Should_update_data_if_deleting_field()
{
var original =
new ContentData()
@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_field_value_with_string()
public void Should_update_data_if_setting_field_value_with_string()
{
var original =
new ContentData()
@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_field_value_with_number()
public void Should_update_data_if_setting_field_value_with_number()
{
var original =
new ContentData()
@ -129,7 +129,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_field_value_with_boolean()
public void Should_update_data_if_setting_field_value_with_boolean()
{
var original =
new ContentData()
@ -149,7 +149,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_field_value_with_array()
public void Should_update_data_if_setting_field_value_with_array()
{
var original =
new ContentData()
@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_setting_field_value_with_object()
public void Should_update_data_if_setting_field_value_with_object()
{
var original =
new ContentData()
@ -189,7 +189,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_throw_when_defining_property_for_field()
public void Should_throw_if_defining_property_for_field()
{
var original =
new ContentData()
@ -208,7 +208,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_update_data_when_deleting_field_value()
public void Should_update_data_if_deleting_field_value()
{
var original =
new ContentData()
@ -259,7 +259,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_throw_exceptions_when_changing_objects()
public void Should_throw_exceptions_if_changing_objects()
{
var original =
new ContentData()
@ -272,7 +272,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Should_not_throw_exceptions_when_changing_arrays()
public void Should_not_throw_exceptions_if_changing_arrays()
{
var original =
new ContentData()

12
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs

@ -185,7 +185,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_validation_exception_when_calling_reject()
public async Task Should_throw_validation_exception_if_calling_reject()
{
const string script = @"
reject()
@ -204,7 +204,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_validation_exception_when_calling_reject_with_message()
public async Task Should_throw_validation_exception_if_calling_reject_with_message()
{
const string script = @"
reject('Not valid')
@ -223,7 +223,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_security_exception_when_calling_reject()
public async Task Should_throw_security_exception_if_calling_reject()
{
const string script = @"
disallow()
@ -242,7 +242,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_security_exception_when_calling_reject_with_message()
public async Task Should_throw_security_exception_if_calling_reject_with_message()
{
const string script = @"
disallow('Operation not allowed')
@ -261,7 +261,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_exception_when_getJson_url_is_null()
public async Task Should_throw_exception_if_getJson_url_is_null()
{
const string script = @"
getJSON(null, function(result) {
@ -275,7 +275,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task Should_throw_exception_when_getJson_callback_is_null()
public async Task Should_throw_exception_if_getJson_callback_is_null()
{
const string script = @"
var url = 'http://squidex.io';

20
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs

@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_return_original_content_when_script_failed()
public async Task TransformAsync_should_return_original_content_if_script_failed()
{
var content = new ContentData();
var context = new ScriptVars { Data = content };
@ -148,7 +148,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_throw_exception_when_script_failed()
public async Task TransformAsync_should_throw_exception_if_script_failed()
{
var content = new ContentData();
var context = new ScriptVars { Data = content };
@ -161,7 +161,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_return_original_content_when_not_replaced()
public async Task TransformAsync_should_return_original_content_if_not_replaced()
{
var content = new ContentData();
var context = new ScriptVars { Data = content };
@ -176,7 +176,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_return_original_content_when_not_replaced_async()
public async Task TransformAsync_should_return_original_content_if_not_replaced_async()
{
var content = new ContentData();
var context = new ScriptVars { Data = content };
@ -254,7 +254,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_not_ignore_transformation_when_async_not_set()
public async Task TransformAsync_should_not_ignore_transformation_if_async_not_set()
{
var content = new ContentData();
var context = new ScriptVars { Data = content, Operation = "MyOperation" };
@ -276,7 +276,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public async Task TransformAsync_should_timeout_when_replace_never_called()
public async Task TransformAsync_should_timeout_if_replace_never_called()
{
var content = new ContentData();
var context = new ScriptVars { Data = content, Operation = "MyOperation" };
@ -372,7 +372,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Evaluate_should_return_true_when_expression_match()
public void Evaluate_should_return_true_if_expression_match()
{
const string script = @"
value.i == 2
@ -389,7 +389,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Evaluate_should_return_true_when_status_match()
public void Evaluate_should_return_true_if_status_match()
{
const string script = @"
value.status == 'Published'
@ -406,7 +406,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Evaluate_should_return_false_when_expression_match()
public void Evaluate_should_return_false_if_expression_match()
{
const string script = @"
value.i == 3
@ -423,7 +423,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting
}
[Fact]
public void Evaluate_should_return_false_when_script_is_invalid()
public void Evaluate_should_return_false_if_script_is_invalid()
{
const string script = @"
function();

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs

@ -191,7 +191,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Templates
}
[Fact]
public async Task Should_throw_exception_when_template_invalid()
public async Task Should_throw_exception_if_template_invalid()
{
var template = "{% for x of event %}";

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs

@ -71,7 +71,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators
}
[Fact]
public async Task Should_add_timeout_error_when_regex_is_too_slow()
public async Task Should_add_timeout_error_if_regex_is_too_slow()
{
var sut = new PatternValidator(@"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$");

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs

@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_call_grain_when_retrieving_settings()
public async Task Should_call_grain_if_retrieving_settings()
{
var settings = JsonValue.Object();
@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_call_grain_when_setting_value()
public async Task Should_call_grain_if_setting_value()
{
var value = JsonValue.Object();
@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_call_grain_when_replacing_settings()
public async Task Should_call_grain_if_replacing_settings()
{
var value = JsonValue.Object();
@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_call_grain_when_removing_value()
public async Task Should_call_grain_if_removing_value()
{
await sut.RemoveAsync(DomainId.NewGuid(), "user", "the.path");

16
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs

@ -103,7 +103,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_throw_exception_when_no_reservation_token_returned()
public async Task Should_throw_exception_if_no_reservation_token_returned()
{
const string appName = "my-app";
@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_not_cleanup_reservation_when_no_reservation_token_hold()
public async Task Should_not_cleanup_reservation_if_no_reservation_token_hold()
{
await sut.CleanupRestoreErrorAsync(appId);
@ -163,7 +163,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_map_contributor_id_when_assigned()
public async Task Should_map_contributor_id_if_assigned()
{
var context = CreateRestoreContext();
@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_ignore_contributor_event_when_assigned_user_not_mapped()
public async Task Should_ignore_contributor_event_if_assigned_user_not_mapped()
{
var context = CreateRestoreContext();
@ -195,7 +195,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_map_contributor_id_when_revoked()
public async Task Should_map_contributor_id_if_revoked()
{
var context = CreateRestoreContext();
@ -211,7 +211,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_ignore_contributor_event_when_removed_user_not_mapped()
public async Task Should_ignore_contributor_event_if_removed_user_not_mapped()
{
var context = CreateRestoreContext();
@ -227,7 +227,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_ignore_exception_when_app_image_to_backup_does_not_exist()
public async Task Should_ignore_exception_if_app_image_to_backup_does_not_exist()
{
var imageStream = new MemoryStream();
@ -275,7 +275,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
}
[Fact]
public async Task Should_ignore_exception_when_app_image_cannot_be_overriden()
public async Task Should_ignore_exception_if_app_image_cannot_be_overriden()
{
var imageStream = new MemoryStream();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs

@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
}
[Fact]
public async Task Should_throw_exception_when_file_to_upload_is_not_an_image()
public async Task Should_throw_exception_if_file_to_upload_is_not_an_image()
{
var file = new NoopAssetFile();

26
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs

@ -218,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_add_app_to_indexes_when_creating()
public async Task Should_add_app_to_indexes_if_creating()
{
var token = RandomHash.Simple();
@ -273,7 +273,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_clear_reservation_when_app_creation_failed()
public async Task Should_clear_reservation_if_app_creation_failed()
{
var token = RandomHash.Simple();
@ -298,7 +298,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_not_add_to_indexes_when_name_is_taken()
public async Task Should_not_add_to_indexes_if_name_is_taken()
{
A.CallTo(() => indexByName.ReserveAsync(appId.Id, appId.Name))
.Returns(Task.FromResult<string?>(null));
@ -322,7 +322,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_not_add_to_indexes_when_name_is_invalid()
public async Task Should_not_add_to_indexes_if_name_is_invalid()
{
var command = Create("INVALID");
@ -343,7 +343,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_add_app_to_index_when_contributor_assigned()
public async Task Should_add_app_to_index_if_contributor_assigned()
{
CreateApp();
@ -360,7 +360,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_update_index_when_app_is_updated()
public async Task Should_update_index_if_app_is_updated()
{
var (_, appGrain) = CreateApp();
@ -377,7 +377,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_update_index_with_result_when_app_is_updated()
public async Task Should_update_index_with_result_if_app_is_updated()
{
var (app, appGrain) = CreateApp();
@ -394,7 +394,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_remove_from_user_index_when_contributor_removed()
public async Task Should_remove_from_user_index_if_contributor_removed()
{
CreateApp();
@ -411,7 +411,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_remove_app_from_indexes_when_app_gets_archived()
public async Task Should_remove_app_from_indexes_if_app_gets_archived()
{
CreateApp(isArchived: true);
@ -431,7 +431,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_also_remove_app_from_client_index_when_created_by_client()
public async Task Should_also_remove_app_from_client_index_if_created_by_client()
{
CreateApp(fromClient: true);
@ -454,7 +454,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_forward_call_when_rebuilding_for_contributors1()
public async Task Should_forward_call_if_rebuilding_for_contributors1()
{
var apps = new HashSet<DomainId>();
@ -465,7 +465,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_forward_call_when_rebuilding_for_contributors2()
public async Task Should_forward_call_if_rebuilding_for_contributors2()
{
var users = new HashSet<string> { userId };
@ -476,7 +476,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
}
[Fact]
public async Task Should_forward_call_when_rebuilding()
public async Task Should_forward_call_if_rebuilding()
{
var apps = new Dictionary<string, DomainId>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs

@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans
}
[Fact]
public async Task Should_do_nothing_when_changing_plan()
public async Task Should_do_nothing_if_changing_plan()
{
await sut.ChangePlanAsync(null!, null!, null, null);
}

12
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs

@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_not_trigger_precheck_when_event_type_not_correct()
public void Should_not_trigger_precheck_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -111,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_trigger_precheck_when_event_type_correct()
public void Should_trigger_precheck_if_event_type_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_not_trigger_check_when_event_type_not_correct()
public void Should_not_trigger_check_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -133,7 +133,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_trigger_check_when_condition_is_empty()
public void Should_trigger_check_if_condition_is_empty()
{
TestForCondition(string.Empty, trigger =>
{
@ -144,7 +144,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_trigger_check_when_condition_matchs()
public void Should_trigger_check_if_condition_matchs()
{
TestForCondition("true", trigger =>
{
@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public void Should_not_trigger_check_when_condition_does_not_matchs()
public void Should_not_trigger_check_if_condition_does_not_matchs()
{
TestForCondition("false", trigger =>
{

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs

@ -55,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public async Task Should_not_delete_assets_when_event_restored()
public async Task Should_not_delete_assets_if_event_restored()
{
var @event = new AssetDeleted { AppId = appId, AssetId = DomainId.NewGuid() };

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs

@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
[Theory]
[MemberData(nameof(EventData))]
public async Task Should_increase_usage_when_asset_created(AssetEvent @event, long sizeDiff, long countDiff)
public async Task Should_increase_usage_if_asset_created(AssetEvent @event, long sizeDiff, long countDiff)
{
var date = DateTime.UtcNow.Date.AddDays(13);

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs

@ -110,7 +110,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
}
[Fact]
public async Task Upsert_should_create_events_and_set_intitial_state_when_not_found()
public async Task Upsert_should_create_events_and_set_intitial_state_if_not_found()
{
var command = new UpsertAsset { File = file, FileHash = "NewHash" };
@ -138,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
}
[Fact]
public async Task Upsert_should_create_events_and_update_file_state_when_found()
public async Task Upsert_should_create_events_and_update_file_state_if_found()
{
var command = new UpsertAsset { File = file, FileHash = "NewHash" };

6
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs

@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_annotating()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_annotating()
{
SetupContext(Permissions.AppAssetsRead);
@ -106,7 +106,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_moving()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_moving()
{
SetupContext(Permissions.AppAssetsRead);
@ -143,7 +143,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_deletion()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_deletion()
{
SetupContext(Permissions.AppAssetsRead);

18
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs

@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
private readonly NamedId<DomainId> appId = NamedId.Of(DomainId.NewGuid(), "my-app");
[Fact]
public async Task CanCreate_should_throw_exception_when_folder_name_not_defined()
public async Task CanCreate_should_throw_exception_if_folder_name_not_defined()
{
var command = new CreateAssetFolder { AppId = appId };
@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanCreate_should_throw_exception_when_folder_not_found()
public async Task CanCreate_should_throw_exception_if_folder_not_found()
{
var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid() };
@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanCreate_should_not_throw_exception_when_folder_found()
public async Task CanCreate_should_not_throw_exception_if_folder_found()
{
var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid() };
@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanCreate_should_not_throw_exception_when_added_to_root()
public async Task CanCreate_should_not_throw_exception_if_added_to_root()
{
var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder" };
@ -66,7 +66,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_throw_exception_when_adding_to_its_own_child()
public async Task CanMove_should_throw_exception_if_adding_to_its_own_child()
{
var id = DomainId.NewGuid();
@ -84,7 +84,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_throw_exception_when_folder_not_found()
public async Task CanMove_should_throw_exception_if_folder_not_found()
{
var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() };
@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_folder_found()
public async Task CanMove_should_not_throw_exception_if_folder_found()
{
var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() };
@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed()
public async Task CanMove_should_not_throw_exception_if_folder_has_not_changed()
{
var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() };
@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_added_to_root()
public async Task CanMove_should_not_throw_exception_if_added_to_root()
{
var command = new MoveAssetFolder { AppId = appId };

10
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs

@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
private readonly NamedId<DomainId> appId = NamedId.Of(DomainId.NewGuid(), "my-app");
[Fact]
public async Task CanMove_should_throw_exception_when_folder_not_found()
public async Task CanMove_should_throw_exception_if_folder_not_found()
{
var parentId = DomainId.NewGuid();
@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_folder_not_found_but_optimized()
public async Task CanMove_should_not_throw_exception_if_folder_not_found_but_optimized()
{
var parentId = DomainId.NewGuid();
@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_folder_found()
public async Task CanMove_should_not_throw_exception_if_folder_found()
{
var parentId = DomainId.NewGuid();
@ -66,7 +66,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed()
public async Task CanMove_should_not_throw_exception_if_folder_has_not_changed()
{
var parentId = DomainId.NewGuid();
@ -76,7 +76,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
}
[Fact]
public async Task CanMove_should_not_throw_exception_when_added_to_root()
public async Task CanMove_should_not_throw_exception_if_added_to_root()
{
var command = new MoveAsset { AppId = appId };

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs

@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries
}
[Fact]
public async Task Should_skip_total_when_set_in_context()
public async Task Should_skip_total_if_set_in_context()
{
var q = await sut.ParseAsync(requestContext.Clone(b => b.WithoutTotal()), Q.Empty);
@ -142,7 +142,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries
}
[Fact]
public async Task Should_not_fail_when_tags_not_found()
public async Task Should_not_fail_if_tags_not_found()
{
A.CallTo(() => tagService.GetTagIdsAsync(appId.Id, TagGroups.Assets, A<HashSet<string>>.That.Contains("name1")))
.Returns(new Dictionary<string, string>());

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs

@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
[Fact]
public async Task Should_Not_invoke_delete_commands_when_event_restored()
public async Task Should_Not_invoke_delete_commands_if_event_restored()
{
var @event = new AssetFolderDeleted { AppId = appId, AssetFolderId = DomainId.NewGuid() };

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs

@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
}
[Fact]
public async Task Should_call_grain_when_restoring_backup()
public async Task Should_call_grain_if_restoring_backup()
{
var grain = A.Fake<IRestoreGrain>();

28
backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs

@ -45,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_return_false_when_asking_for_snapshot_support()
public void Should_return_false_if_asking_for_snapshot_support()
{
Assert.False(sut.CanCreateSnapshotEvents);
}
@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public async Task Should_not_create_enriched_events_when_users_cannot_be_resolved()
public async Task Should_not_create_enriched_events_if_users_cannot_be_resolved()
{
var user1 = UserMocks.User("1");
var user2 = UserMocks.User("2");
@ -94,7 +94,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public async Task Should_not_create_enriched_events_when_mentions_is_null()
public async Task Should_not_create_enriched_events_if_mentions_is_null()
{
var envelope = Envelope.Create<AppEvent>(new CommentCreated { Mentions = null });
@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public async Task Should_not_create_enriched_events_when_mentions_is_empty()
public async Task Should_not_create_enriched_events_if_mentions_is_empty()
{
var envelope = Envelope.Create<AppEvent>(new CommentCreated { Mentions = Array.Empty<string>() });
@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_not_trigger_precheck_when_event_type_not_correct()
public void Should_not_trigger_precheck_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_trigger_precheck_when_event_type_correct()
public void Should_trigger_precheck_if_event_type_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -168,7 +168,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_not_trigger_check_when_event_type_not_correct()
public void Should_not_trigger_check_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_trigger_check_when_condition_is_empty()
public void Should_trigger_check_if_condition_is_empty()
{
TestForCondition(string.Empty, trigger =>
{
@ -190,7 +190,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_trigger_check_when_condition_matchs()
public void Should_trigger_check_if_condition_matchs()
{
TestForCondition("true", trigger =>
{
@ -201,7 +201,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_not_trigger_check_when_condition_does_not_matchs()
public void Should_not_trigger_check_if_condition_does_not_matchs()
{
TestForCondition("false", trigger =>
{
@ -212,7 +212,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_trigger_check_when_email_is_correct()
public void Should_trigger_check_if_email_is_correct()
{
TestForRealCondition("event.mentionedUser.email == '1@email.com'", (handler, trigger) =>
{
@ -225,7 +225,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_not_trigger_check_when_email_is_correct()
public void Should_not_trigger_check_if_email_is_correct()
{
TestForRealCondition("event.mentionedUser.email == 'other@squidex.io'", (handler, trigger) =>
{
@ -238,7 +238,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_trigger_check_when_text_is_urgent()
public void Should_trigger_check_if_text_is_urgent()
{
TestForRealCondition("event.text.indexOf('urgent') >= 0", (handler, trigger) =>
{
@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
}
[Fact]
public void Should_not_trigger_check_when_text_is_not_urgent()
public void Should_not_trigger_check_if_text_is_not_urgent()
{
TestForRealCondition("event.text.indexOf('urgent') >= 0", (handler, trigger) =>
{

28
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs

@ -60,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_return_true_when_asking_for_snapshot_support()
public void Should_return_true_if_asking_for_snapshot_support()
{
Assert.True(sut.CanCreateSnapshotEvents);
}
@ -134,7 +134,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public async Task Should_enrich_with_old_data_when_updated()
public async Task Should_enrich_with_old_data_if_updated()
{
var @event = new ContentUpdated { AppId = appId, ContentId = DomainId.NewGuid(), SchemaId = schemaMatch };
@ -158,7 +158,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_precheck_when_event_type_not_correct()
public void Should_not_trigger_precheck_if_event_type_not_correct()
{
TestForTrigger(handleAll: true, schemaId: null, condition: null, action: trigger =>
{
@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_precheck_when_trigger_contains_no_schemas()
public void Should_not_trigger_precheck_if_trigger_contains_no_schemas()
{
TestForTrigger(handleAll: false, schemaId: null, condition: null, action: trigger =>
{
@ -180,7 +180,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_trigger_precheck_when_handling_all_events()
public void Should_trigger_precheck_if_handling_all_events()
{
TestForTrigger(handleAll: true, schemaId: schemaMatch, condition: null, action: trigger =>
{
@ -191,7 +191,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_trigger_precheck_when_condition_is_empty()
public void Should_trigger_precheck_if_condition_is_empty()
{
TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: string.Empty, action: trigger =>
{
@ -202,7 +202,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_precheck_when_schema_id_does_not_match()
public void Should_not_trigger_precheck_if_schema_id_does_not_match()
{
TestForTrigger(handleAll: false, schemaId: schemaNonMatch, condition: null, action: trigger =>
{
@ -213,7 +213,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_check_when_event_type_not_correct()
public void Should_not_trigger_check_if_event_type_not_correct()
{
TestForTrigger(handleAll: true, schemaId: null, condition: null, action: trigger =>
{
@ -224,7 +224,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_check_when_trigger_contains_no_schemas()
public void Should_not_trigger_check_if_trigger_contains_no_schemas()
{
TestForTrigger(handleAll: false, schemaId: null, condition: null, action: trigger =>
{
@ -235,7 +235,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_trigger_check_when_handling_all_events()
public void Should_trigger_check_if_handling_all_events()
{
TestForTrigger(handleAll: true, schemaId: schemaMatch, condition: null, action: trigger =>
{
@ -246,7 +246,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_trigger_check_when_condition_is_empty()
public void Should_trigger_check_if_condition_is_empty()
{
TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: string.Empty, action: trigger =>
{
@ -257,7 +257,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_trigger_check_when_condition_matchs()
public void Should_trigger_check_if_condition_matchs()
{
TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: "true", action: trigger =>
{
@ -268,7 +268,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_check_when_schema_id_does_not_match()
public void Should_not_trigger_check_if_schema_id_does_not_match()
{
TestForTrigger(handleAll: false, schemaId: schemaNonMatch, condition: null, action: trigger =>
{
@ -279,7 +279,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public void Should_not_trigger_check_when_condition_does_not_matchs()
public void Should_not_trigger_check_if_condition_does_not_matchs()
{
TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: "false", action: trigger =>
{

42
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs

@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Create_should_not_change_status_when_set_to_initial()
public async Task Create_should_not_change_status_if_set_to_initial()
{
var command = new CreateContent { Data = data, Status = Status.Draft };
@ -178,7 +178,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Create_should_change_status_when_set()
public async Task Create_should_change_status_if_set()
{
var command = new CreateContent { Data = data, Status = Status.Archived };
@ -224,7 +224,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Create_should_throw_exception_when_invalid_data_is_passed()
public async Task Create_should_throw_exception_if_invalid_data_is_passed()
{
var command = new CreateContent { Data = invalidData };
@ -232,7 +232,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_create_content_when_not_found()
public async Task Upsert_should_create_content_if_not_found()
{
var command = new UpsertContent { Data = data };
@ -255,7 +255,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_not_change_status_on_create_when_status_set_to_initial()
public async Task Upsert_should_not_change_status_on_create_if_status_set_to_initial()
{
var command = new UpsertContent { Data = data };
@ -278,7 +278,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_change_status_on_create_when_status_set()
public async Task Upsert_should_change_status_on_create_if_status_set()
{
var command = new UpsertContent { Data = data, Status = Status.Archived };
@ -302,7 +302,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_update_content_when_found()
public async Task Upsert_should_update_content_if_found()
{
var command = new UpsertContent { Data = otherData };
@ -324,7 +324,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_not_change_status_on_update_when_status_set_to_initial()
public async Task Upsert_should_not_change_status_on_update_if_status_set_to_initial()
{
var command = new UpsertContent { Data = otherData, Status = Status.Draft };
@ -346,7 +346,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Upsert_should_change_status_on_update_when_status_set()
public async Task Upsert_should_change_status_on_update_if_status_set()
{
var command = new UpsertContent { Data = otherData, Status = Status.Archived };
@ -426,7 +426,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Update_should_create_events_and_update_new_version_when_draft_available()
public async Task Update_should_create_events_and_update_new_version_if_draft_available()
{
var command = new UpdateContent { Data = otherData };
@ -467,7 +467,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Update_should_throw_exception_when_invalid_data_is_passed()
public async Task Update_should_throw_exception_if_invalid_data_is_passed()
{
var command = new UpdateContent { Data = invalidData };
@ -499,7 +499,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Patch_should_create_events_and_update_new_version_when_draft_available()
public async Task Patch_should_create_events_and_update_new_version_if_draft_available()
{
var command = new PatchContent { Data = patch };
@ -540,7 +540,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_update_status_when_published()
public async Task ChangeStatus_should_create_events_and_update_status_if_published()
{
var command = new ChangeContentStatus { Status = Status.Archived };
@ -562,7 +562,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_update_status_when_changed()
public async Task ChangeStatus_should_create_events_and_update_status_if_changed()
{
var command = new ChangeContentStatus { Status = Status.Archived };
@ -584,7 +584,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_update_status_when_unpublished()
public async Task ChangeStatus_should_create_events_and_update_status_if_unpublished()
{
var command = new ChangeContentStatus { Status = Status.Draft };
@ -607,7 +607,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_also_update_when_script_changes_data()
public async Task ChangeStatus_should_also_update_if_script_changes_data()
{
var command = new ChangeContentStatus { Status = Status.Draft };
@ -635,7 +635,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_update_new_version_when_draft_available()
public async Task ChangeStatus_should_create_events_and_update_new_version_if_draft_available()
{
var command = new ChangeContentStatus { Status = Status.Archived };
@ -659,7 +659,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_delete_new_version_when_available()
public async Task ChangeStatus_should_create_events_and_delete_new_version_if_available()
{
var command = new ChangeContentStatus { Status = Status.Published };
@ -683,7 +683,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_create_events_and_set_schedule_when_duetime_set()
public async Task ChangeStatus_create_events_and_set_schedule_if_duetime_set()
{
var dueTime = Instant.MaxValue;
@ -710,7 +710,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_refresh_properties_and_unset_schedule_when_completed()
public async Task ChangeStatus_should_refresh_properties_and_unset_schedule_if_completed()
{
var dueTime = Instant.MaxValue;
@ -738,7 +738,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task ChangeStatus_should_create_events_and_unset_schedule_when_failed()
public async Task ChangeStatus_should_create_events_and_unset_schedule_if_failed()
{
var dueTime = Instant.MaxValue;

18
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs

@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_exception_when_content_cannot_be_resolved()
public async Task Should_throw_exception_if_content_cannot_be_resolved()
{
SetupContext(Permissions.AppContentsUpdateOwn);
@ -77,7 +77,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_exception_when_query_resolves_multiple_contents()
public async Task Should_throw_exception_if_query_resolves_multiple_contents()
{
var requestContext = SetupContext(Permissions.AppContentsUpdateOwn);
@ -207,7 +207,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_upsert_content_when_id_defined()
public async Task Should_upsert_content_if_id_defined()
{
SetupContext(Permissions.AppContentsUpsert);
@ -264,7 +264,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_creating()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_creating()
{
SetupContext(Permissions.AppContentsReadOwn);
@ -301,7 +301,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_updating()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_updating()
{
SetupContext(Permissions.AppContentsReadOwn);
@ -338,7 +338,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_patching()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_patching()
{
SetupContext(Permissions.AppContentsReadOwn);
@ -392,7 +392,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_changing_status()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_changing_status()
{
SetupContext(Permissions.AppContentsReadOwn);
@ -429,7 +429,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_validation()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_validation()
{
SetupContext(Permissions.AppContentsDeleteOwn);
@ -466,7 +466,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
}
[Fact]
public async Task Should_throw_security_exception_when_user_has_no_permission_for_deletion()
public async Task Should_throw_security_exception_if_user_has_no_permission_for_deletion()
{
SetupContext(Permissions.AppContentsReadOwn);

26
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs

@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public void Should_throw_exception_when_draft_already_created()
public void Should_throw_exception_if_draft_already_created()
{
var context = CreateContext(CreateDraftContent(Status.Draft), normalSchema);
@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public void Should_throw_exception_when_draft_cannot_be_created()
public void Should_throw_exception_if_draft_cannot_be_created()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public void Should_not_throw_exception_when_draft_can_be_created()
public void Should_not_throw_exception_if_draft_can_be_created()
{
var context = CreateContext(CreateContent(Status.Published), normalSchema);
@ -131,7 +131,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public void Should_throw_exception_when_draft_cannot_be_deleted()
public void Should_throw_exception_if_draft_cannot_be_deleted()
{
var context = CreateContext(CreateContent(Status.Published), normalSchema);
@ -139,7 +139,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public void Should_not_throw_exception_when_draft_can_be_deleted()
public void Should_not_throw_exception_if_draft_can_be_deleted()
{
var context = CreateContext(CreateDraftContent(Status.Draft), normalSchema);
@ -174,7 +174,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_throw_exception_when_workflow_permits_update()
public async Task Should_throw_exception_if_workflow_permits_update()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -185,7 +185,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_not_throw_exception_when_workflow_allows_update()
public async Task Should_not_throw_exception_if_workflow_allows_update()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -196,7 +196,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_throw_exception_when_workflow_status_not_valid()
public async Task Should_throw_exception_if_workflow_status_not_valid()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -207,7 +207,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_not_throw_exception_when_workflow_status_is_valid()
public async Task Should_not_throw_exception_if_workflow_status_is_valid()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -218,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_not_throw_exception_when_workflow_status_is_checked_for_singleton()
public async Task Should_not_throw_exception_if_workflow_status_is_checked_for_singleton()
{
var context = CreateContext(CreateContent(Status.Draft), singletonSchema);
@ -229,7 +229,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_throw_exception_when_workflow_transition_not_valid()
public async Task Should_throw_exception_if_workflow_transition_not_valid()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -240,7 +240,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_not_throw_exception_when_workflow_transition_is_valid()
public async Task Should_not_throw_exception_if_workflow_transition_is_valid()
{
var context = CreateContext(CreateContent(Status.Draft), normalSchema);
@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
}
[Fact]
public async Task Should_not_throw_exception_when_workflow_transition_is_checked_for_singleton()
public async Task Should_not_throw_exception_if_workflow_transition_is_checked_for_singleton()
{
var context = CreateContext(CreateContent(Status.Draft), singletonSchema);

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs

@ -381,7 +381,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public async Task Should_return_all_statuses_for_default_workflow_when_no_workflow_configured()
public async Task Should_return_all_statuses_for_default_workflow_if_no_workflow_configured()
{
A.CallTo(() => app.Workflows).Returns(Workflows.Empty);

38
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs

@ -37,7 +37,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_create()
public async Task Should_return_error_if_user_has_no_permission_to_create()
{
var query = @"
mutation {
@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_creating_content()
public async Task Should_return_single_content_if_creating_content()
{
var query = CreateQuery(@"
mutation {
@ -112,7 +112,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_creating_content_with_custom_id()
public async Task Should_return_single_content_if_creating_content_with_custom_id()
{
var query = CreateQuery(@"
mutation {
@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_creating_content_with_variable()
public async Task Should_return_single_content_if_creating_content_with_variable()
{
var query = CreateQuery(@"
mutation OP($data: MySchemaDataInputDto!) {
@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_update()
public async Task Should_return_error_if_user_has_no_permission_to_update()
{
var query = CreateQuery(@"
mutation {
@ -221,7 +221,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_updating_content()
public async Task Should_return_single_content_if_updating_content()
{
var query = CreateQuery(@"
mutation {
@ -254,7 +254,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_updating_content_with_variable()
public async Task Should_return_single_content_if_updating_content_with_variable()
{
var query = CreateQuery(@"
mutation OP($data: MySchemaDataInputDto!) {
@ -287,7 +287,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_upsert()
public async Task Should_return_error_if_user_has_no_permission_to_upsert()
{
var query = CreateQuery(@"
mutation {
@ -329,7 +329,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_upserting_content()
public async Task Should_return_single_content_if_upserting_content()
{
var query = CreateQuery(@"
mutation {
@ -363,7 +363,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_upserting_content_with_variable()
public async Task Should_return_single_content_if_upserting_content_with_variable()
{
var query = CreateQuery(@"
mutation OP($data: MySchemaDataInputDto!) {
@ -397,7 +397,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_patch()
public async Task Should_return_error_if_user_has_no_permission_to_patch()
{
var query = CreateQuery(@"
mutation {
@ -439,7 +439,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_patching_content()
public async Task Should_return_single_content_if_patching_content()
{
var query = CreateQuery(@"
mutation {
@ -472,7 +472,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_patching_content_with_variable()
public async Task Should_return_single_content_if_patching_content_with_variable()
{
var query = CreateQuery(@"
mutation OP($data: MySchemaDataInputDto!) {
@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_change_status()
public async Task Should_return_error_if_user_has_no_permission_to_change_status()
{
var query = CreateQuery(@"
mutation {
@ -547,7 +547,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_changing_status()
public async Task Should_return_single_content_if_changing_status()
{
var dueTime = InstantPattern.General.Parse("2021-12-12T11:10:09Z").Value;
@ -583,7 +583,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_changing_status_without_due_time()
public async Task Should_return_single_content_if_changing_status_without_due_time()
{
var query = CreateQuery(@"
mutation {
@ -617,7 +617,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_changing_status_with_null_due_time()
public async Task Should_return_single_content_if_changing_status_with_null_due_time()
{
var query = CreateQuery(@"
mutation {
@ -651,7 +651,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_error_when_user_has_no_permission_to_delete()
public async Task Should_return_error_if_user_has_no_permission_to_delete()
{
var query = CreateQuery(@"
mutation {
@ -693,7 +693,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_new_version_when_deleting_content()
public async Task Should_return_new_version_if_deleting_content()
{
var query = CreateQuery(@"
mutation {

32
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs

@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_multiple_assets_when_querying_assets()
public async Task Should_return_multiple_assets_if_querying_assets()
{
var query = CreateQuery(@"
query {
@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_multiple_assets_with_total_when_querying_assets_with_total()
public async Task Should_return_multiple_assets_with_total_if_querying_assets_with_total()
{
var query = CreateQuery(@"
query {
@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_null_single_asset_when_not_found()
public async Task Should_return_null_single_asset_if_not_found()
{
var assetId = DomainId.NewGuid();
@ -147,7 +147,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_asset_when_finding_asset()
public async Task Should_return_single_asset_if_finding_asset()
{
var assetId = DomainId.NewGuid();
var asset = TestAsset.Create(appId, assetId);
@ -176,7 +176,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_multiple_flat_contents_when_querying_contents()
public async Task Should_return_multiple_flat_contents_if_querying_contents()
{
var query = CreateQuery(@"
query {
@ -278,7 +278,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_multiple_contents_when_querying_contents()
public async Task Should_return_multiple_contents_if_querying_contents()
{
var query = CreateQuery(@"
query {
@ -310,7 +310,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_multiple_contents_with_total_when_querying_contents_with_total()
public async Task Should_return_multiple_contents_with_total_if_querying_contents_with_total()
{
var query = CreateQuery(@"
query {
@ -349,7 +349,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_null_single_content_when_not_found()
public async Task Should_return_null_single_content_if_not_found()
{
var contentId = DomainId.NewGuid();
@ -377,7 +377,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_finding_content()
public async Task Should_return_single_content_if_finding_content()
{
var contentId = DomainId.NewGuid();
var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty);
@ -406,7 +406,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_return_single_content_when_finding_content_with_version()
public async Task Should_return_single_content_if_finding_content_with_version()
{
var contentId = DomainId.NewGuid();
var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty);
@ -435,7 +435,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_also_fetch_referenced_contents_when_field_is_included_in_query()
public async Task Should_also_fetch_referenced_contents_if_field_is_included_in_query()
{
var contentRefId = DomainId.NewGuid();
var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1");
@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_also_fetch_referencing_contents_when_field_is_included_in_query()
public async Task Should_also_fetch_referencing_contents_if_field_is_included_in_query()
{
var contentRefId = DomainId.NewGuid();
var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1");
@ -566,7 +566,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_also_fetch_referencing_contents_with_total_when_field_is_included_in_query()
public async Task Should_also_fetch_referencing_contents_with_total_if_field_is_included_in_query()
{
var contentRefId = DomainId.NewGuid();
var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1");
@ -634,7 +634,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_also_fetch_union_contents_when_field_is_included_in_query()
public async Task Should_also_fetch_union_contents_if_field_is_included_in_query()
{
var contentRefId = DomainId.NewGuid();
var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1");
@ -710,7 +710,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_also_fetch_referenced_assets_when_field_is_included_in_query()
public async Task Should_also_fetch_referenced_assets_if_field_is_included_in_query()
{
var assetRefId = DomainId.NewGuid();
var assetRef = TestAsset.Create(appId, assetRefId);
@ -768,7 +768,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
}
[Fact]
public async Task Should_not_return_data_when_field_not_part_of_content()
public async Task Should_not_return_data_if_field_not_part_of_content()
{
var contentId = DomainId.NewGuid();
var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty, new ContentData());

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs

@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_clone_data_when_requested()
public async Task Should_clone_data_if_requested()
{
var source = CreateContent(new ContentData());
@ -131,7 +131,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_not_clone_data_when_not_requested()
public async Task Should_not_clone_data_if_not_requested()
{
var source = CreateContent(new ContentData());

14
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs

@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_skip_total_when_set_in_context()
public async Task Should_skip_total_if_set_in_context()
{
var q = await sut.ParseAsync(requestContext.Clone(b => b.WithoutTotal()), Q.Empty);
@ -152,7 +152,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_full_text_query_to_filter_when_single_id_found()
public async Task Should_convert_full_text_query_to_filter_if_single_id_found()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, A<TextQuery>.That.Matches(x => x.Text == "Hello"), requestContext.Scope()))
.Returns(new List<DomainId> { DomainId.Create("1") });
@ -165,7 +165,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_full_text_query_to_filter_when_index_returns_null()
public async Task Should_convert_full_text_query_to_filter_if_index_returns_null()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, A<TextQuery>.That.Matches(x => x.Text == "Hello"), requestContext.Scope()))
.Returns(Task.FromResult<List<DomainId>?>(null));
@ -178,7 +178,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_full_text_query_to_filter_when_index_returns_empty()
public async Task Should_convert_full_text_query_to_filter_if_index_returns_empty()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, A<TextQuery>.That.Matches(x => x.Text == "Hello"), requestContext.Scope()))
.Returns(new List<DomainId>());
@ -204,7 +204,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_geo_query_to_filter_when_single_id_found()
public async Task Should_convert_geo_query_to_filter_if_single_id_found()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope()))
.Returns(new List<DomainId> { DomainId.Create("1") });
@ -217,7 +217,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_geo_query_to_filter_when_index_returns_null()
public async Task Should_convert_geo_query_to_filter_if_index_returns_null()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope()))
.Returns(Task.FromResult<List<DomainId>?>(null));
@ -230,7 +230,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_geo_query_to_filter_when_index_returns_empty()
public async Task Should_convert_geo_query_to_filter_if_index_returns_empty()
{
A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope()))
.Returns(new List<DomainId>());

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs

@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_convert_data_and_data_draft_when_frontend_user()
public async Task Should_convert_data_and_data_draft_if_frontend_user()
{
var content = CreateContent(new ContentData());
@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_cleanup_references_when_everything_deleted()
public async Task Should_cleanup_references_if_everything_deleted()
{
var id1 = DomainId.NewGuid();
var id2 = DomainId.NewGuid();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs

@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_not_enrich_with_reference_fields_when_not_frontend()
public async Task Should_not_enrich_with_reference_fields_if_not_frontend()
{
var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId));

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs

@ -180,7 +180,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_not_enrich_when_content_has_more_items()
public async Task Should_not_enrich_if_content_has_more_items()
{
var ref1_1 = CreateRefContent(DomainId.NewGuid(), 1, "ref1_1", 13, refSchemaId1);
var ref1_2 = CreateRefContent(DomainId.NewGuid(), 2, "ref1_2", 17, refSchemaId1);

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs

@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
}
[Fact]
public async Task Should_not_call_script_engine_when_no_script_configured()
public async Task Should_not_call_script_engine_if_no_script_configured()
{
var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId));

6
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs

@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
private readonly SingletonCommandMiddleware sut = new SingletonCommandMiddleware();
[Fact]
public async Task Should_create_content_when_singleton_schema_is_created()
public async Task Should_create_content_if_singleton_schema_is_created()
{
var command = new CreateSchema { IsSingleton = true, Name = "my-schema" };
@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public async Task Should_not_create_content_when_non_singleton_schema_is_created()
public async Task Should_not_create_content_if_non_singleton_schema_is_created()
{
var command = new CreateSchema { IsSingleton = false };
@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
}
[Fact]
public async Task Should_not_create_content_when_singleton_schema_not_created()
public async Task Should_not_create_content_if_singleton_schema_not_created()
{
var command = new CreateSchema { IsSingleton = true };

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs

@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
}
[Fact]
public async Task Should_retrieve_from_inner_when_not_cached()
public async Task Should_retrieve_from_inner_if_not_cached()
{
var contentIds = HashSet.Of(contentId);
@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
}
[Fact]
public async Task Should_retrieve_from_inner_when_not_cached_and_not_found()
public async Task Should_retrieve_from_inner_if_not_cached_and_not_found()
{
var contentIds = HashSet.Of(contentId);
@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
}
[Fact]
public async Task Should_not_retrieve_from_inner_when_cached()
public async Task Should_not_retrieve_from_inner_if_cached()
{
var contentIds = HashSet.Of(contentId);
@ -95,7 +95,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
}
[Fact]
public async Task Should_not_retrieve_from_inner_when_removed()
public async Task Should_not_retrieve_from_inner_if_removed()
{
var contentIds = HashSet.Of(contentId);

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs

@ -121,7 +121,7 @@ namespace Squidex.Domain.Apps.Entities.Notifications
}
[Fact]
public async Task Should_not_send_invitation_email_when_no_consent_given()
public async Task Should_not_send_invitation_email_if_no_consent_given()
{
var withoutConsent = UserMocks.User("2", "2@email.com", "user", false);
@ -135,7 +135,7 @@ namespace Squidex.Domain.Apps.Entities.Notifications
}
[Fact]
public async Task Should_send_invitation_email_when_consent_given()
public async Task Should_send_invitation_email_if_consent_given()
{
var withConsent = UserMocks.User("2", "2@email.com", "user", true);

78
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs

@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
LastEvents
.ShouldHaveSameEvents(
CreateRuleEvent(new RuleUpdated { Trigger = command.Trigger, Action = command.Action, Name = "NewName" })
CreateRuleEvent(new RuleUpdated { Trigger = command.Trigger, Action = command.Action, Name = command.Name })
);
}
@ -113,6 +113,29 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
);
}
[Fact]
public async Task Enable_via_update_should_create_events_and_update_enabled_flag()
{
var command = new UpdateRule
{
IsEnabled = true
};
await ExecuteCreateAsync();
await ExecuteDisableAsync();
var result = await PublishIdempotentAsync(command);
result.ShouldBeEquivalent(sut.Snapshot);
Assert.True(sut.Snapshot.RuleDef.IsEnabled);
LastEvents
.ShouldHaveSameEvents(
CreateRuleEvent(new RuleUpdated { IsEnabled = true })
);
}
[Fact]
public async Task Disable_should_create_events_and_update_enabled_flag()
{
@ -132,6 +155,28 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
);
}
[Fact]
public async Task Disable_via_update_should_create_events_and_update_enabled_flag()
{
var command = new UpdateRule
{
IsEnabled = false
};
await ExecuteCreateAsync();
var result = await PublishIdempotentAsync(command);
result.ShouldBeEquivalent(sut.Snapshot);
Assert.False(sut.Snapshot.RuleDef.IsEnabled);
LastEvents
.ShouldHaveSameEvents(
CreateRuleEvent(new RuleUpdated { IsEnabled = false })
);
}
[Fact]
public async Task Delete_should_create_events_and_update_deleted_flag()
{
@ -198,26 +243,33 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
private static CreateRule MakeCreateCommand()
{
var newTrigger = new ContentChangedTriggerV2();
var newAction = new TestAction
return new CreateRule
{
Value = 123
Trigger = new ContentChangedTriggerV2
{
HandleAll = false
},
Action = new TestAction
{
Value = 123
}
};
return new CreateRule { Trigger = newTrigger, Action = newAction };
}
private static UpdateRule MakeUpdateCommand()
{
var newTrigger = new ContentChangedTriggerV2 { HandleAll = true };
var newAction = new TestAction
return new UpdateRule
{
Value = 456
Name = "NewName",
Trigger = new ContentChangedTriggerV2
{
HandleAll = true
},
Action = new TestAction
{
Value = 456
}
};
return new UpdateRule { Trigger = newTrigger, Action = newAction, Name = "NewName" };
}
private Task<object> PublishIdempotentAsync(RuleCommand command)

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs

@ -108,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Indexes
}
[Fact]
public async Task Should_forward_call_when_rebuilding()
public async Task Should_forward_call_if_rebuilding()
{
var rules = new HashSet<DomainId>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs

@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
private readonly IRuleTriggerHandler sut = new ManualTriggerHandler();
[Fact]
public void Should_return_false_when_asking_for_snapshot_support()
public void Should_return_false_if_asking_for_snapshot_support()
{
Assert.False(sut.CanCreateSnapshotEvents);
}

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs

@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
}
[Fact]
public async Task Should_update_repository_when_enqueing()
public async Task Should_update_repository_if_enqueing()
{
var @event = Envelope.Create<IEvent>(new ContentCreated { AppId = appId });
@ -108,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
}
[Fact]
public async Task Should_not_eqneue_when_event_restored()
public async Task Should_not_eqneue_if_event_restored()
{
var @event = Envelope.Create<IEvent>(new ContentCreated { AppId = appId });

10
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs

@ -24,13 +24,13 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
private readonly IRuleTriggerHandler sut = new UsageTriggerHandler();
[Fact]
public void Should_return_false_when_asking_for_snapshot_support()
public void Should_return_false_if_asking_for_snapshot_support()
{
Assert.False(sut.CanCreateSnapshotEvents);
}
[Fact]
public void Should_not_trigger_precheck_when_event_type_not_correct()
public void Should_not_trigger_precheck_if_event_type_not_correct()
{
var result = sut.Trigger(new ContentCreated(), new UsageTrigger(), ruleId);
@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
}
[Fact]
public void Should_not_trigger_precheck_when_rule_id_not_matchs()
public void Should_not_trigger_precheck_if_rule_id_not_matchs()
{
var result = sut.Trigger(new AppUsageExceeded { RuleId = DomainId.NewGuid() }, new UsageTrigger(), ruleId);
@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
}
[Fact]
public void Should_trigger_precheck_when_event_type_correct_and_rule_id_matchs()
public void Should_trigger_precheck_if_event_type_correct_and_rule_id_matchs()
{
var result = sut.Trigger(new AppUsageExceeded { RuleId = ruleId }, new UsageTrigger(), ruleId);
@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
}
[Fact]
public void Should_not_trigger_check_when_event_type_not_correct()
public void Should_not_trigger_check_if_event_type_not_correct()
{
var result = sut.Trigger(new EnrichedContentEvent(), new UsageTrigger());

16
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs

@ -167,7 +167,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_add_schema_to_index_when_creating()
public async Task Should_add_schema_to_index_if_creating()
{
var token = RandomHash.Simple();
@ -190,7 +190,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_clear_reservation_when_schema_creation_failed()
public async Task Should_clear_reservation_if_schema_creation_failed()
{
var token = RandomHash.Simple();
@ -212,7 +212,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_not_add_to_indexes_when_name_is_taken()
public async Task Should_not_add_to_indexes_if_name_is_taken()
{
A.CallTo(() => index.ReserveAsync(schemaId.Id, schemaId.Name))
.Returns(Task.FromResult<string?>(null));
@ -233,7 +233,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_not_add_to_indexes_when_name_is_invalid()
public async Task Should_not_add_to_indexes_if_name_is_invalid()
{
var command = Create("INVALID");
@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_update_index_when_schema_is_updated()
public async Task Should_update_index_if_schema_is_updated()
{
var (_, schemaGrain) = SetupSchema();
@ -268,7 +268,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_update_index_with_result_when_schema_is_updated()
public async Task Should_update_index_with_result_if_schema_is_updated()
{
var (schema, schemaGrain) = SetupSchema();
@ -285,7 +285,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_remove_schema_from_index_when_deleted_and_exists()
public async Task Should_remove_schema_from_index_if_deleted_and_exists()
{
var (schema, _) = SetupSchema(isDeleted: true);
@ -302,7 +302,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
}
[Fact]
public async Task Should_forward_call_when_rebuilding()
public async Task Should_forward_call_if_rebuilding()
{
var schemas = new Dictionary<string, DomainId>();

14
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs

@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_return_false_when_asking_for_snapshot_support()
public void Should_return_false_if_asking_for_snapshot_support()
{
Assert.False(sut.CanCreateSnapshotEvents);
}
@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_not_trigger_precheck_when_event_type_not_correct()
public void Should_not_trigger_precheck_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_trigger_precheck_when_event_type_correct()
public void Should_trigger_precheck_if_event_type_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_not_trigger_check_when_event_type_not_correct()
public void Should_not_trigger_check_if_event_type_not_correct()
{
TestForCondition(string.Empty, trigger =>
{
@ -101,7 +101,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_trigger_check_when_condition_is_empty()
public void Should_trigger_check_if_condition_is_empty()
{
TestForCondition(string.Empty, trigger =>
{
@ -112,7 +112,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_trigger_check_when_condition_matchs()
public void Should_trigger_check_if_condition_matchs()
{
TestForCondition("true", trigger =>
{
@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
}
[Fact]
public void Should_not_trigger_check_when_condition_does_not_matchs()
public void Should_not_trigger_check_if_condition_does_not_matchs()
{
TestForCondition("false", trigger =>
{

14
backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs

@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_clearing()
public async Task Should_call_grain_if_clearing()
{
await sut.ClearAsync(appId, TagGroups.Assets);
@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_rebuilding()
public async Task Should_call_grain_if_rebuilding()
{
var tags = new TagsExport();
@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_retrieving_raw_tags()
public async Task Should_call_grain_if_retrieving_raw_tags()
{
await sut.GetExportableTagsAsync(appId, TagGroups.Assets);
@ -60,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_retrieving_tags()
public async Task Should_call_grain_if_retrieving_tags()
{
await sut.GetTagsAsync(appId, TagGroups.Assets);
@ -69,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_resolving_tag_ids()
public async Task Should_call_grain_if_resolving_tag_ids()
{
var tagNames = new HashSet<string>();
@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_denormalizing_tags()
public async Task Should_call_grain_if_denormalizing_tags()
{
var tagIds = new HashSet<string>();
@ -91,7 +91,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_call_grain_when_normalizing_tags()
public async Task Should_call_grain_if_normalizing_tags()
{
var tagIds = new HashSet<string>();
var tagNames = new HashSet<string>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs

@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Entities.Tags
}
[Fact]
public async Task Should_delete_and_reset_state_when_cleaning()
public async Task Should_delete_and_reset_state_if_cleaning()
{
await sut.NormalizeTagsAsync(HashSet.Of("name1", "name2"), null);
await sut.NormalizeTagsAsync(HashSet.Of("name2", "name3"), null);

8
backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs

@ -45,7 +45,7 @@ namespace Squidex.Domain.Users
}
[Fact]
public async Task Should_create_user_and_return_true_when_created()
public async Task Should_create_user_and_return_true_if_created()
{
var email = "123@email.com";
@ -60,7 +60,7 @@ namespace Squidex.Domain.Users
}
[Fact]
public async Task Should_create_user_and_return_false_when_exception_thrown()
public async Task Should_create_user_and_return_false_if_exception_thrown()
{
var email = "123@email.com";
@ -78,7 +78,7 @@ namespace Squidex.Domain.Users
}
[Fact]
public async Task Should_add_claim_when_not_added_yet()
public async Task Should_add_claim_if_not_added_yet()
{
var id = "123";
@ -90,7 +90,7 @@ namespace Squidex.Domain.Users
}
[Fact]
public async Task Should_add_claim_when_not_added_yet_silently()
public async Task Should_add_claim_if_not_added_yet_silently()
{
var id = "123";

6
backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs

@ -16,7 +16,7 @@ namespace Squidex.Infrastructure
private readonly Dictionary<int, List<int>> listDictionary = new Dictionary<int, List<int>>();
[Fact]
public void SetEquals_should_return_false_when_subset()
public void SetEquals_should_return_false_if_subset()
{
var set1 = new[] { 1, 2 };
var set2 = new[] { 1, 2, 3 };
@ -36,7 +36,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void IndexOf_should_return_index_when_found()
public void IndexOf_should_return_index_if_found()
{
var source = new List<(int Value, int Other)>
{
@ -50,7 +50,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void IndexOf_should_return_negative_value_when_not_found()
public void IndexOf_should_return_negative_value_if_not_found()
{
var source = new List<(int Value, int Other)>
{

6
backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs

@ -35,7 +35,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public void Should_be_handled_when_succeeded()
public void Should_be_handled_if_succeeded()
{
sut.Complete();
@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public void Should_provide_result_when_succeeded_with_value()
public void Should_provide_result_if_succeeded_with_value()
{
sut.Complete("RESULT");
@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public void Should_provide_plain_result_when_succeeded_with_value()
public void Should_provide_plain_result_if_succeeded_with_value()
{
sut.Complete("RESULT");

40
backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs

@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_repair_when_stale()
public async Task Should_repair_if_stale()
{
A.CallTo(() => persistence.IsSnapshotStale)
.Returns(true);
@ -50,7 +50,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_not_repair_when_not_stale()
public async Task Should_not_repair_if_not_stale()
{
A.CallTo(() => persistence.IsSnapshotStale)
.Returns(false);
@ -64,7 +64,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_write_state_and_events_when_created()
public async Task Should_write_state_and_events_if_created()
{
SetupEmpty();
@ -85,7 +85,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_recreate_with_create_command_when_deleted_before()
public async Task Should_recreate_with_create_command_if_deleted_before()
{
sut.Recreate = true;
@ -110,7 +110,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_recreation_with_create_command_not_allowed()
public async Task Should_throw_exception_if_recreation_with_create_command_not_allowed()
{
sut.Recreate = false;
@ -124,7 +124,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_recreate_with_upsert_command_when_deleted_before()
public async Task Should_recreate_with_upsert_command_if_deleted_before()
{
sut.Recreate = true;
@ -149,7 +149,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_recreation_with_upsert_command_not_allowed()
public async Task Should_throw_exception_if_recreation_with_upsert_command_not_allowed()
{
sut.Recreate = false;
@ -163,7 +163,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_write_state_and_events_when_updated_after_creation()
public async Task Should_write_state_and_events_if_updated_after_creation()
{
SetupEmpty();
@ -186,7 +186,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_write_state_and_events_when_updated()
public async Task Should_write_state_and_events_if_updated()
{
SetupCreated(4);
@ -246,7 +246,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_on_rebuild_when_no_event_found()
public async Task Should_throw_on_rebuild_if_no_event_found()
{
SetupEmpty();
@ -265,7 +265,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_create_command_is_invoked_for_loaded_and_created_object()
public async Task Should_throw_exception_if_create_command_is_invoked_for_loaded_and_created_object()
{
await sut.ExecuteAsync(new CreateAuto());
@ -273,7 +273,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_create_command_not_accepted()
public async Task Should_throw_exception_if_create_command_not_accepted()
{
SetupEmpty();
@ -291,7 +291,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_update_command_invoked_for_empty_object()
public async Task Should_throw_exception_if_update_command_invoked_for_empty_object()
{
SetupEmpty();
@ -299,7 +299,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_update_command_not_accepted()
public async Task Should_throw_exception_if_update_command_not_accepted()
{
SetupCreated(4);
@ -317,7 +317,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_throw_exception_when_other_verison_expected()
public async Task Should_throw_exception_if_other_verison_expected()
{
SetupCreated(4);
@ -325,7 +325,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_not_update_when_snapshot_is_not_changed()
public async Task Should_not_update_if_snapshot_is_not_changed()
{
SetupCreated(4);
@ -339,7 +339,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_reset_state_when_writing_snapshot_for_create_failed()
public async Task Should_reset_state_if_writing_snapshot_for_create_failed()
{
SetupEmpty();
@ -353,7 +353,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_reset_state_when_writing_snapshot_for_update_failed()
public async Task Should_reset_state_if_writing_snapshot_for_update_failed()
{
SetupCreated(4);
@ -392,7 +392,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_get_old_versions_when_cached()
public async Task Should_get_old_versions_if_cached()
{
sut.VersionsToKeep = int.MaxValue;
@ -415,7 +415,7 @@ namespace Squidex.Infrastructure.Commands
}
[Fact]
public async Task Should_get_old_versions_from_query_when_not_cached()
public async Task Should_get_old_versions_from_query_if_not_cached()
{
sut.VersionsToKeep = 1;

4
backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs

@ -28,7 +28,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_not_throw_exception_when_not_disposed()
public void Should_not_throw_exception_if_not_disposed()
{
var sut = new MyDisposableObject();
@ -49,7 +49,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_throw_exception_when_disposed()
public void Should_throw_exception_if_disposed()
{
var sut = new MyDisposableObject();

28
backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs

@ -107,7 +107,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_not_subscribe_to_event_store_when_stopped_in_db()
public async Task Should_not_subscribe_to_event_store_if_stopped_in_db()
{
grainState.Value = grainState.Value.Stopped();
@ -123,7 +123,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_subscribe_to_event_store_when_not_found_in_db()
public async Task Should_subscribe_to_event_store_if_not_found_in_db()
{
await sut.ActivateAsync(consumerName);
await sut.ActivateAsync();
@ -137,7 +137,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_subscribe_to_event_store_when_failed()
public async Task Should_subscribe_to_event_store_if_failed()
{
grainState.Value = grainState.Value.Stopped(new InvalidOperationException());
@ -153,7 +153,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_subscribe_to_event_store_when_not_stopped_in_db()
public async Task Should_subscribe_to_event_store_if_not_stopped_in_db()
{
await sut.ActivateAsync(consumerName);
await sut.ActivateAsync();
@ -167,7 +167,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_stop_subscription_when_stopped()
public async Task Should_stop_subscription_if_stopped()
{
await sut.ActivateAsync(consumerName);
await sut.ActivateAsync();
@ -186,7 +186,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_reset_consumer_when_resetting()
public async Task Should_reset_consumer_if_resetting()
{
await sut.ActivateAsync(consumerName);
await sut.ActivateAsync();
@ -214,7 +214,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_invoke_and_update_position_when_event_received()
public async Task Should_invoke_and_update_position_if_event_received()
{
var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData);
@ -235,7 +235,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_invoke_and_update_position_when_event_received_one_by_one()
public async Task Should_invoke_and_update_position_if_event_received_one_by_one()
{
var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData);
@ -263,7 +263,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_invoke_and_update_position_when_event_received_batched()
public async Task Should_invoke_and_update_position_if_event_received_batched()
{
var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData);
@ -291,7 +291,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_not_invoke_but_update_position_when_consumer_does_not_want_to_handle()
public async Task Should_not_invoke_but_update_position_if_consumer_does_not_want_to_handle()
{
var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData);
@ -339,7 +339,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_not_invoke_and_update_position_when_event_is_from_another_subscription()
public async Task Should_not_invoke_and_update_position_if_event_is_from_another_subscription()
{
var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData);
@ -378,7 +378,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_not_make_error_handling_when_exception_is_from_another_subscription()
public async Task Should_not_make_error_handling_if_exception_is_from_another_subscription()
{
var ex = new InvalidOperationException();
@ -396,7 +396,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_wakeup_when_already_subscribed()
public async Task Should_wakeup_if_already_subscribed()
{
await sut.ActivateAsync(consumerName);
await sut.ActivateAsync();
@ -490,7 +490,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_start_after_stop_when_handling_failed()
public async Task Should_start_after_stop_if_handling_failed()
{
var exception = new InvalidOperationException();

2
backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs

@ -90,7 +90,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
}
[Fact]
public async Task Should_activate_matching_grains_when_stream_name_defined()
public async Task Should_activate_matching_grains_if_stream_name_defined()
{
await sut.ActivateAsync("a-123");

8
backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs

@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.EventSourcing
}
[Fact]
public async Task Should_reopen_subscription_once_when_exception_is_retrieved()
public async Task Should_reopen_subscription_once_if_exception_is_retrieved()
{
await OnErrorAsync(eventSubscription, new InvalidOperationException());
@ -70,7 +70,7 @@ namespace Squidex.Infrastructure.EventSourcing
}
[Fact]
public async Task Should_forward_error_from_inner_subscription_when_failed_often()
public async Task Should_forward_error_from_inner_subscription_if_failed_often()
{
var ex = new InvalidOperationException();
@ -108,7 +108,7 @@ namespace Squidex.Infrastructure.EventSourcing
}
[Fact]
public async Task Should_not_forward_error_when_exception_is_raised_after_unsubscribe()
public async Task Should_not_forward_error_if_exception_is_raised_after_unsubscribe()
{
var ex = new InvalidOperationException();
@ -134,7 +134,7 @@ namespace Squidex.Infrastructure.EventSourcing
}
[Fact]
public async Task Should_forward_event_when_message_is_from_another_subscription()
public async Task Should_forward_event_if_message_is_from_another_subscription()
{
var ev = new StoredEvent("Stream", "1", 2, new EventData("Type", new EnvelopeHeaders(), "Payload"));

28
backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs

@ -353,7 +353,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_create_null_when_adding_null_to_array()
public void Should_create_null_if_adding_null_to_array()
{
var array = JsonValue.Array();
@ -363,7 +363,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_create_null_when_replacing_to_null_in_array()
public void Should_create_null_if_replacing_to_null_in_array()
{
var array = JsonValue.Array(1);
@ -373,7 +373,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_create_null_when_adding_null_to_object()
public void Should_create_null_if_adding_null_to_object()
{
var obj = JsonValue.Object();
@ -383,7 +383,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_create_null_when_replacing_to_null_object()
public void Should_create_null_if_replacing_to_null_object()
{
var obj = JsonValue.Object();
@ -435,13 +435,13 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_throw_exception_when_creation_value_from_invalid_type()
public void Should_throw_exception_if_creation_value_from_invalid_type()
{
Assert.Throws<ArgumentException>(() => JsonValue.Create(default(TimeSpan)));
}
[Fact]
public void Should_return_null_when_getting_value_by_path_segment_from_null()
public void Should_return_null_if_getting_value_by_path_segment_from_null()
{
var json = JsonValue.Null;
@ -452,7 +452,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_getting_value_by_path_segment_from_string()
public void Should_return_null_if_getting_value_by_path_segment_from_string()
{
var json = JsonValue.Create("string");
@ -463,7 +463,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_getting_value_by_path_segment_from_boolean()
public void Should_return_null_if_getting_value_by_path_segment_from_boolean()
{
var json = JsonValue.True;
@ -474,7 +474,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_getting_value_by_path_segment_from_number()
public void Should_return_null_if_getting_value_by_path_segment_from_number()
{
var json = JsonValue.Create(12);
@ -485,7 +485,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_same_object_when_path_is_null()
public void Should_return_same_object_if_path_is_null()
{
var json = JsonValue.Object().Add("property", 12);
@ -496,7 +496,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_same_object_when_path_is_empty()
public void Should_return_same_object_if_path_is_empty()
{
var json = JsonValue.Object().Add("property", 12);
@ -524,7 +524,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_property_not_found()
public void Should_return_null_if_property_not_found()
{
var json =
JsonValue.Object()
@ -537,7 +537,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_out_of_index1()
public void Should_return_null_if_out_of_index1()
{
var json = JsonValue.Array(12, 14);
@ -548,7 +548,7 @@ namespace Squidex.Infrastructure.Json.Objects
}
[Fact]
public void Should_return_null_when_out_of_index2()
public void Should_return_null_if_out_of_index2()
{
var json = JsonValue.Array(12, 14);

4
backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs

@ -159,7 +159,7 @@ namespace Squidex.Infrastructure.Migrations
}
[Fact]
public async Task Should_unlock_when_migration_failed()
public async Task Should_unlock_if_migration_failed()
{
var migrator_0_1 = BuildMigration(0, 1);
var migrator_1_2 = BuildMigration(1, 2);
@ -194,7 +194,7 @@ namespace Squidex.Infrastructure.Migrations
}
[Fact]
public async Task Should_log_exception_when_migration_failed()
public async Task Should_log_exception_if_migration_failed()
{
var migrator_0_1 = BuildMigration(0, 1);
var migrator_1_2 = BuildMigration(1, 2);

6
backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs

@ -88,7 +88,7 @@ namespace Squidex.Infrastructure.MongoDb
}
[Fact]
public async Task Should_break_when_cursor_failed()
public async Task Should_break_if_cursor_failed()
{
var ex = new InvalidOperationException();
@ -110,7 +110,7 @@ namespace Squidex.Infrastructure.MongoDb
}
[Fact]
public async Task Should_break_when_handler_failed()
public async Task Should_break_if_handler_failed()
{
var ex = new InvalidOperationException();
@ -137,7 +137,7 @@ namespace Squidex.Infrastructure.MongoDb
}
[Fact]
public async Task Should_stop_when_cancelled1()
public async Task Should_stop_if_cancelled1()
{
using (var cts = new CancellationTokenSource())
{

4
backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs

@ -480,7 +480,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_add_error_when_using_array_value_for_non_allowed_operator()
public void Should_add_error_if_using_array_value_for_non_allowed_operator()
{
var json = new { path = "string", op = "eq", value = new[] { "Hello" } };
@ -545,7 +545,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_throw_exception_when_parsing_invalid_json()
public void Should_throw_exception_if_parsing_invalid_json()
{
var json = "invalid";

44
backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs

@ -68,7 +68,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("createdNullable")]
[InlineData("properties/datetime")]
[InlineData("properties/nested/datetime")]
public void Should_parse_filter_when_type_is_datetime(string field)
public void Should_parse_filter_if_type_is_datetime(string field)
{
var i = _Q($"$filter={field} eq 1988-01-19T12:00:00Z");
var o = _C($"Filter: {field} == 1988-01-19T12:00:00Z");
@ -81,7 +81,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("createdNullable")]
[InlineData("properties/datetime")]
[InlineData("properties/nested/datetime")]
public void Should_parse_filter_when_type_is_datetime_and_value_is_null(string field)
public void Should_parse_filter_if_type_is_datetime_and_value_is_null(string field)
{
var i = _Q($"$filter={field} eq null");
var o = _C($"Filter: {field} == null");
@ -90,7 +90,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_datetime_list()
public void Should_parse_filter_if_type_is_datetime_list()
{
var i = _Q("$filter=created in ('1988-01-19T12:00:00Z')");
var o = _C("Filter: created in [1988-01-19T12:00:00Z]");
@ -99,7 +99,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_datetime_and_and_value_is_date()
public void Should_parse_filter_if_type_is_datetime_and_and_value_is_date()
{
var i = _Q("$filter=created eq 1988-01-19");
var o = _C("Filter: created == 1988-01-19T00:00:00Z");
@ -112,7 +112,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("birthdayNullable")]
[InlineData("properties/date")]
[InlineData("properties/nested/date")]
public void Should_parse_filter_when_type_is_date(string field)
public void Should_parse_filter_if_type_is_date(string field)
{
var i = _Q($"$filter={field} eq 1988-01-19");
var o = _C($"Filter: {field} == 1988-01-19T00:00:00Z");
@ -121,7 +121,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_date_list()
public void Should_parse_filter_if_type_is_date_list()
{
var i = _Q("$filter=birthday in ('1988-01-19')");
var o = _C("Filter: birthday in [1988-01-19T00:00:00Z]");
@ -134,7 +134,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("idNullable")]
[InlineData("properties/uid")]
[InlineData("properties/nested/guid")]
public void Should_parse_filter_when_type_is_guid(string field)
public void Should_parse_filter_if_type_is_guid(string field)
{
var i = _Q($"$filter={field} eq B5FE25E3-B262-4B17-91EF-B3772A6B62BB");
var o = _C($"Filter: {field} == b5fe25e3-b262-4b17-91ef-b3772a6b62bb");
@ -147,7 +147,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("idNullable")]
[InlineData("properties/uid")]
[InlineData("properties/nested/guid")]
public void Should_parse_filter_when_type_is_guid_and_value_is_null(string field)
public void Should_parse_filter_if_type_is_guid_and_value_is_null(string field)
{
var i = _Q($"$filter={field} eq null");
var o = _C($"Filter: {field} == null");
@ -156,7 +156,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_guid_list()
public void Should_parse_filter_if_type_is_guid_list()
{
var i = _Q("$filter=id in ('B5FE25E3-B262-4B17-91EF-B3772A6B62BB')");
var o = _C("Filter: id in [b5fe25e3-b262-4b17-91ef-b3772a6b62bb]");
@ -165,7 +165,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_null()
public void Should_parse_filter_if_type_is_null()
{
var i = _Q("$filter=firstName eq null");
var o = _C("Filter: firstName == null");
@ -178,7 +178,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("firstNameNullable")]
[InlineData("properties/string")]
[InlineData("properties/nested/string")]
public void Should_parse_filter_when_type_is_string(string field)
public void Should_parse_filter_if_type_is_string(string field)
{
var i = _Q($"$filter={field} eq 'Dagobert'");
var o = _C($"Filter: {field} == 'Dagobert'");
@ -187,7 +187,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_string_list()
public void Should_parse_filter_if_type_is_string_list()
{
var i = _Q("$filter=firstName in ('Dagobert')");
var o = _C("Filter: firstName in ['Dagobert']");
@ -200,7 +200,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("isComicFigureNullable")]
[InlineData("properties/boolean")]
[InlineData("properties/nested/boolean")]
public void Should_parse_filter_when_type_is_boolean(string field)
public void Should_parse_filter_if_type_is_boolean(string field)
{
var i = _Q($"$filter={field} eq true");
var o = _C($"Filter: {field} == True");
@ -213,7 +213,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("isComicFigureNullable")]
[InlineData("properties/boolean")]
[InlineData("properties/nested/boolean")]
public void Should_parse_filter_when_type_is_boolean_and_value_is_null(string field)
public void Should_parse_filter_if_type_is_boolean_and_value_is_null(string field)
{
var i = _Q($"$filter={field} eq null");
var o = _C($"Filter: {field} == null");
@ -222,7 +222,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_boolean_list()
public void Should_parse_filter_if_type_is_boolean_list()
{
var i = _Q("$filter=isComicFigure in (true)");
var o = _C("Filter: isComicFigure in [True]");
@ -235,7 +235,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("ageNullable")]
[InlineData("properties/int")]
[InlineData("properties/nested/int")]
public void Should_parse_filter_when_type_is_int32(string field)
public void Should_parse_filter_if_type_is_int32(string field)
{
var i = _Q($"$filter={field} eq 60");
var o = _C($"Filter: {field} == 60");
@ -244,7 +244,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_int32_list()
public void Should_parse_filter_if_type_is_int32_list()
{
var i = _Q("$filter=age in (60)");
var o = _C("Filter: age in [60]");
@ -257,7 +257,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("incomeCentsNullable")]
[InlineData("properties/long")]
[InlineData("properties/nested/long")]
public void Should_parse_filter_when_type_is_int64(string field)
public void Should_parse_filter_if_type_is_int64(string field)
{
var i = _Q($"$filter={field} eq 31543143513456789");
var o = _C($"Filter: {field} == 31543143513456789");
@ -266,7 +266,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_int64_list()
public void Should_parse_filter_if_type_is_int64_list()
{
var i = _Q("$filter=incomeCents in (31543143513456789)");
var o = _C("Filter: incomeCents in [31543143513456789]");
@ -279,7 +279,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("incomeMioNullable")]
[InlineData("properties/double")]
[InlineData("properties/nested/double")]
public void Should_parse_filter_when_type_is_double(string field)
public void Should_parse_filter_if_type_is_double(string field)
{
var i = _Q($"$filter={field} eq 5634474356.1233");
var o = _C($"Filter: {field} == 5634474356.1233");
@ -292,7 +292,7 @@ namespace Squidex.Infrastructure.Queries
[InlineData("geoNullable")]
[InlineData("properties/geo")]
[InlineData("properties/nested/geo")]
public void Should_parse_filter_when_type_is_geograph(string field)
public void Should_parse_filter_if_type_is_geograph(string field)
{
var i = _Q($"$filter=geo.distance({field}, geography'POINT(10 20)') lt 30.0");
var o = _C($"Filter: {field} < Radius(10, 20, 30)");
@ -301,7 +301,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_parse_filter_when_type_is_double_list()
public void Should_parse_filter_if_type_is_double_list()
{
var i = _Q("$filter=incomeMio in (5634474356.1233)");
var o = _C("Filter: incomeMio in [5634474356.1233]");

2
backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs

@ -166,7 +166,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_not_throw_exception_when_filter_has_unknown_property()
public void Should_not_throw_exception_if_filter_has_unknown_property()
{
var json = new
{

6
backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs

@ -32,7 +32,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_return_null_when_filters_of_logical_filter_get_optimized_away()
public void Should_return_null_if_filters_of_logical_filter_get_optimized_away()
{
var source = ClrFilter.And(ClrFilter.And());
@ -42,7 +42,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_return_null_when_logical_filter_has_no_filter()
public void Should_return_null_if_logical_filter_has_no_filter()
{
var source = ClrFilter.And();
@ -52,7 +52,7 @@ namespace Squidex.Infrastructure.Queries
}
[Fact]
public void Should_return_null_when_filter_of_negation_get_optimized_away()
public void Should_return_null_if_filter_of_negation_get_optimized_away()
{
var source = ClrFilter.Not(ClrFilter.And());

2
backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs

@ -115,7 +115,7 @@ namespace Squidex.Infrastructure.Reflection
}
[Fact]
public void Should_map_when_convertible_is_null()
public void Should_map_if_convertible_is_null()
{
var obj1 = new Class1<int?, int?>
{

26
backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs

@ -23,7 +23,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_permissions_are_equal()
public void Should_allow_and_include_if_permissions_are_equal()
{
var g = new Permission("app.contents");
var r = new Permission("app.contents");
@ -33,7 +33,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_not_allow_and_include_when_permissions_are_not_equal()
public void Should_not_allow_and_include_if_permissions_are_not_equal()
{
var g = new Permission("app.contents");
var r = new Permission("app.assets");
@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_permissions_have_same_wildcards()
public void Should_allow_and_include_if_permissions_have_same_wildcards()
{
var g = new Permission("app.*");
var r = new Permission("app.*");
@ -53,7 +53,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_given_is_parent_of_requested()
public void Should_allow_and_include_if_given_is_parent_of_requested()
{
var g = new Permission("app");
var r = new Permission("app.contents");
@ -63,7 +63,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_not_allow_but_include_when_requested_is_parent_of_given()
public void Should_not_allow_but_include_if_requested_is_parent_of_given()
{
var g = new Permission("app.contents");
var r = new Permission("app");
@ -73,7 +73,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_given_is_wildcard_of_requested()
public void Should_allow_and_include_if_given_is_wildcard_of_requested()
{
var g = new Permission("app.*");
var r = new Permission("app.contents");
@ -83,7 +83,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_not_allow_but_include_when_given_is_wildcard_of_requested()
public void Should_not_allow_but_include_if_given_is_wildcard_of_requested()
{
var g = new Permission("app.contents");
var r = new Permission("app.*");
@ -93,7 +93,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_given_has_alternatives_of_requested()
public void Should_allow_and_include_if_given_has_alternatives_of_requested()
{
var g = new Permission("app.contents|schemas");
var r = new Permission("app.contents");
@ -103,7 +103,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_given_has_not_excluded_requested()
public void Should_allow_and_include_if_given_has_not_excluded_requested()
{
var g = new Permission("app.^schemas");
var r = new Permission("app.contents");
@ -113,7 +113,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_requested_has_not_excluded_given()
public void Should_allow_and_include_if_requested_has_not_excluded_given()
{
var g = new Permission("app.contents");
var r = new Permission("app.^schemas");
@ -123,7 +123,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_not_allow_and_include_when_given_has_excluded_requested()
public void Should_not_allow_and_include_if_given_has_excluded_requested()
{
var g = new Permission("app.^contents");
var r = new Permission("app.contents");
@ -133,7 +133,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_not_allow_and_include_when_given_and_requested_have_same_exclusion()
public void Should_not_allow_and_include_if_given_and_requested_have_same_exclusion()
{
var g = new Permission("app.^contents");
var r = new Permission("app.^contents");
@ -143,7 +143,7 @@ namespace Squidex.Infrastructure.Security
}
[Fact]
public void Should_allow_and_include_when_requested_is_has_alternatives_of_given()
public void Should_allow_and_include_if_requested_is_has_alternatives_of_given()
{
var g = new Permission("app.contents");
var r = new Permission("app.contents|schemas");

12
backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs

@ -106,7 +106,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_mark_as_stale_when_snapshot_old_than_events()
public async Task Should_mark_as_stale_if_snapshot_old_than_events()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns(("2", true, 1L));
@ -264,7 +264,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_write_snapshot_to_store_when_not_read_before()
public async Task Should_write_snapshot_to_store_if_not_read_before()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns((null!, true, EtagVersion.Empty));
@ -290,7 +290,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_not_write_snapshot_to_store_when_not_changed()
public async Task Should_not_write_snapshot_to_store_if_not_changed()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns(("0", true, 2));
@ -310,7 +310,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_wrap_exception_when_writing_to_store_with_previous_version()
public async Task Should_wrap_exception_if_writing_to_store_with_previous_version()
{
SetupEventStore(3);
@ -326,7 +326,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_delete_events_but_not_snapshot_when_deleted_snapshot_only()
public async Task Should_delete_events_but_not_snapshot_if_deleted_snapshot_only()
{
var persistence = sut.WithEventSourcing(None.Type, key, null);
@ -340,7 +340,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_delete_events_and_snapshot_when_deleted()
public async Task Should_delete_events_and_snapshot_if_deleted()
{
var persistence = sut.WithSnapshotsAndEventSourcing(None.Type, key, null, null);

10
backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs

@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_not_read_from_store_when_not_valid()
public async Task Should_not_read_from_store_if_not_valid()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns((20, false, 10));
@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_return_empty_version_when_version_negative()
public async Task Should_return_empty_version_if_version_negative()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns((20, true, -10));
@ -72,7 +72,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_set_to_empty_when_store_returns_not_found()
public async Task Should_set_to_empty_if_store_returns_not_found()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns((20, true, EtagVersion.Empty));
@ -142,7 +142,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_not_wrap_exception_when_writing_to_store_with_previous_version()
public async Task Should_not_wrap_exception_if_writing_to_store_with_previous_version()
{
A.CallTo(() => snapshotStore.ReadAsync(key))
.Returns((20, true, 10));
@ -159,7 +159,7 @@ namespace Squidex.Infrastructure.States
}
[Fact]
public async Task Should_delete_snapshot_but_not_events_when_deleted()
public async Task Should_delete_snapshot_but_not_events_if_deleted()
{
var persistedState = Save.Snapshot(0);
var persistence = sut.WithSnapshots(None.Type, key, persistedState.Write);

8
backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs

@ -63,7 +63,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_join_non_empty_when_all_are_valid()
public void Should_join_non_empty_if_all_are_valid()
{
var result = StringExtensions.JoinNonEmpty("_", "1", "2", "3");
@ -71,7 +71,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_join_non_empty_when_first_invalid()
public void Should_join_non_empty_if_first_invalid()
{
var result = StringExtensions.JoinNonEmpty("_", null, "2", "3");
@ -79,7 +79,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_join_non_empty_when_middle_invalid()
public void Should_join_non_empty_if_middle_invalid()
{
var result = StringExtensions.JoinNonEmpty("_", "1", null, "3");
@ -87,7 +87,7 @@ namespace Squidex.Infrastructure
}
[Fact]
public void Should_join_non_empty_when_last_invalid()
public void Should_join_non_empty_if_last_invalid()
{
var result = StringExtensions.JoinNonEmpty("_", "1", "2", null);

4
backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs

@ -61,7 +61,7 @@ namespace Squidex.Infrastructure.UsageTracking
}
[Fact]
public async Task Should_sum_up_when_getting_monthly_calls()
public async Task Should_sum_up_if_getting_monthly_calls()
{
var dateFrom = new DateTime(date.Year, date.Month, 1);
var dateTo = dateFrom.AddMonths(1).AddDays(-1);
@ -87,7 +87,7 @@ namespace Squidex.Infrastructure.UsageTracking
}
[Fact]
public async Task Should_sum_up_when_getting_last_calls_calls()
public async Task Should_sum_up_if_getting_last_calls_calls()
{
var dateFrom = date;
var dateTo = dateFrom.AddDays(10);

6
backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs

@ -95,7 +95,7 @@ namespace Squidex.Web
}
[Fact]
public async Task Should_return_forbidden_when_user_has_wrong_permission()
public async Task Should_return_forbidden_if_user_has_wrong_permission()
{
actionExecutingContext.HttpContext.Features.Set<IAppFeature>(new AppFeature(NamedId.Of(DomainId.NewGuid(), "my-app")));
@ -112,7 +112,7 @@ namespace Squidex.Web
}
[Fact]
public async Task Should_return_forbidden_when_route_data_has_no_value()
public async Task Should_return_forbidden_if_route_data_has_no_value()
{
user.AddClaim(new Claim(SquidexClaimTypes.Permissions, "squidex.apps.other-app"));
@ -127,7 +127,7 @@ namespace Squidex.Web
}
[Fact]
public async Task Should_return_forbidden_when_user_has_no_permission()
public async Task Should_return_forbidden_if_user_has_no_permission()
{
SetContext();

2
backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs

@ -33,7 +33,7 @@ namespace Squidex.Web.CommandMiddlewares
}
[Fact]
public async Task Should_do_nothing_when_context_is_null()
public async Task Should_do_nothing_if_context_is_null()
{
A.CallTo(() => httpContextAccessor.HttpContext)
.Returns(null!);

4
backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs

@ -33,13 +33,13 @@ namespace Squidex.Web.CommandMiddlewares
}
[Fact]
public async Task Should_throw_security_exception_when_no_subject_or_client_is_found()
public async Task Should_throw_security_exception_if_no_subject_or_client_is_found()
{
await Assert.ThrowsAsync<DomainForbiddenException>(() => HandleAsync(new CreateContent()));
}
[Fact]
public async Task Should_do_nothing_when_context_is_null()
public async Task Should_do_nothing_if_context_is_null()
{
A.CallTo(() => httpContextAccessor.HttpContext)
.Returns(null!);

6
backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs

@ -21,7 +21,7 @@ namespace Squidex.Web.Pipeline
[Theory]
[InlineData("administrator")]
[InlineData("ADMINISTRATOR")]
public async Task Should_add_admin_permission_when_user_is_in_role(string role)
public async Task Should_add_admin_permission_if_user_is_in_role(string role)
{
var userIdentity = new ClaimsIdentity();
var userPrinicpal = new ClaimsPrincipal(userIdentity);
@ -35,7 +35,7 @@ namespace Squidex.Web.Pipeline
}
[Fact]
public async Task Should_not_add_admin_persmission_when_user_has_other_role()
public async Task Should_not_add_admin_persmission_if_user_has_other_role()
{
var userIdentity = new ClaimsIdentity();
var userPrinicpal = new ClaimsPrincipal(userIdentity);
@ -48,7 +48,7 @@ namespace Squidex.Web.Pipeline
}
[Fact]
public async Task Should_not_add_admin_persmission_when_user_has_no_role()
public async Task Should_not_add_admin_persmission_if_user_has_no_role()
{
var userIdentity = new ClaimsIdentity();
var userPrinicpal = new ClaimsPrincipal(userIdentity);

6
backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs

@ -102,7 +102,7 @@ namespace Squidex.Web.Pipeline
}
[Fact]
public async Task Should_append_authorization_as_header_when_user_has_subject()
public async Task Should_append_authorization_as_header_if_user_has_subject()
{
var identity = (ClaimsIdentity)httpContext.User.Identity!;
@ -114,7 +114,7 @@ namespace Squidex.Web.Pipeline
}
[Fact]
public async Task Should_append_client_id_as_header_when_user_has_client_but_no_subject()
public async Task Should_append_client_id_as_header_if_user_has_client_but_no_subject()
{
var identity = (ClaimsIdentity)httpContext.User.Identity!;
@ -299,7 +299,7 @@ namespace Squidex.Web.Pipeline
}
[Fact]
public async Task Should_not_generate_etag_when_already_added()
public async Task Should_not_generate_etag_if_already_added()
{
var id1 = DomainId.NewGuid();
var id2 = DomainId.NewGuid();

1
frontend/app/features/administration/declarations.ts

@ -6,7 +6,6 @@
*/
export * from './administration-area.component';
export * from './guards/unset-user.guard';
export * from './guards/user-must-exist.guard';
export * from './internal';
export * from './pages/cluster/cluster-page.component';

36
frontend/app/features/administration/guards/unset-user.guard.spec.ts

@ -1,36 +0,0 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { UsersState } from '@app/features/administration/internal';
import { of } from 'rxjs';
import { IMock, Mock, Times } from 'typemoq';
import { UnsetUserGuard } from './unset-user.guard';
describe('UnsetUserGuard', () => {
let usersState: IMock<UsersState>;
let userGuard: UnsetUserGuard;
beforeEach(() => {
usersState = Mock.ofType<UsersState>();
userGuard = new UnsetUserGuard(usersState.object);
});
it('should unset user', () => {
usersState.setup(x => x.select(null))
.returns(() => of(null));
let result: boolean;
userGuard.canActivate().subscribe(x => {
result = x;
}).unsubscribe();
expect(result!).toBeTruthy();
usersState.verify(x => x.select(null), Times.once());
});
});

24
frontend/app/features/administration/guards/unset-user.guard.ts

@ -1,24 +0,0 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { UsersState } from '@app/features/administration/internal';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable()
export class UnsetUserGuard implements CanActivate {
constructor(
private readonly usersState: UsersState
) {
}
public canActivate(): Observable<boolean> {
return this.usersState.select(null).pipe(map(u => u === null));
}
}

63
frontend/app/features/administration/guards/user-must-exist.guard.spec.ts

@ -12,11 +12,6 @@ import { IMock, Mock, Times } from 'typemoq';
import { UserMustExistGuard } from './user-must-exist.guard';
describe('UserMustExistGuard', () => {
const route: any = {
params: {
userId: '123'
}
};
let usersState: IMock<UsersState>;
let router: IMock<Router>;
@ -28,12 +23,18 @@ describe('UserMustExistGuard', () => {
userGuard = new UserMustExistGuard(usersState.object, router.object);
});
it('should load user and return true when found', () => {
it('should load user and return true if found', () => {
usersState.setup(x => x.select('123'))
.returns(() => of(<UserDto>{}));
let result: boolean;
const route: any = {
params: {
userId: '123'
}
};
userGuard.canActivate(route).subscribe(x => {
result = x;
}).unsubscribe();
@ -43,12 +44,18 @@ describe('UserMustExistGuard', () => {
usersState.verify(x => x.select('123'), Times.once());
});
it('should load user and return false when not found', () => {
it('should load user and return false if not found', () => {
usersState.setup(x => x.select('123'))
.returns(() => of(null));
let result: boolean;
const route: any = {
params: {
userId: '123'
}
};
userGuard.canActivate(route).subscribe(x => {
result = x;
}).unsubscribe();
@ -57,4 +64,46 @@ describe('UserMustExistGuard', () => {
router.verify(x => x.navigate(['/404']), Times.once());
});
it('should unset user if user id is undefined', () => {
usersState.setup(x => x.select(null))
.returns(() => of(null));
let result: boolean;
const route: any = {
params: {
userId: undefined
}
};
userGuard.canActivate(route).subscribe(x => {
result = x;
}).unsubscribe();
expect(result!).toBeTruthy();
usersState.verify(x => x.select(null), Times.once());
});
it('should unset user if user id is <new>', () => {
usersState.setup(x => x.select(null))
.returns(() => of(null));
let result: boolean;
const route: any = {
params: {
userId: 'new'
}
};
userGuard.canActivate(route).subscribe(x => {
result = x;
}).unsubscribe();
expect(result!).toBeTruthy();
usersState.verify(x => x.select(null), Times.once());
});
});

4
frontend/app/features/administration/guards/user-must-exist.guard.ts

@ -23,6 +23,10 @@ export class UserMustExistGuard implements CanActivate {
public canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
const userId = allParams(route)['userId'];
if (!userId || userId === 'new') {
return this.usersState.select(null).pipe(map(u => u === null));
}
const result =
this.usersState.select(userId).pipe(
tap(dto => {

8
frontend/app/features/administration/module.ts

@ -10,7 +10,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SqxFrameworkModule, SqxSharedModule } from '@app/shared';
import { AdministrationAreaComponent, ClusterPageComponent, EventConsumerComponent, EventConsumersPageComponent, EventConsumersService, EventConsumersState, RestorePageComponent, UnsetUserGuard, UserComponent, UserMustExistGuard, UserPageComponent, UsersPageComponent, UsersService, UsersState } from './declarations';
import { AdministrationAreaComponent, ClusterPageComponent, EventConsumerComponent, EventConsumersPageComponent, EventConsumersService, EventConsumersState, RestorePageComponent, UserComponent, UserMustExistGuard, UserPageComponent, UsersPageComponent, UsersService, UsersState } from './declarations';
const routes: Routes = [
{
@ -36,11 +36,6 @@ const routes: Routes = [
path: 'users',
component: UsersPageComponent,
children: [
{
path: 'new',
component: UserPageComponent,
canActivate: [UnsetUserGuard]
},
{
path: ':userId',
component: UserPageComponent,
@ -73,7 +68,6 @@ const routes: Routes = [
providers: [
EventConsumersService,
EventConsumersState,
UnsetUserGuard,
UserMustExistGuard,
UsersService,
UsersState

24
frontend/app/features/administration/state/event-consumers.state.spec.ts

@ -46,7 +46,7 @@ describe('EventConsumersState', () => {
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.never());
});
it('should reset loading when loading failed', () => {
it('should reset loading state if loading failed', () => {
eventConsumersService.setup(x => x.getEventConsumers())
.returns(() => throwError('error'));
@ -55,7 +55,7 @@ describe('EventConsumersState', () => {
expect(eventConsumersState.snapshot.isLoading).toBeFalsy();
});
it('should show notification on load when reload is true', () => {
it('should show notification on load if reload is true', () => {
eventConsumersService.setup(x => x.getEventConsumers())
.returns(() => of(new EventConsumersDto([eventConsumer1, eventConsumer2]))).verifiable();
@ -66,7 +66,7 @@ describe('EventConsumersState', () => {
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
it('should show notification on load error when silent is false', () => {
it('should show notification on load error if silent is false', () => {
eventConsumersService.setup(x => x.getEventConsumers())
.returns(() => throwError({})).verifiable();
@ -86,7 +86,7 @@ describe('EventConsumersState', () => {
eventConsumersState.load().subscribe();
});
it('should update event consumer when started', () => {
it('should update event consumer if started', () => {
const updated = createEventConsumer(2, '_new');
eventConsumersService.setup(x => x.putStart(eventConsumer2))
@ -94,12 +94,10 @@ describe('EventConsumersState', () => {
eventConsumersState.start(eventConsumer2).subscribe();
const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1];
expect(newConsumer2).toEqual(updated);
expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]);
});
it('should update event consumer when stopped', () => {
it('should update event consumer if stopped', () => {
const updated = createEventConsumer(2, '_new');
eventConsumersService.setup(x => x.putStop(eventConsumer2))
@ -107,12 +105,10 @@ describe('EventConsumersState', () => {
eventConsumersState.stop(eventConsumer2).subscribe();
const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1];
expect(newConsumer2).toEqual(updated);
expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]);
});
it('should update event consumer when reset', () => {
it('should update event consumer if reset', () => {
const updated = createEventConsumer(2, '_new');
eventConsumersService.setup(x => x.putReset(eventConsumer2))
@ -120,9 +116,7 @@ describe('EventConsumersState', () => {
eventConsumersState.reset(eventConsumer2).subscribe();
const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1];
expect(newConsumer2).toEqual(updated);
expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]);
});
});
});

2
frontend/app/features/administration/state/event-consumers.state.ts

@ -99,7 +99,7 @@ export class EventConsumersState extends State<Snapshot> {
private replaceEventConsumer(eventConsumer: EventConsumerDto) {
this.next(s => {
const eventConsumers = s.eventConsumers.replaceBy('name', eventConsumer);
const eventConsumers = s.eventConsumers.replacedBy('name', eventConsumer);
return { ...s, eventConsumers };
}, 'Updated');

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save