Browse Source

Code cleanup.

pull/342/head
Sebastian Stehle 7 years ago
parent
commit
7e2fc6f796
  1. 4
      src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs
  2. 2
      src/Squidex.Domain.Apps.Core.Model/Schemas/Fields.cs
  3. 1
      src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonFieldModel.cs
  4. 1
      src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs
  5. 2
      src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs
  6. 4
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/Triggers/ContentChangedTriggerHandler.cs
  7. 2
      src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/CustomProperty.cs
  8. 4
      src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  9. 2
      src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentDraftCollection.cs
  10. 4
      src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Visitors/FindExtensions.cs
  11. 1
      src/Squidex.Domain.Apps.Entities.MongoDb/History/MongoHistoryEventRepository.cs
  12. 10
      src/Squidex.Domain.Apps.Entities/Apps/BackupApps.cs
  13. 10
      src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs
  14. 3
      src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs
  15. 2
      src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs
  16. 3
      src/Squidex.Domain.Apps.Entities/Contents/ContentQueryService.cs
  17. 2
      src/Squidex.Domain.Apps.Entities/Rules/EventEnricher.cs
  18. 7
      src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs
  19. 6
      src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs
  20. 2
      src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs
  21. 1
      src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEvent.cs
  22. 2
      src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs
  23. 2
      src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs
  24. 2
      src/Squidex.Infrastructure/IMigrated.cs
  25. 6
      src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs
  26. 6
      src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs
  27. 2
      src/Squidex.Infrastructure/Queries/FilterValue.cs
  28. 2
      src/Squidex.Infrastructure/Queries/OData/ConstantWithTypeVisitor.cs
  29. 1
      src/Squidex.Infrastructure/States/Persistence{TSnapshot,TKey}.cs
  30. 2
      src/Squidex.Shared/Permissions.cs
  31. 1
      src/Squidex/Areas/Api/Controllers/Apps/AppClientsController.cs
  32. 3
      src/Squidex/Areas/Api/Controllers/Apps/AppRolesController.cs
  33. 2
      src/Squidex/Areas/Api/Controllers/Apps/AppsController.cs
  34. 1
      src/Squidex/Areas/Api/Controllers/Apps/Models/AppDto.cs
  35. 1
      src/Squidex/Areas/Api/Controllers/Apps/Models/ContributorsDto.cs
  36. 1
      src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs
  37. 3
      src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs
  38. 1
      src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs
  39. 1
      src/Squidex/Areas/Api/Controllers/History/HistoryController.cs
  40. 1
      src/Squidex/Areas/Api/Controllers/Rules/Models/RuleEventsDto.cs
  41. 2
      src/Squidex/Areas/Api/Controllers/Schemas/SchemasController.cs
  42. 1
      src/Squidex/Areas/Api/Controllers/Statistics/UsagesController.cs
  43. 6
      src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  44. 1
      src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs
  45. 1
      src/Squidex/Pipeline/AppResolver.cs
  46. 16
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs
  47. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs
  48. 4
      tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs
  49. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/Tags/TagNormalizerTests.cs
  50. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs
  51. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs
  52. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs
  53. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs
  54. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppGrainTests.cs
  55. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs
  56. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetCommandMiddlewareTests.cs
  57. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetGrainTests.cs
  58. 8
      tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsGrainTests.cs
  59. 4
      tests/Squidex.Domain.Apps.Entities.Tests/Comments/Guards/GuardCommentsTests.cs
  60. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentGrainTests.cs
  61. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleGrainTests.cs
  62. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs
  63. 2
      tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/HandlerTestBase.cs
  64. 3
      tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs
  65. 2
      tests/Squidex.Infrastructure.Tests/Json/ClaimsPrincipalConverterTests.cs
  66. 3
      tests/Squidex.Infrastructure.Tests/LanguageTests.cs
  67. 4
      tests/Squidex.Infrastructure.Tests/Log/SemanticLogAdapterTests.cs
  68. 4
      tools/Migrate_01/Rebuilder.cs

4
src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs

@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
[Pure] [Pure]
public FieldCollection<T> Remove(long fieldId) public FieldCollection<T> Remove(long fieldId)
{ {
if (!ById.TryGetValue(fieldId, out var field)) if (!ById.TryGetValue(fieldId, out _))
{ {
return this; return this;
} }
@ -150,7 +150,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
return this; return this;
} }
if (!(newField is T typedField)) if (!(newField is T))
{ {
throw new InvalidOperationException($"Field must be of type {typeof(T)}"); throw new InvalidOperationException($"Field must be of type {typeof(T)}");
} }

2
src/Squidex.Domain.Apps.Core.Model/Schemas/Fields.cs

@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
{ {
public static RootField<ArrayFieldProperties> Array(long id, string name, Partitioning partitioning, params NestedField[] fields) public static RootField<ArrayFieldProperties> Array(long id, string name, Partitioning partitioning, params NestedField[] fields)
{ {
return new ArrayField(id, name, partitioning, fields: fields); return new ArrayField(id, name, partitioning, fields);
} }
public static ArrayField Array(long id, string name, Partitioning partitioning, ArrayFieldProperties properties = null, IFieldSettings settings = null) public static ArrayField Array(long id, string name, Partitioning partitioning, ArrayFieldProperties properties = null, IFieldSettings settings = null)

1
src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonFieldModel.cs

@ -8,7 +8,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using System; using System;
using System.Linq;
using P = Squidex.Domain.Apps.Core.Partitioning; using P = Squidex.Domain.Apps.Core.Partitioning;
namespace Squidex.Domain.Apps.Core.Schemas.Json namespace Squidex.Domain.Apps.Core.Schemas.Json

1
src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Squidex.Infrastructure; using Squidex.Infrastructure;

2
src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs

@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
return (data, field) => return (data, field) =>
{ {
if (field is IField<AssetsFieldProperties> assetField && (isAll || fields.Contains(field.Name))) if (field is IField<AssetsFieldProperties> && (isAll || fields.Contains(field.Name)))
{ {
foreach (var partition in data) foreach (var partition in data)
{ {

4
src/Squidex.Domain.Apps.Core.Operations/HandleRules/Triggers/ContentChangedTriggerHandler.cs

@ -67,9 +67,9 @@ namespace Squidex.Domain.Apps.Core.HandleRules.Triggers
return false; return false;
} }
private bool MatchsSchema(ContentChangedTriggerSchemaV2 schema, NamedId<Guid> @eventId) private static bool MatchsSchema(ContentChangedTriggerSchemaV2 schema, NamedId<Guid> eventId)
{ {
return @eventId.Id == schema.SchemaId; return eventId.Id == schema.SchemaId;
} }
private bool MatchsCondition(ContentChangedTriggerSchemaV2 schema, EnrichedSchemaEvent @event) private bool MatchsCondition(ContentChangedTriggerSchemaV2 schema, EnrichedSchemaEvent @event)

2
src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/CustomProperty.cs

@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
{ {
public abstract class CustomProperty : PropertyDescriptor public abstract class CustomProperty : PropertyDescriptor
{ {
public CustomProperty() protected CustomProperty()
: base(PropertyFlag.CustomJsValue) : base(PropertyFlag.CustomJsValue)
{ {
Enumerable = true; Enumerable = true;

4
src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -229,7 +229,7 @@ namespace Squidex.Domain.Apps.Core.Scripting
private static Func<string> Safe(Func<string> func) private static Func<string> Safe(Func<string> func)
{ {
return new Func<string>(() => return () =>
{ {
try try
{ {
@ -239,7 +239,7 @@ namespace Squidex.Domain.Apps.Core.Scripting
{ {
return "null"; return "null";
} }
}); };
} }
private static JsValue Slugify(JsValue thisObject, JsValue[] arguments) private static JsValue Slugify(JsValue thisObject, JsValue[] arguments)

2
src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentDraftCollection.cs

@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
.Text(x => x.DataText) .Text(x => x.DataText)
.Ascending(x => x.IndexedSchemaId) .Ascending(x => x.IndexedSchemaId)
.Ascending(x => x.IsDeleted) .Ascending(x => x.IsDeleted)
.Ascending(x => x.Status)), .Ascending(x => x.Status))
}, ct); }, ct);
await base.SetupCollectionAsync(collection, ct); await base.SetupCollectionAsync(collection, ct);

4
src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Visitors/FindExtensions.cs

@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Visitors
private static Func<IReadOnlyList<string>, IReadOnlyList<string>> PathConverter(Schema schema, bool useDraft) private static Func<IReadOnlyList<string>, IReadOnlyList<string>> PathConverter(Schema schema, bool useDraft)
{ {
return new Func<IReadOnlyList<string>, IReadOnlyList<string>>(propertyNames => return propertyNames =>
{ {
var result = new List<string>(propertyNames); var result = new List<string>(propertyNames);
@ -91,7 +91,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Visitors
} }
return result; return result;
}); };
} }
public static IFindFluent<MongoContentEntity, MongoContentEntity> ContentSort(this IFindFluent<MongoContentEntity, MongoContentEntity> cursor, Query query) public static IFindFluent<MongoContentEntity, MongoContentEntity> ContentSort(this IFindFluent<MongoContentEntity, MongoContentEntity> cursor, Query query)

1
src/Squidex.Domain.Apps.Entities.MongoDb/History/MongoHistoryEventRepository.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;

10
src/Squidex.Domain.Apps.Entities/Apps/BackupApps.cs

@ -15,7 +15,6 @@ using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Apps; using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Json.Objects; using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Shared.Users; using Squidex.Shared.Users;
@ -28,7 +27,6 @@ namespace Squidex.Domain.Apps.Entities.Apps
private const string SettingsFile = "Settings.json"; private const string SettingsFile = "Settings.json";
private readonly IGrainFactory grainFactory; private readonly IGrainFactory grainFactory;
private readonly IUserResolver userResolver; private readonly IUserResolver userResolver;
private readonly IJsonSerializer serializer;
private readonly IAppsByNameIndex appsByNameIndex; private readonly IAppsByNameIndex appsByNameIndex;
private readonly HashSet<string> contributors = new HashSet<string>(); private readonly HashSet<string> contributors = new HashSet<string>();
private Dictionary<string, string> usersWithEmail = new Dictionary<string, string>(); private Dictionary<string, string> usersWithEmail = new Dictionary<string, string>();
@ -38,14 +36,12 @@ namespace Squidex.Domain.Apps.Entities.Apps
public override string Name { get; } = "Apps"; public override string Name { get; } = "Apps";
public BackupApps(IGrainFactory grainFactory, IUserResolver userResolver, IJsonSerializer serializer) public BackupApps(IGrainFactory grainFactory, IUserResolver userResolver)
{ {
Guard.NotNull(grainFactory, nameof(grainFactory)); Guard.NotNull(grainFactory, nameof(grainFactory));
Guard.NotNull(serializer, nameof(serializer));
Guard.NotNull(userResolver, nameof(userResolver)); Guard.NotNull(userResolver, nameof(userResolver));
this.grainFactory = grainFactory; this.grainFactory = grainFactory;
this.serializer = serializer;
this.userResolver = userResolver; this.userResolver = userResolver;
appsByNameIndex = grainFactory.GetGrain<IAppsByNameIndex>(SingleGrain.Id); appsByNameIndex = grainFactory.GetGrain<IAppsByNameIndex>(SingleGrain.Id);
@ -83,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
{ {
appName = appCreated.Name; appName = appCreated.Name;
await ResolveUsersAsync(reader, actor); await ResolveUsersAsync(reader);
await ReserveAppAsync(appId); await ReserveAppAsync(appId);
break; break;
@ -148,7 +144,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
return userMapping.GetOrAdd(userId, fallback); return userMapping.GetOrAdd(userId, fallback);
} }
private async Task ResolveUsersAsync(BackupReader reader, RefToken actor) private async Task ResolveUsersAsync(BackupReader reader)
{ {
await ReadUsersAsync(reader); await ReadUsersAsync(reader);

10
src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.Repositories;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Backup;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
@ -26,23 +25,18 @@ namespace Squidex.Domain.Apps.Entities.Assets
private const string TagsFile = "AssetTags.json"; private const string TagsFile = "AssetTags.json";
private readonly HashSet<Guid> assetIds = new HashSet<Guid>(); private readonly HashSet<Guid> assetIds = new HashSet<Guid>();
private readonly IAssetStore assetStore; private readonly IAssetStore assetStore;
private readonly IAssetRepository assetRepository;
private readonly ITagService tagService; private readonly ITagService tagService;
public override string Name { get; } = "Assets"; public override string Name { get; } = "Assets";
public BackupAssets(IStore<Guid> store, public BackupAssets(IStore<Guid> store, IAssetStore assetStore, ITagService tagService)
IAssetStore assetStore,
IAssetRepository assetRepository,
ITagService tagService)
: base(store) : base(store)
{ {
Guard.NotNull(assetStore, nameof(assetStore)); Guard.NotNull(assetStore, nameof(assetStore));
Guard.NotNull(assetRepository, nameof(assetRepository));
Guard.NotNull(tagService, nameof(tagService)); Guard.NotNull(tagService, nameof(tagService));
this.assetStore = assetStore; this.assetStore = assetStore;
this.assetRepository = assetRepository;
this.tagService = tagService; this.tagService = tagService;
} }

3
src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System.Globalization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
@ -79,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Backup.Model
public EventData ToData() public EventData ToData()
{ {
return new EventData(Type, Metadata, Payload.ToString()); return new EventData(Type, Metadata, Payload.ToString(CultureInfo.InvariantCulture));
} }
} }

2
src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs

@ -111,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
private ValidationContext CreateValidationContext() private ValidationContext CreateValidationContext()
{ {
return new ValidationContext(contentId, schemaId, (sid, filterNode) => QueryContentsAsync(sid, filterNode), QueryAssetsAsync); return new ValidationContext(contentId, schemaId, QueryContentsAsync, QueryAssetsAsync);
} }
private async Task<IReadOnlyList<IAssetInfo>> QueryAssetsAsync(IEnumerable<Guid> assetIds) private async Task<IReadOnlyList<IAssetInfo>> QueryAssetsAsync(IEnumerable<Guid> assetIds)

3
src/Squidex.Domain.Apps.Entities/Contents/ContentQueryService.cs

@ -25,7 +25,6 @@ using Squidex.Infrastructure.Queries.OData;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Shared; using Squidex.Shared;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
using Squidex.Shared.Users;
#pragma warning disable RECS0147 #pragma warning disable RECS0147
@ -275,7 +274,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
return schema; return schema;
} }
private void CheckPermission(ISchemaEntity schema, ClaimsPrincipal user) private static void CheckPermission(ISchemaEntity schema, ClaimsPrincipal user)
{ {
var permissions = user.Permissions(); var permissions = user.Permissions();
var permission = Permissions.ForApp(Permissions.AppContentsRead, schema.AppId.Name, schema.Name); var permission = Permissions.ForApp(Permissions.AppContentsRead, schema.AppId.Name, schema.Name);

2
src/Squidex.Domain.Apps.Entities/Rules/EventEnricher.cs

@ -170,7 +170,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
{ {
x.AbsoluteExpirationRelativeToNow = UserCacheDuration; x.AbsoluteExpirationRelativeToNow = UserCacheDuration;
IUser user = null; IUser user;
try try
{ {
user = await userResolver.FindByIdOrEmailAsync(actor.Identifier); user = await userResolver.FindByIdOrEmailAsync(actor.Identifier);

7
src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Backup;
using Squidex.Domain.Apps.Entities.Schemas.Indexes; using Squidex.Domain.Apps.Entities.Schemas.Indexes;
using Squidex.Domain.Apps.Events.Schemas; using Squidex.Domain.Apps.Events.Schemas;
@ -22,18 +21,14 @@ namespace Squidex.Domain.Apps.Entities.Schemas
public sealed class BackupSchemas : BackupHandler public sealed class BackupSchemas : BackupHandler
{ {
private readonly Dictionary<string, Guid> schemasByName = new Dictionary<string, Guid>(); private readonly Dictionary<string, Guid> schemasByName = new Dictionary<string, Guid>();
private readonly FieldRegistry fieldRegistry;
private readonly IGrainFactory grainFactory; private readonly IGrainFactory grainFactory;
public override string Name { get; } = "Schemas"; public override string Name { get; } = "Schemas";
public BackupSchemas(FieldRegistry fieldRegistry, IGrainFactory grainFactory) public BackupSchemas(IGrainFactory grainFactory)
{ {
Guard.NotNull(fieldRegistry, nameof(fieldRegistry));
Guard.NotNull(grainFactory, nameof(grainFactory)); Guard.NotNull(grainFactory, nameof(grainFactory));
this.fieldRegistry = fieldRegistry;
this.grainFactory = grainFactory; this.grainFactory = grainFactory;
} }

6
src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs

@ -141,7 +141,7 @@ namespace Squidex.Domain.Users.MongoDb
public bool IsId(string id) public bool IsId(string id)
{ {
return ObjectId.TryParse(id, out var _); return ObjectId.TryParse(id, out _);
} }
public IdentityUser Create(string email) public IdentityUser Create(string email)
@ -279,7 +279,7 @@ namespace Squidex.Domain.Users.MongoDb
public Task<DateTimeOffset?> GetLockoutEndDateAsync(IdentityUser user, CancellationToken cancellationToken) public Task<DateTimeOffset?> GetLockoutEndDateAsync(IdentityUser user, CancellationToken cancellationToken)
{ {
return Task.FromResult<DateTimeOffset?>(((MongoUser)user).LockoutEnd); return Task.FromResult(((MongoUser)user).LockoutEnd);
} }
public Task<int> GetAccessFailedCountAsync(IdentityUser user, CancellationToken cancellationToken) public Task<int> GetAccessFailedCountAsync(IdentityUser user, CancellationToken cancellationToken)
@ -309,7 +309,7 @@ namespace Squidex.Domain.Users.MongoDb
public Task<int> CountCodesAsync(IdentityUser user, CancellationToken cancellationToken) public Task<int> CountCodesAsync(IdentityUser user, CancellationToken cancellationToken)
{ {
return Task.FromResult(((MongoUser)user).GetToken(InternalLoginProvider, RecoveryCodeTokenName)?.Split(';')?.Length ?? 0); return Task.FromResult(((MongoUser)user).GetToken(InternalLoginProvider, RecoveryCodeTokenName)?.Split(';').Length ?? 0);
} }
public Task SetUserNameAsync(IdentityUser user, string userName, CancellationToken cancellationToken) public Task SetUserNameAsync(IdentityUser user, string userName, CancellationToken cancellationToken)

2
src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs

@ -49,7 +49,7 @@ namespace Squidex.Infrastructure.EventSourcing
throw new ConfigurationException("Cannot connect to event store.", ex); throw new ConfigurationException("Cannot connect to event store.", ex);
} }
await projectionClient.ConnectAsync(); await projectionClient.ConnectAsync(ct);
} }
public IEventSubscription CreateSubscription(IEventSubscriber subscriber, string streamFilter, string position = null) public IEventSubscription CreateSubscription(IEventSubscriber subscriber, string streamFilter, string position = null)

1
src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEvent.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Attributes;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;

2
src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs

@ -89,7 +89,7 @@ namespace Squidex.Infrastructure.MongoDb
{ {
try try
{ {
await mongoDatabase.DropCollectionAsync(CollectionName()); await mongoDatabase.DropCollectionAsync(CollectionName(), ct);
mongoCollection = CreateCollection(); mongoCollection = CreateCollection();

2
src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs

@ -34,7 +34,7 @@ namespace Squidex.Infrastructure.Diagnostics
{ "Allocated", allocated.ToReadableSize() }, { "Allocated", allocated.ToReadableSize() },
{ "Gen0Collections", GC.CollectionCount(0) }, { "Gen0Collections", GC.CollectionCount(0) },
{ "Gen1Collections", GC.CollectionCount(1) }, { "Gen1Collections", GC.CollectionCount(1) },
{ "Gen2Collections", GC.CollectionCount(2) }, { "Gen2Collections", GC.CollectionCount(2) }
}; };
var status = allocated < threshold ? HealthStatus.Healthy : HealthStatus.Unhealthy; var status = allocated < threshold ? HealthStatus.Healthy : HealthStatus.Unhealthy;

2
src/Squidex.Infrastructure/IMigrated.cs

@ -7,7 +7,7 @@
namespace Squidex.Infrastructure namespace Squidex.Infrastructure
{ {
public interface IMigrated<T> public interface IMigrated<out T>
{ {
T Migrate(); T Migrate();
} }

6
src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs

@ -38,7 +38,7 @@ namespace Squidex.Infrastructure.Json.Newtonsoft
return ReadJson(reader); return ReadJson(reader);
} }
private IJsonValue ReadJson(JsonReader reader) private static IJsonValue ReadJson(JsonReader reader)
{ {
switch (reader.TokenType) switch (reader.TokenType)
{ {
@ -125,11 +125,11 @@ namespace Squidex.Infrastructure.Json.Newtonsoft
WriteJson(writer, (IJsonValue)value); WriteJson(writer, (IJsonValue)value);
} }
private void WriteJson(JsonWriter writer, IJsonValue value) private static void WriteJson(JsonWriter writer, IJsonValue value)
{ {
switch (value) switch (value)
{ {
case JsonNull n: case JsonNull _:
writer.WriteNull(); writer.WriteNull();
break; break;
case JsonBoolean s: case JsonBoolean s:

6
src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs

@ -65,8 +65,10 @@ namespace Squidex.Infrastructure.Log.Internal
var fs = new FileStream(fileInfo.FullName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); var fs = new FileStream(fileInfo.FullName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
writer = new StreamWriter(fs, Encoding.UTF8); writer = new StreamWriter(fs, Encoding.UTF8)
writer.AutoFlush = true; {
AutoFlush = true
};
writer.WriteLine($"--- Started Logging {DateTime.UtcNow} ---", 1); writer.WriteLine($"--- Started Logging {DateTime.UtcNow} ---", 1);
} }

2
src/Squidex.Infrastructure/Queries/FilterValue.cs

@ -131,7 +131,7 @@ namespace Squidex.Infrastructure.Queries
return ToString(Value); return ToString(Value);
} }
private string ToString(object value) private static string ToString(object value)
{ {
if (value == null) if (value == null)
{ {

2
src/Squidex.Infrastructure/Queries/OData/ConstantWithTypeVisitor.cs

@ -148,7 +148,7 @@ namespace Squidex.Infrastructure.Queries.OData
throw new NotSupportedException(); throw new NotSupportedException();
} }
private Instant ParseInstant(object value) private static Instant ParseInstant(object value)
{ {
if (value is DateTimeOffset dateTimeOffset) if (value is DateTimeOffset dateTimeOffset)
{ {

1
src/Squidex.Infrastructure/States/Persistence{TSnapshot,TKey}.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
#pragma warning disable RECS0012 // 'if' statement can be re-written as 'switch' statement #pragma warning disable RECS0012 // 'if' statement can be re-written as 'switch' statement

2
src/Squidex.Shared/Permissions.cs

@ -166,7 +166,7 @@ namespace Squidex.Shared
public static string[] ToAppNames(this PermissionSet permissions) public static string[] ToAppNames(this PermissionSet permissions)
{ {
var matching = permissions.Where(x => x.StartsWith($"squidex.apps.")); var matching = permissions.Where(x => x.StartsWith("squidex.apps."));
var result = var result =
matching matching

1
src/Squidex/Areas/Api/Controllers/Apps/AppClientsController.cs

@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
using Squidex.Areas.Api.Controllers.Apps.Models; using Squidex.Areas.Api.Controllers.Apps.Models;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Pipeline; using Squidex.Pipeline;
using Squidex.Shared; using Squidex.Shared;

3
src/Squidex/Areas/Api/Controllers/Apps/AppRolesController.cs

@ -93,8 +93,7 @@ namespace Squidex.Areas.Api.Controllers.Apps
[ApiCosts(1)] [ApiCosts(1)]
public async Task<IActionResult> PostRole(string app, [FromBody] AddRoleDto request) public async Task<IActionResult> PostRole(string app, [FromBody] AddRoleDto request)
{ {
var command = request.ToCommand(); await CommandBus.PublishAsync(request.ToCommand());
var context = await CommandBus.PublishAsync(command);
return NoContent(); return NoContent();
} }

2
src/Squidex/Areas/Api/Controllers/Apps/AppsController.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
@ -20,7 +19,6 @@ using Squidex.Infrastructure.Security;
using Squidex.Pipeline; using Squidex.Pipeline;
using Squidex.Shared; using Squidex.Shared;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
using Squidex.Shared.Users;
namespace Squidex.Areas.Api.Controllers.Apps namespace Squidex.Areas.Api.Controllers.Apps
{ {

1
src/Squidex/Areas/Api/Controllers/Apps/Models/AppDto.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using NodaTime; using NodaTime;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Apps.Services; using Squidex.Domain.Apps.Entities.Apps.Services;

1
src/Squidex/Areas/Api/Controllers/Apps/Models/ContributorsDto.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Apps.Services; using Squidex.Domain.Apps.Entities.Apps.Services;
using Squidex.Infrastructure; using Squidex.Infrastructure;

1
src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Orleans; using Orleans;

3
src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs

@ -82,7 +82,8 @@ namespace Squidex.Areas.Api.Controllers.Comments
public async Task<IActionResult> PostComment(string app, Guid commentsId, [FromBody] UpsertCommentDto request) public async Task<IActionResult> PostComment(string app, Guid commentsId, [FromBody] UpsertCommentDto request)
{ {
var command = request.ToCreateCommand(commentsId); var command = request.ToCreateCommand(commentsId);
var context = await CommandBus.PublishAsync(command);
await CommandBus.PublishAsync(command);
var response = CommentDto.FromCommand(command); var response = CommentDto.FromCommand(command);

1
src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs

@ -19,7 +19,6 @@ using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Contents.Commands; using Squidex.Domain.Apps.Entities.Contents.Commands;
using Squidex.Domain.Apps.Entities.Contents.GraphQL; using Squidex.Domain.Apps.Entities.Contents.GraphQL;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Pipeline; using Squidex.Pipeline;
using Squidex.Shared; using Squidex.Shared;

1
src/Squidex/Areas/Api/Controllers/History/HistoryController.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Squidex.Areas.Api.Controllers.History.Models; using Squidex.Areas.Api.Controllers.History.Models;

1
src/Squidex/Areas/Api/Controllers/Rules/Models/RuleEventsDto.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using Squidex.Domain.Apps.Entities.Rules; using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Infrastructure;
namespace Squidex.Areas.Api.Controllers.Rules.Models namespace Squidex.Areas.Api.Controllers.Rules.Models
{ {

2
src/Squidex/Areas/Api/Controllers/Schemas/SchemasController.cs

@ -6,8 +6,6 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;

1
src/Squidex/Areas/Api/Controllers/Statistics/UsagesController.cs

@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Mvc;
using Squidex.Areas.Api.Controllers.Statistics.Models; using Squidex.Areas.Api.Controllers.Statistics.Models;
using Squidex.Domain.Apps.Entities.Apps.Services; using Squidex.Domain.Apps.Entities.Apps.Services;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.UsageTracking; using Squidex.Infrastructure.UsageTracking;
using Squidex.Pipeline; using Squidex.Pipeline;

6
src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs

@ -35,9 +35,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
private readonly UserManager<IdentityUser> userManager; private readonly UserManager<IdentityUser> userManager;
private readonly IUserFactory userFactory; private readonly IUserFactory userFactory;
private readonly IUserEvents userEvents; private readonly IUserEvents userEvents;
private readonly IUserResolver userResolver;
private readonly IOptions<MyIdentityOptions> identityOptions; private readonly IOptions<MyIdentityOptions> identityOptions;
private readonly IOptions<MyUrlsOptions> urlOptions;
private readonly ISemanticLog log; private readonly ISemanticLog log;
private readonly IIdentityServerInteractionService interactions; private readonly IIdentityServerInteractionService interactions;
@ -46,16 +44,12 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
UserManager<IdentityUser> userManager, UserManager<IdentityUser> userManager,
IUserFactory userFactory, IUserFactory userFactory,
IUserEvents userEvents, IUserEvents userEvents,
IUserResolver userResolver,
IOptions<MyIdentityOptions> identityOptions, IOptions<MyIdentityOptions> identityOptions,
IOptions<MyUrlsOptions> urlOptions,
ISemanticLog log, ISemanticLog log,
IIdentityServerInteractionService interactions) IIdentityServerInteractionService interactions)
{ {
this.log = log; this.log = log;
this.urlOptions = urlOptions;
this.userEvents = userEvents; this.userEvents = userEvents;
this.userResolver = userResolver;
this.userManager = userManager; this.userManager = userManager;
this.userFactory = userFactory; this.userFactory = userFactory;
this.interactions = interactions; this.interactions = interactions;

1
src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Security; using System.Security;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;

1
src/Squidex/Pipeline/AppResolver.cs

@ -16,7 +16,6 @@ using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Security;
using Squidex.Shared; using Squidex.Shared;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
using Squidex.Shared.Users;
namespace Squidex.Pipeline namespace Squidex.Pipeline
{ {

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

@ -428,9 +428,9 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
new ContentFieldData() new ContentFieldData()
.AddValue("iv", JsonValue.Array("url/to/1", "url/to/2")); .AddValue("iv", JsonValue.Array("url/to/1", "url/to/2"));
var rtesult = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "1" }), assetUrlGenerator)(source, assetsField); var result = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "1" }), assetUrlGenerator)(source, assetsField);
Assert.Equal(expected, source); Assert.Equal(expected, result);
} }
[Fact] [Fact]
@ -444,9 +444,9 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
new ContentFieldData() new ContentFieldData()
.AddValue("iv", JsonValue.Array("url/to/1", "url/to/2")); .AddValue("iv", JsonValue.Array("url/to/1", "url/to/2"));
var rtesult = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "*" }), assetUrlGenerator)(source, assetsField); var result = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "*" }), assetUrlGenerator)(source, assetsField);
Assert.Equal(expected, source); Assert.Equal(expected, result);
} }
[Fact] [Fact]
@ -460,9 +460,9 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
new ContentFieldData() new ContentFieldData()
.AddValue("iv", JsonValue.Array("1", "2")); .AddValue("iv", JsonValue.Array("1", "2"));
var rtesult = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "2" }), assetUrlGenerator)(source, assetsField); var result = FieldConverters.ResolveAssetUrls(new HashSet<string>(new[] { "2" }), assetUrlGenerator)(source, assetsField);
Assert.Equal(expected, source); Assert.Equal(expected, result);
} }
[Fact] [Fact]
@ -476,9 +476,9 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
new ContentFieldData() new ContentFieldData()
.AddValue("iv", JsonValue.Array("1", "2")); .AddValue("iv", JsonValue.Array("1", "2"));
var rtesult = FieldConverters.ResolveAssetUrls(null, assetUrlGenerator)(source, assetsField); var result = FieldConverters.ResolveAssetUrls(null, assetUrlGenerator)(source, assetsField);
Assert.Equal(expected, source); Assert.Equal(expected, result);
} }
} }
} }

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

@ -269,7 +269,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds
private static IJsonValue CreateValue(params Guid[] ids) private static IJsonValue CreateValue(params Guid[] ids)
{ {
return ids == null ? (IJsonValue)JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray()); return ids == null ? JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray());
} }
} }
} }

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

@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
{ {
var result = sut.ToPayload(new { Value = 1 }); var result = sut.ToPayload(new { Value = 1 });
Assert.True(result is string); Assert.NotNull(result);
} }
[Fact] [Fact]
@ -63,7 +63,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
var result = sut.ToPayload(@event); var result = sut.ToPayload(@event);
Assert.True(result is string); Assert.NotNull(result);
} }
[Fact] [Fact]

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/Tags/TagNormalizerTests.cs

@ -101,7 +101,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Tags
Assert.Equal(JsonValue.Array("name4"), GetNestedTags(newData)); Assert.Equal(JsonValue.Array("name4"), GetNestedTags(newData));
} }
private IJsonValue GetNestedTags(NamedContentData newData) private static IJsonValue GetNestedTags(NamedContentData newData)
{ {
var array = (JsonArray)newData["array"]["iv"]; var array = (JsonArray)newData["array"]["iv"];
var arrayItem = (JsonObject)array[0]; var arrayItem = (JsonObject)array[0];

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs

@ -104,7 +104,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent
private static IJsonValue CreateValue(params JsonObject[] ids) private static IJsonValue CreateValue(params JsonObject[] ids)
{ {
return ids == null ? (IJsonValue)JsonValue.Null : JsonValue.Array(ids.OfType<object>().ToArray()); return ids == null ? JsonValue.Null : JsonValue.Array(ids.OfType<object>().ToArray());
} }
private static RootField<ArrayFieldProperties> Field(ArrayFieldProperties properties) private static RootField<ArrayFieldProperties> Field(ArrayFieldProperties properties)

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs

@ -265,7 +265,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent
private static IJsonValue CreateValue(params Guid[] ids) private static IJsonValue CreateValue(params Guid[] ids)
{ {
return ids == null ? (IJsonValue)JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray()); return ids == null ? JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray());
} }
private static RootField<AssetsFieldProperties> Field(AssetsFieldProperties properties) private static RootField<AssetsFieldProperties> Field(AssetsFieldProperties properties)

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs

@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent
private static IJsonValue CreateValue(params Guid[] ids) private static IJsonValue CreateValue(params Guid[] ids)
{ {
return ids == null ? (IJsonValue)JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray()); return ids == null ? JsonValue.Null : JsonValue.Array(ids.Select(x => (object)x.ToString()).ToArray());
} }
private static RootField<ReferencesFieldProperties> Field(ReferencesFieldProperties properties) private static RootField<ReferencesFieldProperties> Field(ReferencesFieldProperties properties)

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs

@ -116,7 +116,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent
private static IJsonValue CreateValue(params string[] ids) private static IJsonValue CreateValue(params string[] ids)
{ {
return ids == null ? (IJsonValue)JsonValue.Null : JsonValue.Array(ids.OfType<object>().ToArray()); return ids == null ? JsonValue.Null : JsonValue.Array(ids.OfType<object>().ToArray());
} }
private static RootField<TagsFieldProperties> Field(TagsFieldProperties properties) private static RootField<TagsFieldProperties> Field(TagsFieldProperties properties)

2
tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppGrainTests.cs

@ -23,7 +23,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps
{ {
public class AppGrainTests : HandlerTestBase<AppGrain, AppState> public class AppGrainTests : HandlerTestBase<AppState>
{ {
private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>(); private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>();
private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>(); private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>();

2
tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs

@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
Assert.True(result.Contains("schemas.schema2.read")); Assert.True(result.Contains("schemas.schema2.read"));
} }
private ISchemaEntity CreateSchema(string name) private static ISchemaEntity CreateSchema(string name)
{ {
var schema = A.Fake<ISchemaEntity>(); var schema = A.Fake<ISchemaEntity>();

2
tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetCommandMiddlewareTests.cs

@ -24,7 +24,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets
{ {
public class AssetCommandMiddlewareTests : HandlerTestBase<AssetGrain, AssetState> public class AssetCommandMiddlewareTests : HandlerTestBase<AssetState>
{ {
private readonly IAssetThumbnailGenerator assetThumbnailGenerator = A.Fake<IAssetThumbnailGenerator>(); private readonly IAssetThumbnailGenerator assetThumbnailGenerator = A.Fake<IAssetThumbnailGenerator>();
private readonly IAssetStore assetStore = A.Fake<IAssetStore>(); private readonly IAssetStore assetStore = A.Fake<IAssetStore>();

2
tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetGrainTests.cs

@ -23,7 +23,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets
{ {
public class AssetGrainTests : HandlerTestBase<AssetGrain, AssetState> public class AssetGrainTests : HandlerTestBase<AssetState>
{ {
private readonly ITagService tagService = A.Fake<ITagService>(); private readonly ITagService tagService = A.Fake<ITagService>();
private readonly ImageInfo image = new ImageInfo(2048, 2048); private readonly ImageInfo image = new ImageInfo(2048, 2048);

8
tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsGrainTests.cs

@ -23,9 +23,8 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Comments namespace Squidex.Domain.Apps.Entities.Comments
{ {
public class CommentsGrainTests : HandlerTestBase<CommentsGrain, CommentsState> public class CommentsGrainTests : HandlerTestBase<CommentsState>
{ {
private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
private readonly Guid commentsId = Guid.NewGuid(); private readonly Guid commentsId = Guid.NewGuid();
private readonly CommentsGrain sut; private readonly CommentsGrain sut;
@ -139,11 +138,6 @@ namespace Squidex.Domain.Apps.Entities.Comments
); );
} }
private Task ExecuteDeleteAsync()
{
return sut.ExecuteAsync(CreateCommentsCommand(new DeleteComment()));
}
protected T CreateCommentsEvent<T>(T @event) where T : CommentsEvent protected T CreateCommentsEvent<T>(T @event) where T : CommentsEvent
{ {
@event.CommentsId = commentsId; @event.CommentsId = commentsId;

4
tests/Squidex.Domain.Apps.Entities.Tests/Comments/Guards/GuardCommentsTests.cs

@ -87,7 +87,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.Guards
var events = new List<Envelope<CommentsEvent>> var events = new List<Envelope<CommentsEvent>>
{ {
Envelope.Create(new CommentCreated { CommentId = commentId, Actor = user1 }).To<CommentsEvent>(), Envelope.Create(new CommentCreated { CommentId = commentId, Actor = user1 }).To<CommentsEvent>(),
Envelope.Create(new CommentDeleted { CommentId = commentId }).To<CommentsEvent>(), Envelope.Create(new CommentDeleted { CommentId = commentId }).To<CommentsEvent>()
}; };
Assert.Throws<DomainObjectNotFoundException>(() => GuardComments.CanUpdate(events, command)); Assert.Throws<DomainObjectNotFoundException>(() => GuardComments.CanUpdate(events, command));
@ -141,7 +141,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.Guards
var events = new List<Envelope<CommentsEvent>> var events = new List<Envelope<CommentsEvent>>
{ {
Envelope.Create(new CommentCreated { CommentId = commentId, Actor = user1 }).To<CommentsEvent>(), Envelope.Create(new CommentCreated { CommentId = commentId, Actor = user1 }).To<CommentsEvent>(),
Envelope.Create(new CommentDeleted { CommentId = commentId }).To<CommentsEvent>(), Envelope.Create(new CommentDeleted { CommentId = commentId }).To<CommentsEvent>()
}; };
Assert.Throws<DomainObjectNotFoundException>(() => GuardComments.CanDelete(events, command)); Assert.Throws<DomainObjectNotFoundException>(() => GuardComments.CanDelete(events, command));

2
tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentGrainTests.cs

@ -29,7 +29,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
{ {
public class ContentGrainTests : HandlerTestBase<ContentGrain, ContentState> public class ContentGrainTests : HandlerTestBase<ContentState>
{ {
private readonly ISchemaEntity schema = A.Fake<ISchemaEntity>(); private readonly ISchemaEntity schema = A.Fake<ISchemaEntity>();
private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>(); private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>();

2
tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleGrainTests.cs

@ -22,7 +22,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules
{ {
public class RuleGrainTests : HandlerTestBase<RuleGrain, RuleState> public class RuleGrainTests : HandlerTestBase<RuleState>
{ {
private readonly IAppProvider appProvider = A.Fake<IAppProvider>(); private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
private readonly Guid ruleId = Guid.NewGuid(); private readonly Guid ruleId = Guid.NewGuid();

2
tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs

@ -23,7 +23,7 @@ using Xunit;
namespace Squidex.Domain.Apps.Entities.Schemas namespace Squidex.Domain.Apps.Entities.Schemas
{ {
public class SchemaGrainTests : HandlerTestBase<SchemaGrain, SchemaState> public class SchemaGrainTests : HandlerTestBase<SchemaState>
{ {
private readonly IAppProvider appProvider = A.Fake<IAppProvider>(); private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
private readonly FieldRegistry registry = new FieldRegistry(new TypeNameRegistry()); private readonly FieldRegistry registry = new FieldRegistry(new TypeNameRegistry());

2
tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/HandlerTestBase.cs

@ -21,7 +21,7 @@ using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.TestHelpers namespace Squidex.Domain.Apps.Entities.TestHelpers
{ {
public abstract class HandlerTestBase<T, TState> where T : IDomainObjectGrain public abstract class HandlerTestBase<TState>
{ {
private readonly IStore<Guid> store = A.Fake<IStore<Guid>>(); private readonly IStore<Guid> store = A.Fake<IStore<Guid>>();
private readonly IPersistence<TState> persistence1 = A.Fake<IPersistence<TState>>(); private readonly IPersistence<TState> persistence1 = A.Fake<IPersistence<TState>>();

3
tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
@ -104,7 +103,7 @@ namespace Squidex.Domain.Users
var claims = new List<Claim> var claims = new List<Claim>
{ {
new Claim($"{id}_a", "1"), new Claim($"{id}_a", "1"),
new Claim($"{id}_b", "2"), new Claim($"{id}_b", "2")
}; };
return (user, claims); return (user, claims);

2
tests/Squidex.Infrastructure.Tests/Json/ClaimsPrincipalConverterTests.cs

@ -49,7 +49,7 @@ namespace Squidex.Infrastructure.Json
var serialized = value.SerializeAndDeserialize(); var serialized = value.SerializeAndDeserialize();
Assert.Null(value); Assert.Null(serialized);
} }
} }
} }

3
tests/Squidex.Infrastructure.Tests/LanguageTests.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Linq;
using Squidex.Infrastructure.TestHelpers; using Squidex.Infrastructure.TestHelpers;
using Xunit; using Xunit;
@ -37,7 +36,7 @@ namespace Squidex.Infrastructure
[Fact] [Fact]
public void Should_provide_all_languages() public void Should_provide_all_languages()
{ {
Assert.True(Language.AllLanguages.Count() > 100); Assert.True(Language.AllLanguages.Count > 100);
} }
[Fact] [Fact]

4
tests/Squidex.Infrastructure.Tests/Log/SemanticLogAdapterTests.cs

@ -137,8 +137,6 @@ namespace Squidex.Infrastructure.Log
[Fact] [Fact]
public void Should_log_additional_values() public void Should_log_additional_values()
{ {
var exception = new InvalidOperationException();
var logger = sut.CreateLogger("my-category"); var logger = sut.CreateLogger("my-category");
logger.LogDebug("My numbers are {number1} and {Number2}", 123, 456); logger.LogDebug("My numbers are {number1} and {Number2}", 123, 456);
@ -157,8 +155,6 @@ namespace Squidex.Infrastructure.Log
[Fact] [Fact]
public void Should_not_log_numbers() public void Should_not_log_numbers()
{ {
var exception = new InvalidOperationException();
var logger = sut.CreateLogger("my-category"); var logger = sut.CreateLogger("my-category");
logger.LogDebug("My numbers are {0} and {1}", 123, 456); logger.LogDebug("My numbers are {0} and {1}", 123, 456);

4
tools/Migrate_01/Rebuilder.cs

@ -25,7 +25,6 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Caching; using Squidex.Infrastructure.Caching;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
namespace Migrate_01 namespace Migrate_01
@ -34,21 +33,18 @@ namespace Migrate_01
{ {
private readonly FieldRegistry fieldRegistry; private readonly FieldRegistry fieldRegistry;
private readonly ILocalCache localCache; private readonly ILocalCache localCache;
private readonly IJsonSerializer serializer;
private readonly IStore<Guid> store; private readonly IStore<Guid> store;
private readonly IEventStore eventStore; private readonly IEventStore eventStore;
public Rebuilder( public Rebuilder(
FieldRegistry fieldRegistry, FieldRegistry fieldRegistry,
ILocalCache localCache, ILocalCache localCache,
IJsonSerializer serializer,
IStore<Guid> store, IStore<Guid> store,
IEventStore eventStore) IEventStore eventStore)
{ {
this.fieldRegistry = fieldRegistry; this.fieldRegistry = fieldRegistry;
this.eventStore = eventStore; this.eventStore = eventStore;
this.localCache = localCache; this.localCache = localCache;
this.serializer = serializer;
this.store = store; this.store = store;
} }

Loading…
Cancel
Save