mirror of https://github.com/Squidex/squidex.git
16 changed files with 207 additions and 17 deletions
@ -0,0 +1,31 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Orleans; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Entities.Rules.Indexes |
||||
|
{ |
||||
|
public sealed class RuleIndexCleaner : IAppStorage |
||||
|
{ |
||||
|
private readonly IGrainFactory grainFactory; |
||||
|
|
||||
|
public RuleIndexCleaner(IGrainFactory grainFactory) |
||||
|
{ |
||||
|
Guard.NotNull(grainFactory, nameof(grainFactory)); |
||||
|
|
||||
|
this.grainFactory = grainFactory; |
||||
|
} |
||||
|
|
||||
|
public Task ClearAsync(Guid appId) |
||||
|
{ |
||||
|
return grainFactory.GetGrain<IRulesByAppIndex>(appId).ClearAsync(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Orleans; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Entities.Schemas.Indexes |
||||
|
{ |
||||
|
public sealed class SchemaIndexCleaner : IAppStorage |
||||
|
{ |
||||
|
private readonly IGrainFactory grainFactory; |
||||
|
|
||||
|
public SchemaIndexCleaner(IGrainFactory grainFactory) |
||||
|
{ |
||||
|
Guard.NotNull(grainFactory, nameof(grainFactory)); |
||||
|
|
||||
|
this.grainFactory = grainFactory; |
||||
|
} |
||||
|
|
||||
|
public Task ClearAsync(Guid appId) |
||||
|
{ |
||||
|
return grainFactory.GetGrain<ISchemasByAppIndex>(appId).ClearAsync(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using FakeItEasy; |
||||
|
using Orleans; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Entities.Rules.Indexes |
||||
|
{ |
||||
|
public class RuleIndexCleanerTests |
||||
|
{ |
||||
|
private readonly IGrainFactory grainFactory = A.Fake<IGrainFactory>(); |
||||
|
private readonly IRulesByAppIndex index = A.Fake<IRulesByAppIndex>(); |
||||
|
private readonly Guid appId = Guid.NewGuid(); |
||||
|
private readonly RuleIndexCleaner sut; |
||||
|
|
||||
|
public RuleIndexCleanerTests() |
||||
|
{ |
||||
|
A.CallTo(() => grainFactory.GetGrain<IRulesByAppIndex>(appId, null)) |
||||
|
.Returns(index); |
||||
|
|
||||
|
sut = new RuleIndexCleaner(grainFactory); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Should_forward_to_index() |
||||
|
{ |
||||
|
await sut.ClearAsync(appId); |
||||
|
|
||||
|
A.CallTo(() => index.ClearAsync()) |
||||
|
.MustHaveHappened(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using FakeItEasy; |
||||
|
using Orleans; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Entities.Schemas.Indexes |
||||
|
{ |
||||
|
public class SchemaIndexCleanerTests |
||||
|
{ |
||||
|
private readonly IGrainFactory grainFactory = A.Fake<IGrainFactory>(); |
||||
|
private readonly ISchemasByAppIndex index = A.Fake<ISchemasByAppIndex>(); |
||||
|
private readonly Guid appId = Guid.NewGuid(); |
||||
|
private readonly SchemaIndexCleaner sut; |
||||
|
|
||||
|
public SchemaIndexCleanerTests() |
||||
|
{ |
||||
|
A.CallTo(() => grainFactory.GetGrain<ISchemasByAppIndex>(appId, null)) |
||||
|
.Returns(index); |
||||
|
|
||||
|
sut = new SchemaIndexCleaner(grainFactory); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Should_forward_to_index() |
||||
|
{ |
||||
|
await sut.ClearAsync(appId); |
||||
|
|
||||
|
A.CallTo(() => index.ClearAsync()) |
||||
|
.MustHaveHappened(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue