mirror of https://github.com/Squidex/squidex.git
17 changed files with 74 additions and 113 deletions
@ -0,0 +1,17 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Threading.Tasks; |
||||
|
using Orleans; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Entities |
||||
|
{ |
||||
|
public interface ICleanableAppGrain : IGrainWithGuidKey |
||||
|
{ |
||||
|
Task ClearAsync(); |
||||
|
} |
||||
|
} |
||||
@ -1,31 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// 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(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// 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