Browse Source

Stylecop fixes

pull/107/head
Sebastian Stehle 8 years ago
parent
commit
389a1ab037
  1. 6
      src/Squidex.Domain.Apps.Core/Contents/ContentData.cs
  2. 3
      src/Squidex.Domain.Apps.Core/Schemas/CloneableBase.cs
  3. 3
      src/Squidex.Domain.Apps.Core/Schemas/Field_Generic.cs
  4. 3
      src/Squidex.Domain.Apps.Core/Schemas/Validators/RangeValidator.cs
  5. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/MongoContentEntity.cs
  6. 8
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/FilterVisitor.cs
  7. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/FindExtensions.cs
  8. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookEventRepository.cs
  9. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookRepository.cs
  10. 4
      src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookRepository_EventHandling.cs
  11. 58
      src/Squidex.Domain.Apps.Read/Apps/Services/Implementations/ConfigAppLimitsProvider.cs
  12. 8
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/QueryContext.cs
  13. 1
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/AssetGraphType.cs
  14. 2
      src/Squidex.Domain.Apps.Read/Contents/IContentEntity.cs
  15. 2
      src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs
  16. 3
      src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectFactory.cs
  17. 4
      src/Squidex.Infrastructure/CQRS/Commands/EnrichWithTimestampCommandMiddleware.cs
  18. 2
      src/Squidex.Infrastructure/CQRS/Commands/EntityCreatedResult_T.cs
  19. 2
      src/Squidex.Infrastructure/CQRS/DomainObjectBase.cs
  20. 2
      src/Squidex.Infrastructure/CQRS/Events/Envelope_1.cs
  21. 6
      src/Squidex.Infrastructure/CollectionExtensions.cs
  22. 2
      src/Squidex.Infrastructure/Json/InstantConverter.cs
  23. 2
      src/Squidex.Infrastructure/Json/JsonExtension.cs
  24. 1
      src/Squidex.Infrastructure/Json/TypeNameSerializationBinder.cs
  25. 2
      src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs
  26. 3
      src/Squidex.Infrastructure/UsageTracking/Usage.cs
  27. 2
      src/Squidex/Config/Domain/WriteModule.cs
  28. 3
      src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs
  29. 79
      tests/Squidex.Domain.Apps.Core.Tests/Schemas/GeolocationPropertiesTests.cs
  30. 2
      tests/Squidex.Domain.Apps.Core.Tests/Schemas/StringFieldPropertiesTests.cs
  31. 2
      tests/Squidex.Domain.Apps.Read.Tests/Apps/CachingAppProviderTests.cs
  32. 4
      tests/Squidex.Domain.Apps.Read.Tests/Contents/ContentQueryServiceTests.cs
  33. 10
      tests/Squidex.Domain.Apps.Read.Tests/Contents/GraphQLTests.cs
  34. 4
      tests/Squidex.Domain.Apps.Read.Tests/Contents/ODataQueryTests.cs
  35. 1
      tests/Squidex.Domain.Apps.Read.Tests/Webhooks/WebhookEnqueuerTests.cs
  36. 3
      tests/Squidex.Infrastructure.Tests/Caching/InvalidatingMemoryCacheTests.cs

6
src/Squidex.Domain.Apps.Core/Contents/ContentData.cs

@ -34,8 +34,7 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
} }
protected static TResult Merge<TResult>(TResult source, TResult target) protected static TResult Merge<TResult>(TResult source, TResult target) where TResult : ContentData<T>
where TResult : ContentData<T>
{ {
if (ReferenceEquals(target, source)) if (ReferenceEquals(target, source))
{ {
@ -55,8 +54,7 @@ namespace Squidex.Domain.Apps.Core.Contents
return target; return target;
} }
protected static TResult Clean<TResult>(TResult source, TResult target) protected static TResult Clean<TResult>(TResult source, TResult target) where TResult : ContentData<T>
where TResult : ContentData<T>
{ {
foreach (var fieldValue in source.ValidValues) foreach (var fieldValue in source.ValidValues)
{ {

3
src/Squidex.Domain.Apps.Core/Schemas/CloneableBase.cs

@ -12,8 +12,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
{ {
public abstract class CloneableBase public abstract class CloneableBase
{ {
protected T Clone<T>(Action<T> updater) protected T Clone<T>(Action<T> updater) where T : CloneableBase
where T : CloneableBase
{ {
var clone = (T)MemberwiseClone(); var clone = (T)MemberwiseClone();

3
src/Squidex.Domain.Apps.Core/Schemas/Field_Generic.cs

@ -13,8 +13,7 @@ using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.Schemas namespace Squidex.Domain.Apps.Core.Schemas
{ {
public abstract class Field<T> : Field public abstract class Field<T> : Field where T : FieldProperties
where T : FieldProperties
{ {
private T properties; private T properties;

3
src/Squidex.Domain.Apps.Core/Schemas/Validators/RangeValidator.cs

@ -12,8 +12,7 @@ using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.Schemas.Validators namespace Squidex.Domain.Apps.Core.Schemas.Validators
{ {
public sealed class RangeValidator<T> : IValidator public sealed class RangeValidator<T> : IValidator where T : struct, IComparable<T>
where T : struct, IComparable<T>
{ {
private readonly T? min; private readonly T? min;
private readonly T? max; private readonly T? max;

2
src/Squidex.Domain.Apps.Read.MongoDb/Contents/MongoContentEntity.cs

@ -31,8 +31,8 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents
{ {
public sealed class MongoContentEntity : IContentEntity, IMongoEntity public sealed class MongoContentEntity : IContentEntity, IMongoEntity
{ {
private static readonly JsonWriterSettings Settings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict };
private const int MaxLength = 1024 * 1024; private const int MaxLength = 1024 * 1024;
private static readonly JsonWriterSettings Settings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict };
private NamedContentData contentData; private NamedContentData contentData;
[BsonId] [BsonId]

8
src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/FilterVisitor.cs

@ -62,12 +62,14 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
return Filter.Regex(BuildFieldDefinition(fieldNode), value); return Filter.Regex(BuildFieldDefinition(fieldNode), value);
} }
if (string.Equals(nodeIn.Name, "startswith", StringComparison.OrdinalIgnoreCase)) if (string.Equals(nodeIn.Name, "startswith", StringComparison.OrdinalIgnoreCase))
{ {
var value = BuildRegex(valueNode, v => "^" + v); var value = BuildRegex(valueNode, v => "^" + v);
return Filter.Regex(BuildFieldDefinition(fieldNode), value); return Filter.Regex(BuildFieldDefinition(fieldNode), value);
} }
if (string.Equals(nodeIn.Name, "contains", StringComparison.OrdinalIgnoreCase)) if (string.Equals(nodeIn.Name, "contains", StringComparison.OrdinalIgnoreCase))
{ {
var value = BuildRegex(valueNode, v => v); var value = BuildRegex(valueNode, v => v);
@ -84,6 +86,7 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
{ {
return Filter.And(nodeIn.Left.Accept(this), nodeIn.Right.Accept(this)); return Filter.And(nodeIn.Left.Accept(this), nodeIn.Right.Accept(this));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.Or) if (nodeIn.OperatorKind == BinaryOperatorKind.Or)
{ {
return Filter.Or(nodeIn.Left.Accept(this), nodeIn.Right.Accept(this)); return Filter.Or(nodeIn.Left.Accept(this), nodeIn.Right.Accept(this));
@ -116,22 +119,27 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
Filter.Not(Filter.Exists(field)), Filter.Not(Filter.Exists(field)),
Filter.Ne(field, BuildValue(nodeIn.Right))); Filter.Ne(field, BuildValue(nodeIn.Right)));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.Equal) if (nodeIn.OperatorKind == BinaryOperatorKind.Equal)
{ {
return Filter.Eq(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right)); return Filter.Eq(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.LessThan) if (nodeIn.OperatorKind == BinaryOperatorKind.LessThan)
{ {
return Filter.Lt(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right)); return Filter.Lt(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.LessThanOrEqual) if (nodeIn.OperatorKind == BinaryOperatorKind.LessThanOrEqual)
{ {
return Filter.Lte(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right)); return Filter.Lte(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.GreaterThan) if (nodeIn.OperatorKind == BinaryOperatorKind.GreaterThan)
{ {
return Filter.Gt(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right)); return Filter.Gt(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right));
} }
if (nodeIn.OperatorKind == BinaryOperatorKind.GreaterThanOrEqual) if (nodeIn.OperatorKind == BinaryOperatorKind.GreaterThanOrEqual)
{ {
return Filter.Gte(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right)); return Filter.Gte(BuildFieldDefinition(nodeIn.Left), BuildValue(nodeIn.Right));

2
src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/FindExtensions.cs

@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
{ {
private static readonly FilterDefinitionBuilder<MongoContentEntity> Filter = Builders<MongoContentEntity>.Filter; private static readonly FilterDefinitionBuilder<MongoContentEntity> Filter = Builders<MongoContentEntity>.Filter;
public static IFindFluent<MongoContentEntity, MongoContentEntity> Sort(this IFindFluent<MongoContentEntity, MongoContentEntity> cursor, ODataUriParser query, Schema schema) public static IFindFluent<MongoContentEntity, MongoContentEntity> Sort(this IFindFluent<MongoContentEntity, MongoContentEntity> cursor, ODataUriParser query, Schema schema)
{ {
return cursor.Sort(SortBuilder.BuildSort(query, schema)); return cursor.Sort(SortBuilder.BuildSort(query, schema));
} }

2
src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookEventRepository.cs

@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Webhooks
await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.Expires), new CreateIndexOptions { ExpireAfter = TimeSpan.Zero }); await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.Expires), new CreateIndexOptions { ExpireAfter = TimeSpan.Zero });
} }
public Task QueryPendingAsync(Func<IWebhookEventEntity, Task> callback, CancellationToken cancellationToken = new CancellationToken()) public Task QueryPendingAsync(Func<IWebhookEventEntity, Task> callback, CancellationToken cancellationToken = default(CancellationToken))
{ {
var now = clock.GetCurrentInstant(); var now = clock.GetCurrentInstant();

2
src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookRepository.cs

@ -25,8 +25,8 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Webhooks
public partial class MongoWebhookRepository : MongoRepositoryBase<MongoWebhookEntity>, IWebhookRepository, IEventConsumer public partial class MongoWebhookRepository : MongoRepositoryBase<MongoWebhookEntity>, IWebhookRepository, IEventConsumer
{ {
private static readonly List<IWebhookEntity> EmptyWebhooks = new List<IWebhookEntity>(); private static readonly List<IWebhookEntity> EmptyWebhooks = new List<IWebhookEntity>();
private Dictionary<Guid, List<IWebhookEntity>> inMemoryWebhooks;
private readonly SemaphoreSlim lockObject = new SemaphoreSlim(1); private readonly SemaphoreSlim lockObject = new SemaphoreSlim(1);
private Dictionary<Guid, List<IWebhookEntity>> inMemoryWebhooks;
public MongoWebhookRepository(IMongoDatabase database) public MongoWebhookRepository(IMongoDatabase database)
: base(database) : base(database)

4
src/Squidex.Domain.Apps.Read.MongoDb/Webhooks/MongoWebhookRepository_EventHandling.cs

@ -10,12 +10,12 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Domain.Apps.Events.Schemas; using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Domain.Apps.Events.Webhooks;
using Squidex.Domain.Apps.Read.MongoDb.Utils;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Events; using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.Dispatching; using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Domain.Apps.Events.Webhooks;
using Squidex.Domain.Apps.Read.MongoDb.Utils;
namespace Squidex.Domain.Apps.Read.MongoDb.Webhooks namespace Squidex.Domain.Apps.Read.MongoDb.Webhooks
{ {

58
src/Squidex.Domain.Apps.Read/Apps/Services/Implementations/ConfigAppLimitsProvider.cs

@ -1,58 +0,0 @@
// ==========================================================================
// ConfigAppLimitsProvider.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Read.Apps.Services.Implementations
{
public sealed class ConfigAppPlansProvider : IAppPlansProvider
{
private static readonly ConfigAppLimitsPlan Infinite = new ConfigAppLimitsPlan
{
Id = "infinite",
Name = "Infinite",
MaxApiCalls = -1,
MaxAssetSize = -1,
MaxContributors = -1
};
private readonly Dictionary<string, ConfigAppLimitsPlan> config;
public ConfigAppPlansProvider(IEnumerable<ConfigAppLimitsPlan> config)
{
Guard.NotNull(config, nameof(config));
this.config = config.Select(c => c.Clone()).OrderBy(x => x.MaxApiCalls).ToDictionary(c => c.Id, StringComparer.OrdinalIgnoreCase);
}
public IEnumerable<IAppLimitsPlan> GetAvailablePlans()
{
return config.Values;
}
public IAppLimitsPlan GetPlanForApp(IAppEntity app)
{
Guard.NotNull(app, nameof(app));
return GetPlan(app.PlanId);
}
public IAppLimitsPlan GetPlan(string planId)
{
return config.GetOrDefault(planId ?? string.Empty) ?? config.Values.FirstOrDefault() ?? Infinite;
}
public bool IsConfiguredPlan(string planId)
{
return planId != null && config.ContainsKey(planId);
}
}
}

8
src/Squidex.Domain.Apps.Read/Contents/GraphQL/QueryContext.cs

@ -7,16 +7,16 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Squidex.Infrastructure;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Squidex.Domain.Apps.Read.Apps; using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Assets; using Squidex.Domain.Apps.Read.Assets;
using Squidex.Domain.Apps.Read.Assets.Repositories; using Squidex.Domain.Apps.Read.Assets.Repositories;
using Squidex.Infrastructure;
// ReSharper disable InvertIf // ReSharper disable InvertIf
@ -145,7 +145,7 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL
public Task<IReadOnlyList<IContentEntity>> GetReferencedContentsAsync(Guid schemaId, JToken value) public Task<IReadOnlyList<IContentEntity>> GetReferencedContentsAsync(Guid schemaId, JToken value)
{ {
var ids = ParseIds(value); var ids = ParseIds(value);
return GetReferencedContentsAsync(schemaId, ids); return GetReferencedContentsAsync(schemaId, ids);
} }

1
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/AssetGraphType.cs

@ -150,7 +150,6 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
if (context.CanGenerateAssetSourceUrl) if (context.CanGenerateAssetSourceUrl)
{ {
AddField(new FieldType AddField(new FieldType
{ {
Name = "sourceUrl", Name = "sourceUrl",

2
src/Squidex.Domain.Apps.Read/Contents/IContentEntity.cs

@ -14,6 +14,6 @@ namespace Squidex.Domain.Apps.Read.Contents
{ {
bool IsPublished { get; } bool IsPublished { get; }
NamedContentData Data { get;} NamedContentData Data { get; }
} }
} }

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

@ -26,8 +26,8 @@ namespace Squidex.Infrastructure.MongoDb
protected static readonly IndexKeysDefinitionBuilder<TEntity> Index = Builders<TEntity>.IndexKeys; protected static readonly IndexKeysDefinitionBuilder<TEntity> Index = Builders<TEntity>.IndexKeys;
protected static readonly ProjectionDefinitionBuilder<TEntity> Project = Builders<TEntity>.Projection; protected static readonly ProjectionDefinitionBuilder<TEntity> Project = Builders<TEntity>.Projection;
private Lazy<IMongoCollection<TEntity>> mongoCollection;
private readonly IMongoDatabase mongoDatabase; private readonly IMongoDatabase mongoDatabase;
private Lazy<IMongoCollection<TEntity>> mongoCollection;
protected IMongoCollection<TEntity> Collection protected IMongoCollection<TEntity> Collection
{ {

3
src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectFactory.cs

@ -10,7 +10,8 @@ using System;
namespace Squidex.Infrastructure.CQRS.Commands namespace Squidex.Infrastructure.CQRS.Commands
{ {
public delegate T DomainObjectFactoryFunction<out T>(Guid id) where T : IAggregate; public delegate T DomainObjectFactoryFunction<out T>(Guid id)
where T : IAggregate;
public class DefaultDomainObjectFactory : IDomainObjectFactory public class DefaultDomainObjectFactory : IDomainObjectFactory
{ {

4
src/Squidex.Infrastructure/CQRS/Commands/EnrichWithTimestampCommandMiddleware.cs

@ -12,11 +12,11 @@ using NodaTime;
namespace Squidex.Infrastructure.CQRS.Commands namespace Squidex.Infrastructure.CQRS.Commands
{ {
public sealed class EnrichWithTimestampHandler : ICommandMiddleware public sealed class EnrichWithTimestampCommandMiddleware : ICommandMiddleware
{ {
private readonly IClock clock; private readonly IClock clock;
public EnrichWithTimestampHandler(IClock clock) public EnrichWithTimestampCommandMiddleware(IClock clock)
{ {
Guard.NotNull(clock, nameof(clock)); Guard.NotNull(clock, nameof(clock));

2
src/Squidex.Infrastructure/CQRS/Commands/EntityCreatedResult_T.cs

@ -6,6 +6,8 @@
// All rights reserved. // All rights reserved.
// ========================================================================== // ==========================================================================
#pragma warning disable SA1649 // File name must match first type name
namespace Squidex.Infrastructure.CQRS.Commands namespace Squidex.Infrastructure.CQRS.Commands
{ {
public sealed class EntityCreatedResult<T> : EntitySavedResult public sealed class EntityCreatedResult<T> : EntitySavedResult

2
src/Squidex.Infrastructure/CQRS/DomainObjectBase.cs

@ -10,7 +10,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Squidex.Infrastructure.CQRS.Events; using Squidex.Infrastructure.CQRS.Events;
// ReSharper disable ImpureMethodCallOnReadonlyValueField #pragma warning disable SA1107 // Code must not contain multiple statements on one line
namespace Squidex.Infrastructure.CQRS namespace Squidex.Infrastructure.CQRS
{ {

2
src/Squidex.Infrastructure/CQRS/Events/Envelope_1.cs

@ -6,6 +6,8 @@
// All rights reserved. // All rights reserved.
// ========================================================================== // ==========================================================================
#pragma warning disable SA1649 // File name must match first type name
namespace Squidex.Infrastructure.CQRS.Events namespace Squidex.Infrastructure.CQRS.Events
{ {
public class Envelope<TPayload> where TPayload : class public class Envelope<TPayload> where TPayload : class

6
src/Squidex.Infrastructure/CollectionExtensions.cs

@ -102,14 +102,12 @@ namespace Squidex.Infrastructure
return dictionary.GetOrAdd(key, _ => default(TValue)); return dictionary.GetOrAdd(key, _ => default(TValue));
} }
public static TValue GetOrNew<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) public static TValue GetOrNew<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) where TValue : class, new()
where TValue : class, new()
{ {
return dictionary.GetOrCreate(key, _ => new TValue()); return dictionary.GetOrCreate(key, _ => new TValue());
} }
public static TValue GetOrAddNew<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) public static TValue GetOrAddNew<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) where TValue : class, new()
where TValue : class, new()
{ {
return dictionary.GetOrAdd(key, _ => new TValue()); return dictionary.GetOrAdd(key, _ => new TValue());
} }

2
src/Squidex.Infrastructure/Json/InstantConverter.cs

@ -35,10 +35,12 @@ namespace Squidex.Infrastructure.Json
{ {
return InstantPattern.General.Parse(reader.Value.ToString()).Value; return InstantPattern.General.Parse(reader.Value.ToString()).Value;
} }
if (reader.TokenType == JsonToken.Date) if (reader.TokenType == JsonToken.Date)
{ {
return Instant.FromDateTimeUtc((DateTime)reader.Value); return Instant.FromDateTimeUtc((DateTime)reader.Value);
} }
if (reader.TokenType == JsonToken.Null && objectType == typeof(Instant?)) if (reader.TokenType == JsonToken.Null && objectType == typeof(Instant?))
{ {
return null; return null;

2
src/Squidex.Infrastructure/Json/JsonExtension.cs

@ -18,10 +18,12 @@ namespace Squidex.Infrastructure.Json
{ {
return true; return true;
} }
if (token.Type == JTokenType.Null) if (token.Type == JTokenType.Null)
{ {
return true; return true;
} }
if (token is JValue value) if (token is JValue value)
{ {
return value.Value == null; return value.Value == null;

1
src/Squidex.Infrastructure/Json/TypeNameSerializationBinder.cs

@ -46,4 +46,3 @@ namespace Squidex.Infrastructure.Json
} }
} }
} }

2
src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs

@ -15,8 +15,8 @@ namespace Squidex.Infrastructure.Log.Internal
{ {
public class ConsoleLogProcessor : DisposableObjectBase public class ConsoleLogProcessor : DisposableObjectBase
{ {
private readonly IConsole console;
private const int MaxQueuedMessages = 1024; private const int MaxQueuedMessages = 1024;
private readonly IConsole console;
private readonly BlockingCollection<LogMessageEntry> messageQueue = new BlockingCollection<LogMessageEntry>(MaxQueuedMessages); private readonly BlockingCollection<LogMessageEntry> messageQueue = new BlockingCollection<LogMessageEntry>(MaxQueuedMessages);
private readonly Task outputTask; private readonly Task outputTask;

3
src/Squidex.Infrastructure/UsageTracking/Usage.cs

@ -5,6 +5,9 @@
// Copyright (c) Squidex Group // Copyright (c) Squidex Group
// All rights reserved. // All rights reserved.
// ========================================================================== // ==========================================================================
#pragma warning disable SA1401 // Fields must be private
namespace Squidex.Infrastructure.UsageTracking namespace Squidex.Infrastructure.UsageTracking
{ {
public sealed class Usage public sealed class Usage

2
src/Squidex/Config/Domain/WriteModule.cs

@ -37,7 +37,7 @@ namespace Squidex.Config.Domain
.As<ICommandMiddleware>() .As<ICommandMiddleware>()
.SingleInstance(); .SingleInstance();
builder.RegisterType<EnrichWithTimestampHandler>() builder.RegisterType<EnrichWithTimestampCommandMiddleware>()
.As<ICommandMiddleware>() .As<ICommandMiddleware>()
.SingleInstance(); .SingleInstance();

3
src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs

@ -22,8 +22,7 @@ namespace Squidex.Pipeline
{ {
private static readonly List<Func<Exception, IActionResult>> Handlers = new List<Func<Exception, IActionResult>>(); private static readonly List<Func<Exception, IActionResult>> Handlers = new List<Func<Exception, IActionResult>>();
private static void AddHandler<T>(Func<T, IActionResult> handler) private static void AddHandler<T>(Func<T, IActionResult> handler) where T : Exception
where T : Exception
{ {
Handlers.Add(ex => ex is T typed ? handler(typed) : null); Handlers.Add(ex => ex is T typed ? handler(typed) : null);
} }

79
tests/Squidex.Domain.Apps.Core.Tests/Schemas/GeolocationPropertiesTests.cs

@ -1,79 +0,0 @@
// ==========================================================================
// GeolocationPropertiesTests.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentAssertions;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Domain.Apps.Core.Schemas
{
public class GeolocationFieldPropertiesTests
{
private readonly List<ValidationError> errors = new List<ValidationError>();
[Fact]
public void Should_add_error_if_editor_is_not_valid()
{
var sut = new GeolocationFieldProperties { Editor = (GeolocationFieldEditor)123 };
sut.Validate(errors);
errors.ShouldBeEquivalentTo(
new List<ValidationError>
{
new ValidationError("Editor is not a valid value", "Editor")
});
}
[Fact]
public void Should_set_or_freeze_sut()
{
var sut = new GeolocationFieldProperties();
foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen"))
{
var value =
property.PropertyType.GetTypeInfo().IsValueType ?
Activator.CreateInstance(property.PropertyType) :
null;
property.SetValue(sut, value);
var result = property.GetValue(sut);
Assert.Equal(value, result);
}
sut.Freeze();
foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen"))
{
var value =
property.PropertyType.GetTypeInfo().IsValueType ?
Activator.CreateInstance(property.PropertyType) :
null;
Assert.Throws<InvalidOperationException>(() =>
{
try
{
property.SetValue(sut, value);
}
catch (Exception ex)
{
throw ex.InnerException;
}
});
}
}
}
}

2
tests/Squidex.Domain.Apps.Core.Tests/Schemas/StringFieldPropertiesTests.cs

@ -94,7 +94,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
[Fact] [Fact]
public void Should_add_error_if_pattern_is_not_valid_regex() public void Should_add_error_if_pattern_is_not_valid_regex()
{ {
var sut = new StringFieldProperties { Pattern = "[0-9{1}"}; var sut = new StringFieldProperties { Pattern = "[0-9{1}" };
sut.Validate(errors); sut.Validate(errors);

2
tests/Squidex.Domain.Apps.Read.Tests/Apps/CachingAppProviderTests.cs

@ -97,7 +97,7 @@ namespace Squidex.Domain.Apps.Read.Apps
await ProvideAppByIdAsync(appV1); await ProvideAppByIdAsync(appV1);
sut.On(Envelope.Create(new AppLanguageAdded {AppId = appId }).To<IEvent>()).Wait(); sut.On(Envelope.Create(new AppLanguageAdded { AppId = appId }).To<IEvent>()).Wait();
await ProvideAppByIdAsync(appV2); await ProvideAppByIdAsync(appV2);

4
tests/Squidex.Domain.Apps.Read.Tests/Contents/ContentQueryServiceTests.cs

@ -7,9 +7,11 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Collections.Generic;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Microsoft.OData.UriParser;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Core.Scripting; using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Read.Apps; using Squidex.Domain.Apps.Read.Apps;
@ -19,8 +21,6 @@ using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Domain.Apps.Read.Schemas.Services; using Squidex.Domain.Apps.Read.Schemas.Services;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Xunit; using Xunit;
using System.Collections.Generic;
using Microsoft.OData.UriParser;
namespace Squidex.Domain.Apps.Read.Contents namespace Squidex.Domain.Apps.Read.Contents
{ {

10
tests/Squidex.Domain.Apps.Read.Tests/Contents/GraphQLTests.cs

@ -15,21 +15,21 @@ using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NodaTime.Extensions;
using Squidex.Domain.Apps.Core; using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Read.Apps; using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Assets;
using Squidex.Domain.Apps.Read.Assets.Repositories; using Squidex.Domain.Apps.Read.Assets.Repositories;
using Squidex.Domain.Apps.Read.Contents.GraphQL; using Squidex.Domain.Apps.Read.Contents.GraphQL;
using Squidex.Domain.Apps.Read.Contents.TestData; using Squidex.Domain.Apps.Read.Contents.TestData;
using Squidex.Domain.Apps.Read.Schemas; using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Domain.Apps.Read.Schemas.Repositories; using Squidex.Domain.Apps.Read.Schemas.Repositories;
using Xunit;
using NodaTime.Extensions;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Read.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Xunit;
// ReSharper disable SimilarAnonymousTypeNearby #pragma warning disable SA1311 // Static readonly fields must begin with upper-case letter
namespace Squidex.Domain.Apps.Read.Contents namespace Squidex.Domain.Apps.Read.Contents
{ {

4
tests/Squidex.Domain.Apps.Read.Tests/Contents/ODataQueryTests.cs

@ -326,7 +326,7 @@ namespace Squidex.Domain.Apps.Read.Contents
[Fact] [Fact]
public void Should_set_default_top() public void Should_set_default_top()
{ {
var parser = edmModel.ParseQuery(""); var parser = edmModel.ParseQuery(string.Empty);
var cursor = A.Fake<IFindFluent<MongoContentEntity, MongoContentEntity>>(); var cursor = A.Fake<IFindFluent<MongoContentEntity, MongoContentEntity>>();
cursor.Take(parser); cursor.Take(parser);
@ -348,7 +348,7 @@ namespace Squidex.Domain.Apps.Read.Contents
[Fact] [Fact]
public void Should_not_set_skip() public void Should_not_set_skip()
{ {
var parser = edmModel.ParseQuery(""); var parser = edmModel.ParseQuery(string.Empty);
var cursor = A.Fake<IFindFluent<MongoContentEntity, MongoContentEntity>>(); var cursor = A.Fake<IFindFluent<MongoContentEntity, MongoContentEntity>>();
cursor.Take(parser); cursor.Take(parser);

1
tests/Squidex.Domain.Apps.Read.Tests/Webhooks/WebhookEnqueuerTests.cs

@ -70,7 +70,6 @@ namespace Squidex.Domain.Apps.Read.Webhooks
[Fact] [Fact]
public async Task Should_update_repositories_on_successful_requests() public async Task Should_update_repositories_on_successful_requests()
{ {
var @event = Envelope.Create(new ContentCreated { AppId = appId, SchemaId = schemaId }); var @event = Envelope.Create(new ContentCreated { AppId = appId, SchemaId = schemaId });
var webhook1 = CreateWebhook(1); var webhook1 = CreateWebhook(1);

3
tests/Squidex.Infrastructure.Tests/Caching/InvalidatingMemoryCacheTests.cs

@ -18,8 +18,7 @@ namespace Squidex.Infrastructure.Caching
{ {
public class InvalidatingMemoryCacheTests public class InvalidatingMemoryCacheTests
{ {
internal sealed class MyOptions<T> : IOptions<T> internal sealed class MyOptions<T> : IOptions<T> where T : class, new()
where T : class, new()
{ {
public MyOptions(T value) public MyOptions(T value)
{ {

Loading…
Cancel
Save