Browse Source

Compiler errors fixed.

pull/204/head
Sebastian Stehle 8 years ago
parent
commit
da6198dd92
  1. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Assets/MongoAssetRepository_EventHandling.cs
  2. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Assets/MongoAssetStatsRepository_EventHandling.cs
  3. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/MongoContentRepository_EventHandling.cs
  4. 2
      src/Squidex.Domain.Apps.Read/Apps/AppHistoryEventsCreator.cs
  5. 14
      src/Squidex.Domain.Apps.Read/State/AppProvider.cs
  6. 6
      src/Squidex.Domain.Apps.Read/State/AppStateEventConsumer.cs
  7. 14
      src/Squidex.Domain.Apps.Read/State/Grains/AppStateGrain.cs
  8. 2
      src/Squidex.Domain.Apps.Read/State/Grains/AppStateGrainState.cs
  9. 5
      src/Squidex.Domain.Apps.Read/State/Grains/AppUserGrain.cs
  10. 4
      src/Squidex.Domain.Apps.Write/Apps/AppDomainObject.cs
  11. 4
      src/Squidex.Domain.Apps.Write/Assets/AssetDomainObject.cs
  12. 4
      src/Squidex.Domain.Apps.Write/Contents/ContentDomainObject.cs
  13. 5
      src/Squidex.Domain.Apps.Write/Contents/ContentVersionLoader.cs
  14. 4
      src/Squidex.Domain.Apps.Write/Rules/RuleDomainObject.cs
  15. 4
      src/Squidex.Domain.Apps.Write/Schemas/SchemaDomainObject.cs
  16. 3
      src/Squidex.Infrastructure.GetEventStore/EventSourcing/Events/GetEventStore.cs
  17. 2
      src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs
  18. 2
      src/Squidex.Infrastructure/EventSourcing/IEventStore.cs
  19. 8
      src/Squidex.Infrastructure/States/StateFactory.cs
  20. 9
      tests/Benchmarks/Services.cs
  21. 6
      tests/Benchmarks/Tests/HandleEvents.cs
  22. 6
      tests/Benchmarks/Tests/HandleEventsWithManyWriters.cs
  23. 2
      tests/Benchmarks/Tests/ReadSchemaState.cs
  24. 25
      tests/Benchmarks/Tests/TestData/MyAppState.cs
  25. 2
      tests/Squidex.Domain.Apps.Write.Tests/Apps/AppDomainObjectTests.cs
  26. 2
      tests/Squidex.Domain.Apps.Write.Tests/Assets/AssetDomainObjectTests.cs
  27. 2
      tests/Squidex.Domain.Apps.Write.Tests/Contents/ContentDomainObjectTests.cs
  28. 15
      tests/Squidex.Domain.Apps.Write.Tests/Contents/ContentVersionLoaderTests.cs
  29. 2
      tests/Squidex.Domain.Apps.Write.Tests/Rules/RuleDomainObjectTests.cs
  30. 2
      tests/Squidex.Domain.Apps.Write.Tests/Schemas/SchemaDomainObjectTests.cs
  31. 1
      tests/Squidex.Domain.Apps.Write.Tests/TestHelpers/HandlerTestBase.cs
  32. 2
      tests/Squidex.Infrastructure.Tests/States/StateSnapshotTests.cs

2
src/Squidex.Domain.Apps.Read.MongoDb/Assets/MongoAssetRepository_EventHandling.cs

@ -9,8 +9,8 @@
using System.Threading.Tasks;
using MongoDB.Driver;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Read.MongoDb.Assets

2
src/Squidex.Domain.Apps.Read.MongoDb/Assets/MongoAssetStatsRepository_EventHandling.cs

@ -10,8 +10,8 @@ using System;
using System.Threading.Tasks;
using MongoDB.Driver;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
namespace Squidex.Domain.Apps.Read.MongoDb.Assets
{

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

@ -13,8 +13,8 @@ using Squidex.Domain.Apps.Core.ConvertContent;
using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Read.MongoDb.Contents

2
src/Squidex.Domain.Apps.Read/Apps/AppHistoryEventsCreator.cs

@ -10,8 +10,8 @@ using System.Threading.Tasks;
using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Read.History;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
namespace Squidex.Domain.Apps.Read.Apps
{

14
src/Squidex.Domain.Apps.Read/State/AppProvider.cs

@ -32,49 +32,49 @@ namespace Squidex.Domain.Apps.Read.State
public async Task<IAppEntity> GetAppAsync(string appName)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetAppAsync();
}
public async Task<(IAppEntity, ISchemaEntity)> GetAppWithSchemaAsync(string appName, Guid id)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetAppWithSchemaAsync(id);
}
public async Task<List<IRuleEntity>> GetRulesAsync(string appName)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetRulesAsync();
}
public async Task<ISchemaEntity> GetSchemaAsync(string appName, Guid id, bool provideDeleted = false)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetSchemaAsync(id, provideDeleted);
}
public async Task<ISchemaEntity> GetSchemaAsync(string appName, string name, bool provideDeleted = false)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetSchemaAsync(name, provideDeleted);
}
public async Task<List<ISchemaEntity>> GetSchemasAsync(string appName)
{
var app = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appName);
var app = await factory.GetSynchronizedAsync<AppStateGrain>(appName);
return await app.GetSchemasAsync();
}
public async Task<List<IAppEntity>> GetUserApps(string userId)
{
var appUser = await factory.GetAsync<AppUserGrain, AppUserGrainState>(userId);
var appUser = await factory.GetSynchronizedAsync<AppUserGrain>(userId);
var appNames = await appUser.GetAppNamesAsync();
var tasks = appNames.Select(x => GetAppAsync(x));

6
src/Squidex.Domain.Apps.Read/State/AppStateEventConsumer.cs

@ -47,21 +47,21 @@ namespace Squidex.Domain.Apps.Read.State
{
if (@event.Payload is AppEvent appEvent)
{
var appGrain = await factory.GetAsync<AppStateGrain, AppStateGrainState>(appEvent.AppId.Name);
var appGrain = await factory.GetSynchronizedAsync<AppStateGrain>(appEvent.AppId.Name);
await appGrain.HandleAsync(@event);
}
if (@event.Payload is AppContributorAssigned contributorAssigned)
{
var userGrain = await factory.GetAsync<AppUserGrain, AppUserGrainState>(contributorAssigned.ContributorId);
var userGrain = await factory.GetSynchronizedAsync<AppUserGrain>(contributorAssigned.ContributorId);
await userGrain.AddAppAsync(contributorAssigned.AppId.Name);
}
if (@event.Payload is AppContributorRemoved contributorRemoved)
{
var userGrain = await factory.GetAsync<AppUserGrain, AppUserGrainState>(contributorRemoved.ContributorId);
var userGrain = await factory.GetSynchronizedAsync<AppUserGrain>(contributorRemoved.ContributorId);
await userGrain.RemoveAppAsync(contributorRemoved.AppId.Name);
}

14
src/Squidex.Domain.Apps.Read/State/Grains/AppStateGrain.cs

@ -25,7 +25,6 @@ namespace Squidex.Domain.Apps.Read.State.Grains
{
private readonly FieldRegistry fieldRegistry;
private IPersistence<AppStateGrainState> persistence;
private Task readTask;
private Exception exception;
private AppStateGrainState state;
@ -36,15 +35,10 @@ namespace Squidex.Domain.Apps.Read.State.Grains
this.fieldRegistry = fieldRegistry;
}
public Task ActivateAsync(string key, IStore store)
public async Task ActivateAsync(string key, IStore store)
{
persistence = store.WithSnapshots<AppStateGrain, AppStateGrainState>(key, s => state = s);
return readTask ?? (readTask = ReadInitialAsync());
}
private async Task ReadInitialAsync()
{
try
{
await persistence.ReadAsync();
@ -121,15 +115,15 @@ namespace Squidex.Domain.Apps.Read.State.Grains
{
state = state.Apply(message);
await persistence.WriteSnapShotAsync(state);
await persistence.WriteSnapshotAsync(state);
}
catch (InconsistentStateException)
{
await persistence.ReadAsync(true);
await persistence.ReadAsync();
state = state.Apply(message);
await persistence.WriteSnapShotAsync(state);
await persistence.WriteSnapshotAsync(state);
}
}
}

2
src/Squidex.Domain.Apps.Read/State/Grains/AppStateGrainState.cs

@ -16,8 +16,8 @@ using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Rules;
using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
namespace Squidex.Domain.Apps.Read.State.Grains
{

5
src/Squidex.Domain.Apps.Read/State/Grains/AppUserGrain.cs

@ -17,7 +17,6 @@ namespace Squidex.Domain.Apps.Read.State.Grains
public sealed class AppUserGrain : IStatefulObject
{
private IPersistence<AppUserGrainState> persistence;
private Task readTask;
private AppUserGrainState state;
public Task ActivateAsync(string key, IStore store)
@ -38,14 +37,14 @@ namespace Squidex.Domain.Apps.Read.State.Grains
{
state = state.AddApp(appName);
return persistence.WriteSnapShotAsync(state);
return persistence.WriteSnapshotAsync(state);
}
public Task RemoveAppAsync(string appName)
{
state = state.RemoveApp(appName);
return persistence.WriteSnapShotAsync(state);
return persistence.WriteSnapshotAsync(state);
}
public Task<List<string>> GetAppNamesAsync()

4
src/Squidex.Domain.Apps.Write/Apps/AppDomainObject.cs

@ -13,9 +13,9 @@ using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Events.Apps.Utils;
using Squidex.Domain.Apps.Write.Apps.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Write.Apps

4
src/Squidex.Domain.Apps.Write/Assets/AssetDomainObject.cs

@ -10,9 +10,9 @@ using System;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Domain.Apps.Write.Assets.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Write.Assets

4
src/Squidex.Domain.Apps.Write/Contents/ContentDomainObject.cs

@ -11,9 +11,9 @@ using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Domain.Apps.Write.Contents.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Write.Contents

5
src/Squidex.Domain.Apps.Write/Contents/ContentVersionLoader.cs

@ -13,6 +13,7 @@ using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Write.Contents
{
@ -20,9 +21,9 @@ namespace Squidex.Domain.Apps.Write.Contents
{
private readonly IStreamNameResolver nameResolver;
private readonly IEventStore eventStore;
private readonly EventDataFormatter formatter;
private readonly IEventDataFormatter formatter;
public ContentVersionLoader(IEventStore eventStore, IStreamNameResolver nameResolver, EventDataFormatter formatter)
public ContentVersionLoader(IEventStore eventStore, IStreamNameResolver nameResolver, IEventDataFormatter formatter)
{
Guard.NotNull(formatter, nameof(formatter));
Guard.NotNull(eventStore, nameof(eventStore));

4
src/Squidex.Domain.Apps.Write/Rules/RuleDomainObject.cs

@ -12,9 +12,9 @@ using Squidex.Domain.Apps.Events.Rules;
using Squidex.Domain.Apps.Events.Rules.Utils;
using Squidex.Domain.Apps.Write.Rules.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Write.Rules

4
src/Squidex.Domain.Apps.Write/Schemas/SchemaDomainObject.cs

@ -13,9 +13,9 @@ using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Domain.Apps.Events.Schemas.Utils;
using Squidex.Domain.Apps.Write.Schemas.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Write.Schemas

3
src/Squidex.Infrastructure.GetEventStore/EventSourcing/Events/GetEventStore.cs

@ -12,6 +12,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using EventStore.ClientAPI.Exceptions;
namespace Squidex.Infrastructure.EventSourcing
{
@ -59,7 +60,7 @@ namespace Squidex.Infrastructure.EventSourcing
throw new NotSupportedException();
}
public async Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = -1)
public async Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = 0)
{
var result = new List<StoredEvent>();

2
src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs

@ -61,7 +61,7 @@ namespace Squidex.Infrastructure.EventSourcing
return new PollingSubscription(this, notifier, subscriber, streamFilter, position);
}
public async Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = -1)
public async Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = 0)
{
var commits = await Collection.Find(x => x.EventStreamOffset >= streamPosition).Sort(Sort.Ascending(TimestampField)).ToListAsync();

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

@ -15,7 +15,7 @@ namespace Squidex.Infrastructure.EventSourcing
{
public interface IEventStore
{
Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = -1);
Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = 0);
Task GetEventsAsync(Func<StoredEvent, Task> callback, CancellationToken cancellationToken, string streamFilter = null, string position = null);

8
src/Squidex.Infrastructure/States/StateFactory.cs

@ -26,7 +26,7 @@ namespace Squidex.Infrastructure.States
private readonly IEventStore eventStore;
private readonly IEventDataFormatter eventDataFormatter;
private readonly object lockObject = new object();
private IDisposable pubSubscription;
private IDisposable pubSubSubscription;
public sealed class ObjectHolder<T> where T : IStatefulObject
{
@ -76,7 +76,7 @@ namespace Squidex.Infrastructure.States
public void Connect()
{
pubSubscription = pubSub.Subscribe<InvalidateMessage>(m =>
pubSubSubscription = pubSub.Subscribe<InvalidateMessage>(m =>
{
lock (lockObject)
{
@ -128,9 +128,9 @@ namespace Squidex.Infrastructure.States
protected override void DisposeObject(bool disposing)
{
if (disposing)
if (disposing && pubSubSubscription != null)
{
pubSubscription.Dispose();
pubSubSubscription.Dispose();
}
}
}

9
tests/Benchmarks/Services.cs

@ -37,7 +37,6 @@ namespace Benchmarks
services.AddSingleton(CreateTypeNameRegistry());
services.AddSingleton<EventDataFormatter>();
services.AddSingleton<FieldRegistry>();
services.AddTransient<MyAppState>();
@ -60,12 +59,18 @@ namespace Benchmarks
services.AddSingleton<IEventStore,
MongoEventStore>();
services.AddSingleton<IStateStore,
services.AddSingleton<IEventDataFormatter,
JsonEventDataFormatter>();
services.AddSingleton<ISnapshotStore,
MongoSnapshotStore>();
services.AddSingleton<IStateFactory,
StateFactory>();
services.AddSingleton<IStreamNameResolver,
DefaultStreamNameResolver>();
services.AddSingleton<JsonSerializer>(c =>
JsonSerializer.Create(c.GetRequiredService<JsonSerializerSettings>()));

6
tests/Benchmarks/Tests/HandleEvents.cs

@ -20,8 +20,8 @@ namespace Benchmarks.Tests
private const int NumEvents = 5000;
private IServiceProvider services;
private IEventStore eventStore;
private IEventDataFormatter eventDataFormatter;
private EventConsumerGrain eventConsumerGrain;
private EventDataFormatter eventDataFormatter;
private MyEventConsumer eventConsumer;
public override void RunInitialize()
@ -32,10 +32,10 @@ namespace Benchmarks.Tests
eventStore = services.GetRequiredService<IEventStore>();
eventDataFormatter = services.GetRequiredService<EventDataFormatter>();
eventDataFormatter = services.GetRequiredService<IEventDataFormatter>();
eventConsumerGrain = services.GetRequiredService<EventConsumerGrain>();
eventConsumerGrain.ActivateAsync(services.GetRequiredService<StateHolder<EventConsumerState>>()).Wait();
eventConsumerGrain.ActivateAsync("Test", services.GetRequiredService<IStore>()).Wait();
eventConsumerGrain.Activate(eventConsumer);
}

6
tests/Benchmarks/Tests/HandleEventsWithManyWriters.cs

@ -22,8 +22,8 @@ namespace Benchmarks.Tests
private const int NumStreams = 10;
private IServiceProvider services;
private IEventStore eventStore;
private IEventDataFormatter eventDataFormatter;
private EventConsumerGrain eventConsumerGrain;
private EventDataFormatter eventDataFormatter;
private MyEventConsumer eventConsumer;
public override void RunInitialize()
@ -33,11 +33,11 @@ namespace Benchmarks.Tests
eventConsumer = new MyEventConsumer(NumStreams * NumCommits);
eventStore = services.GetRequiredService<IEventStore>();
eventDataFormatter = services.GetRequiredService<IEventDataFormatter>();
eventDataFormatter = services.GetRequiredService<EventDataFormatter>();
eventConsumerGrain = services.GetRequiredService<EventConsumerGrain>();
eventConsumerGrain.ActivateAsync(services.GetRequiredService<StateHolder<EventConsumerState>>()).Wait();
eventConsumerGrain.ActivateAsync("Test", services.GetRequiredService<IStore>()).Wait();
eventConsumerGrain.Activate(eventConsumer);
}

2
tests/Benchmarks/Tests/ReadSchemaState.cs

@ -31,7 +31,7 @@ namespace Benchmarks.Tests
{
services = Services.Create();
grain = services.GetRequiredService<IStateFactory>().GetAsync<MyAppState, AppStateGrainState>("DEFAULT").Result;
grain = services.GetRequiredService<IStateFactory>().GetSynchronizedAsync<MyAppState>("DEFAULT").Result;
var state = new AppStateGrainState
{

25
tests/Benchmarks/Tests/TestData/MyAppState.cs

@ -6,16 +6,37 @@
// All rights reserved.
// ==========================================================================
using System.Threading.Tasks;
using Squidex.Domain.Apps.Read.State.Grains;
using Squidex.Infrastructure.States;
namespace Benchmarks.Tests.TestData
{
public sealed class MyAppState : StatefulObject<AppStateGrainState>
public sealed class MyAppState : IStatefulObject
{
private IPersistence<AppStateGrainState> persistence;
private AppStateGrainState state;
public Task ActivateAsync(string key, IStore store)
{
persistence = store.WithSnapshots<MyAppState, AppStateGrainState>(key, s => state = s);
return persistence.ReadAsync();
}
public void SetState(AppStateGrainState state)
{
State = state;
this.state = state;
}
public Task WriteStateAsync()
{
return persistence.WriteSnapshotAsync(state);
}
public Task ReadStateAsync()
{
return persistence.ReadAsync();
}
}
}

2
tests/Squidex.Domain.Apps.Write.Tests/Apps/AppDomainObjectTests.cs

@ -14,7 +14,7 @@ using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Write.Apps.Commands;
using Squidex.Domain.Apps.Write.TestHelpers;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
using Xunit;
namespace Squidex.Domain.Apps.Write.Apps

2
tests/Squidex.Domain.Apps.Write.Tests/Assets/AssetDomainObjectTests.cs

@ -13,7 +13,7 @@ using Squidex.Domain.Apps.Write.Assets.Commands;
using Squidex.Domain.Apps.Write.TestHelpers;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
using Xunit;
namespace Squidex.Domain.Apps.Write.Assets

2
tests/Squidex.Domain.Apps.Write.Tests/Contents/ContentDomainObjectTests.cs

@ -13,7 +13,7 @@ using Squidex.Domain.Apps.Events.Contents;
using Squidex.Domain.Apps.Write.Contents.Commands;
using Squidex.Domain.Apps.Write.TestHelpers;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
using Xunit;
namespace Squidex.Domain.Apps.Write.Contents

15
tests/Squidex.Domain.Apps.Write.Tests/Contents/ContentVersionLoaderTests.cs

@ -14,6 +14,7 @@ using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
using Xunit;
namespace Squidex.Domain.Apps.Write.Contents
@ -21,8 +22,8 @@ namespace Squidex.Domain.Apps.Write.Contents
public class ContentVersionLoaderTests
{
private readonly IEventStore eventStore = A.Fake<IEventStore>();
private readonly IEventDataFormatter formatter = A.Fake<IEventDataFormatter>();
private readonly IStreamNameResolver nameResolver = A.Fake<IStreamNameResolver>();
private readonly EventDataFormatter formatter = A.Fake<EventDataFormatter>();
private readonly Guid id = Guid.NewGuid();
private readonly Guid appId = Guid.NewGuid();
private readonly string streamName = Guid.NewGuid().ToString();
@ -30,7 +31,7 @@ namespace Squidex.Domain.Apps.Write.Contents
public ContentVersionLoaderTests()
{
A.CallTo(() => nameResolver.GetStreamName(typeof(ContentDomainObject), id))
A.CallTo(() => nameResolver.GetStreamName(typeof(ContentDomainObject), id.ToString()))
.Returns(streamName);
sut = new ContentVersionLoader(eventStore, nameResolver, formatter);
@ -39,7 +40,7 @@ namespace Squidex.Domain.Apps.Write.Contents
[Fact]
public async Task Should_throw_exception_when_event_store_returns_no_events()
{
A.CallTo(() => eventStore.GetEventsAsync(streamName))
A.CallTo(() => eventStore.GetEventsAsync(streamName, 0))
.Returns(new List<StoredEvent>());
await Assert.ThrowsAsync<DomainObjectNotFoundException>(() => sut.LoadAsync(appId, id, -1));
@ -48,7 +49,7 @@ namespace Squidex.Domain.Apps.Write.Contents
[Fact]
public async Task Should_throw_exception_when_version_not_found()
{
A.CallTo(() => eventStore.GetEventsAsync(streamName))
A.CallTo(() => eventStore.GetEventsAsync(streamName, 0))
.Returns(new List<StoredEvent>());
await Assert.ThrowsAsync<DomainObjectNotFoundException>(() => sut.LoadAsync(appId, id, 3));
@ -66,7 +67,7 @@ namespace Squidex.Domain.Apps.Write.Contents
new StoredEvent("0", 0, eventData1)
};
A.CallTo(() => eventStore.GetEventsAsync(streamName))
A.CallTo(() => eventStore.GetEventsAsync(streamName, 0))
.Returns(events);
A.CallTo(() => formatter.Parse(eventData1, true))
@ -90,7 +91,7 @@ namespace Squidex.Domain.Apps.Write.Contents
new StoredEvent("1", 1, eventData2)
};
A.CallTo(() => eventStore.GetEventsAsync(streamName))
A.CallTo(() => eventStore.GetEventsAsync(streamName, 0))
.Returns(events);
A.CallTo(() => formatter.Parse(eventData1, true))
@ -121,7 +122,7 @@ namespace Squidex.Domain.Apps.Write.Contents
new StoredEvent("2", 2, eventData3)
};
A.CallTo(() => eventStore.GetEventsAsync(streamName))
A.CallTo(() => eventStore.GetEventsAsync(streamName, 0))
.Returns(events);
A.CallTo(() => formatter.Parse(eventData1, true))

2
tests/Squidex.Domain.Apps.Write.Tests/Rules/RuleDomainObjectTests.cs

@ -15,7 +15,7 @@ using Squidex.Domain.Apps.Events.Rules;
using Squidex.Domain.Apps.Write.Rules.Commands;
using Squidex.Domain.Apps.Write.TestHelpers;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
using Xunit;
namespace Squidex.Domain.Apps.Write.Rules

2
tests/Squidex.Domain.Apps.Write.Tests/Schemas/SchemaDomainObjectTests.cs

@ -13,7 +13,7 @@ using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Domain.Apps.Write.Schemas.Commands;
using Squidex.Domain.Apps.Write.TestHelpers;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
using Xunit;
namespace Squidex.Domain.Apps.Write.Schemas

1
tests/Squidex.Domain.Apps.Write.Tests/TestHelpers/HandlerTestBase.cs

@ -10,7 +10,6 @@ using System;
using System.Threading.Tasks;
using Squidex.Domain.Apps.Events;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.Commands;
#pragma warning disable IDE0019 // Use pattern matching

2
tests/Squidex.Infrastructure.Tests/States/StateSnapshotTests.cs

@ -191,7 +191,7 @@ namespace Squidex.Infrastructure.States
.Returns((123, version));
A.CallTo(() => snapshotStore.WriteAsync(key, 123, version, 2))
.Throws(new InconsistentStateException(1, 1));
.Throws(new InconsistentStateException(1, 1, new InvalidOperationException()));
var actualObject = await sut.GetSynchronizedAsync<MyStatefulObject>(key);

Loading…
Cancel
Save