From ecc8c7fc6c35b91b2224f2afa33dca24d4850337 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sat, 15 Jul 2017 10:22:18 +0200 Subject: [PATCH] Minor refactorings. --- .../Squidex.Infrastructure.EventStore.csproj | 15 ---------- Squidex.sln | 28 +++++++++---------- .../Formatter.cs | 2 +- .../GetEventStore.cs | 8 +++--- .../GetEventStoreSubscription.cs | 4 +-- ...quidex.Infrastructure.GetEventStore.csproj | 15 ++++++++++ .../Commands/DefaultDomainObjectRepository.cs | 1 - src/Squidex/Config/Domain/EventStoreModule.cs | 18 ++++++------ src/Squidex/Squidex.csproj | 2 +- src/Squidex/appsettings.json | 8 +++--- .../DefaultDomainObjectRepositoryTests.cs | 7 ++--- .../CQRS/Events/EventReceiverTests.cs | 1 - 12 files changed, 53 insertions(+), 56 deletions(-) delete mode 100644 Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj rename {Squidex.Infrastructure.EventStore => src/Squidex.Infrastructure.GetEventStore}/Formatter.cs (96%) rename Squidex.Infrastructure.EventStore/EventStore.cs => src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs (94%) rename Squidex.Infrastructure.EventStore/EventStoreSubscription.cs => src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs (98%) create mode 100644 src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj diff --git a/Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj b/Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj deleted file mode 100644 index aeb6f3d81..000000000 --- a/Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netcoreapp1.1 - - - - - - - - - - - \ No newline at end of file diff --git a/Squidex.sln b/Squidex.sln index ec63b2ae1..86c2ab6fe 100644 --- a/Squidex.sln +++ b/Squidex.sln @@ -56,7 +56,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.MongoD EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.Tests", "tests\Squidex.Domain.Users.Tests\Squidex.Domain.Users.Tests.csproj", "{42184546-E3CB-4D4F-9495-43979B9C63B9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Infrastructure.EventStore", "Squidex.Infrastructure.EventStore\Squidex.Infrastructure.EventStore.csproj", "{91D9D992-FA34-49EE-A1D7-DEA5E660424F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Infrastructure.GetEventStore", "src\Squidex.Infrastructure.GetEventStore\Squidex.Infrastructure.GetEventStore.csproj", "{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -268,18 +268,18 @@ Global {42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x64.Build.0 = Release|Any CPU {42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.ActiveCfg = Release|Any CPU {42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.Build.0 = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x64.ActiveCfg = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x64.Build.0 = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x86.ActiveCfg = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x86.Build.0 = Debug|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|Any CPU.Build.0 = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x64.ActiveCfg = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x64.Build.0 = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x86.ActiveCfg = Release|Any CPU - {91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x86.Build.0 = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x64.ActiveCfg = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x64.Build.0 = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x86.ActiveCfg = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x86.Build.0 = Debug|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|Any CPU.Build.0 = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x64.ActiveCfg = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x64.Build.0 = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x86.ActiveCfg = Release|Any CPU + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -307,6 +307,6 @@ Global {F7771E22-47BD-45C4-A133-FD7F1DE27CA0} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA} {27CF800D-890F-4882-BF05-44EC3233537D} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA} {42184546-E3CB-4D4F-9495-43979B9C63B9} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA} - {91D9D992-FA34-49EE-A1D7-DEA5E660424F} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF} + {EF75E488-1324-4E18-A1BD-D3A05AE67B1F} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF} EndGlobalSection EndGlobal diff --git a/Squidex.Infrastructure.EventStore/Formatter.cs b/src/Squidex.Infrastructure.GetEventStore/Formatter.cs similarity index 96% rename from Squidex.Infrastructure.EventStore/Formatter.cs rename to src/Squidex.Infrastructure.GetEventStore/Formatter.cs index 79dbcf658..d6551e36e 100644 --- a/Squidex.Infrastructure.EventStore/Formatter.cs +++ b/src/Squidex.Infrastructure.GetEventStore/Formatter.cs @@ -11,7 +11,7 @@ using EventStore.ClientAPI; using EventData = Squidex.Infrastructure.CQRS.Events.EventData; using EventStoreData = EventStore.ClientAPI.EventData; -namespace Squidex.Infrastructure.EventStore +namespace Squidex.Infrastructure.GetEventStore { public static class Formatter { diff --git a/Squidex.Infrastructure.EventStore/EventStore.cs b/src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs similarity index 94% rename from Squidex.Infrastructure.EventStore/EventStore.cs rename to src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs index 3f487e705..e2c99b5c9 100644 --- a/Squidex.Infrastructure.EventStore/EventStore.cs +++ b/src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs @@ -1,5 +1,5 @@ // ========================================================================== -// EventStore.cs +// GetEventStore.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group @@ -17,9 +17,9 @@ using EventData = Squidex.Infrastructure.CQRS.Events.EventData; // ReSharper disable ConvertIfStatementToSwitchStatement // ReSharper disable InvertIf -namespace Squidex.Infrastructure.EventStore +namespace Squidex.Infrastructure.GetEventStore { - public sealed class EventStore : IEventStore, IExternalSystem + public sealed class GetEventStore : IEventStore, IExternalSystem { private const int WritePageSize = 500; private const int ReadPageSize = 500; @@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.EventStore private readonly string projectionHost; private readonly string prefix; - public EventStore(IEventStoreConnection connection, string prefix, string projectionHost) + public GetEventStore(IEventStoreConnection connection, string prefix, string projectionHost) { Guard.NotNull(connection, nameof(connection)); diff --git a/Squidex.Infrastructure.EventStore/EventStoreSubscription.cs b/src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs similarity index 98% rename from Squidex.Infrastructure.EventStore/EventStoreSubscription.cs rename to src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs index 22ed3ec33..d600af1ad 100644 --- a/Squidex.Infrastructure.EventStore/EventStoreSubscription.cs +++ b/src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs @@ -1,5 +1,5 @@ // ========================================================================== -// EventStoreSubscription.cs +// GetEventStoreSubscription.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group @@ -18,7 +18,7 @@ using EventStore.ClientAPI.Exceptions; using EventStore.ClientAPI.Projections; using Squidex.Infrastructure.CQRS.Events; -namespace Squidex.Infrastructure.EventStore +namespace Squidex.Infrastructure.GetEventStore { internal sealed class EventStoreSubscription : IEventSubscription { diff --git a/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj b/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj new file mode 100644 index 000000000..30635bd77 --- /dev/null +++ b/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj @@ -0,0 +1,15 @@ + + + netstandard1.6 + + + full + True + + + + + + + + \ No newline at end of file diff --git a/src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs b/src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs index 857c8586b..9c61be078 100644 --- a/src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs +++ b/src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs @@ -9,7 +9,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reactive.Linq; using System.Threading.Tasks; using Squidex.Infrastructure.CQRS.Events; diff --git a/src/Squidex/Config/Domain/EventStoreModule.cs b/src/Squidex/Config/Domain/EventStoreModule.cs index eb1492625..4ca8f8f19 100644 --- a/src/Squidex/Config/Domain/EventStoreModule.cs +++ b/src/Squidex/Config/Domain/EventStoreModule.cs @@ -14,8 +14,8 @@ using Microsoft.Extensions.Configuration; using MongoDB.Driver; using Squidex.Infrastructure; using Squidex.Infrastructure.CQRS.Events; +using Squidex.Infrastructure.GetEventStore; using Squidex.Infrastructure.MongoDb.EventStore; -using EventStoreStore = Squidex.Infrastructure.EventStore.EventStore; namespace Squidex.Config.Domain { @@ -79,34 +79,34 @@ namespace Squidex.Config.Domain .As() .SingleInstance(); } - else if (string.Equals(eventStoreType, "EventStore", StringComparison.OrdinalIgnoreCase)) + else if (string.Equals(eventStoreType, "GetEventStore", StringComparison.OrdinalIgnoreCase)) { - var configuration = Configuration.GetValue("eventStore:eventStore:configuration"); + var configuration = Configuration.GetValue("eventStore:getEventStore:configuration"); if (string.IsNullOrWhiteSpace(configuration)) { - throw new ConfigurationException("Configure EventStore EventStore configuration with 'eventStore:eventStore:configuration'."); + throw new ConfigurationException("Configure GetEventStore EventStore configuration with 'eventStore:getEventStore:configuration'."); } - var projectionHost = Configuration.GetValue("eventStore:eventStore:projectionHost"); + var projectionHost = Configuration.GetValue("eventStore:getEventStore:projectionHost"); if (string.IsNullOrWhiteSpace(projectionHost)) { - throw new ConfigurationException("Configure EventStore EventStore projection host with 'eventStore:eventStore:projectionHost'."); + throw new ConfigurationException("Configure GetEventStore EventStore projection host with 'eventStore:getEventStore:projectionHost'."); } - var prefix = Configuration.GetValue("eventStore:eventStore:prefix"); + var prefix = Configuration.GetValue("eventStore:getEventStore:prefix"); var connection = EventStoreConnection.Create(configuration); - builder.Register(c => new EventStoreStore(connection, prefix, projectionHost)) + builder.Register(c => new GetEventStore(connection, prefix, projectionHost)) .As() .As() .SingleInstance(); } else { - throw new ConfigurationException($"Unsupported value '{eventStoreType}' for 'eventStore:type', supported: MongoDb, EventStore."); + throw new ConfigurationException($"Unsupported value '{eventStoreType}' for 'eventStore:type', supported: MongoDb, GetEventStore."); } } } diff --git a/src/Squidex/Squidex.csproj b/src/Squidex/Squidex.csproj index fcae22c2b..7208c9dbc 100644 --- a/src/Squidex/Squidex.csproj +++ b/src/Squidex/Squidex.csproj @@ -25,11 +25,11 @@ - + diff --git a/src/Squidex/appsettings.json b/src/Squidex/appsettings.json index 2ca1a9749..8366ac2cc 100644 --- a/src/Squidex/appsettings.json +++ b/src/Squidex/appsettings.json @@ -21,15 +21,15 @@ } }, "eventStore": { - "type": "EventStore", + "type": "GetEventStore", "mongoDb": { "configuration": "mongodb://localhost", "database": "Squidex" }, - "eventStore": { + "getEventStore": { "configuration": "ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500", - "projectionHost": "localhost", - "prefix": "squidex" + "projectionHost": "localhost", + "prefix": "squidex" }, "consume": true }, diff --git a/tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs b/tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs index bd251a7f0..a39cc59b9 100644 --- a/tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs +++ b/tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Threading.Tasks; using Moq; using Squidex.Infrastructure.CQRS.Events; @@ -73,7 +72,7 @@ namespace Squidex.Infrastructure.CQRS.Commands [Fact] public async Task Should_throw_exception_when_event_store_returns_no_events() { - eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult>(new List())); + eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult>(new List())); await Assert.ThrowsAsync(() => sut.GetByIdAsync(aggregateId)); } @@ -93,7 +92,7 @@ namespace Squidex.Infrastructure.CQRS.Commands new StoredEvent("1", 1, eventData2) }; - eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult>(events)); + eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult>(events)); eventDataFormatter.Setup(x => x.Parse(eventData1)).Returns(new Envelope(event1)); eventDataFormatter.Setup(x => x.Parse(eventData2)).Returns(new Envelope(event2)); @@ -118,7 +117,7 @@ namespace Squidex.Infrastructure.CQRS.Commands new StoredEvent("1", 1, eventData2) }; - eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult>(events)); + eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult>(events)); eventDataFormatter.Setup(x => x.Parse(eventData1)).Returns(new Envelope(event1)); eventDataFormatter.Setup(x => x.Parse(eventData2)).Returns(new Envelope(event2)); diff --git a/tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs b/tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs index c0717f2c1..d46d40515 100644 --- a/tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs +++ b/tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs @@ -91,7 +91,6 @@ namespace Squidex.Infrastructure.CQRS.Events private readonly Mock eventConsumerInfoRepository = new Mock(); private readonly Mock eventConsumer = new Mock(); - private readonly Mock eventNotifier = new Mock(); private readonly Mock log = new Mock(); private readonly Mock formatter = new Mock(new TypeNameRegistry(), null); private readonly EventData eventData1 = new EventData();