diff --git a/Driver/Program.cs b/Driver/Program.cs index 06fe14e6..4ba783a8 100644 --- a/Driver/Program.cs +++ b/Driver/Program.cs @@ -21,7 +21,7 @@ internal class Program #region Methods internal static EventStoreClientSettings ConfigureEventStoreSettings() { - EventStoreClientSettings settings = new(); //EventStoreClientSettings.Create("esdb://127.0.0.1:2113?tls=trur"); + EventStoreClientSettings settings = new(); settings.CreateHttpMessageHandler = () => new SocketsHttpHandler { SslOptions = { @@ -43,10 +43,6 @@ internal static EventStoreClientSettings ConfigureEventStoreSettings() { private static async Task Main(String[] args) { Logger.Initialise(NullLogger.Instance); await Program.SubscriptionsTest(); - //await Program.QueryTest(); - - //TestDockerHelper t = new TestDockerHelper(); - //await t.StartContainersForScenarioRun(""); Console.ReadKey(); } @@ -69,8 +65,6 @@ private static async Task SubscriptionsTest() { ISubscriptionRepository subscriptionRepository = SubscriptionRepository.Create(eventStoreConnectionString, cacheDuration); - //((SubscriptionRepository)subscriptionRepository).Trace += (sender, s) => Extensions.log(TraceEventType.Information, "REPOSITORY", s); - // init our SubscriptionRepository subscriptionRepository.PreWarm(CancellationToken.None).Wait(); @@ -90,10 +84,6 @@ private static async Task SubscriptionsTest() { } #endregion - - #region Others - - #endregion } diff --git a/Shared.EventStore.Tests/AggregateExtensionsTests.cs b/Shared.EventStore.Tests/AggregateExtensionsTests.cs index e95731ed..2210f773 100644 --- a/Shared.EventStore.Tests/AggregateExtensionsTests.cs +++ b/Shared.EventStore.Tests/AggregateExtensionsTests.cs @@ -80,7 +80,6 @@ public void AggregateExtensions_IsEventDuplicate_EventsIsNotADuplicate(Boolean c public void AggregateExtensions_GetPendingEvents_EventIsApplied() { TestAggregate t = TestAggregate.Create(TestData.AggregateId); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); t.CommitPendingEvents(); IList events = t.GetPendingEvents(); events.Count.ShouldBe(0); diff --git a/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs b/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs index 191d2beb..1fe5636d 100644 --- a/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs +++ b/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs @@ -36,8 +36,6 @@ public void DomainEventHandlerResolver_EventNotConfigured_NullReturned() return new TestDomainEventHandler(); }; - List handlers = new List(); - DomainEventHandlerResolver r = new DomainEventHandlerResolver(eventHandlerConfiguration, createEventHandlerFunc); List result = r.GetDomainEventHandlers(new EstateCreatedEvent(TestData.AggregateId, TestData.EstateName)); result.ShouldBeNull(); @@ -56,7 +54,7 @@ public void DomainEventHandlerResolver_GetDomainEventHandlers_NoHandlerFound_Err eventHandlerConfiguration.Add("EstateCreatedEvent", handlers.ToArray()); Should.Throw(() => { - DomainEventHandlerResolver r = new DomainEventHandlerResolver(eventHandlerConfiguration, createEventHandlerFunc); + new DomainEventHandlerResolver(eventHandlerConfiguration, createEventHandlerFunc); }); } } diff --git a/Shared.EventStore.Tests/IApplicationBuilderExtenstionsTests.cs b/Shared.EventStore.Tests/IApplicationBuilderExtenstionsTests.cs deleted file mode 100644 index 43b8a3ef..00000000 --- a/Shared.EventStore.Tests/IApplicationBuilderExtenstionsTests.cs +++ /dev/null @@ -1,190 +0,0 @@ -namespace Shared.EventStore.Tests; - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; -using EventHandling; -using Extensions; -using global::EventStore.Client; -using Microsoft.AspNetCore.Builder; -using Moq; -using Shouldly; -using SubscriptionWorker; -using TestObjects; -using Xunit; -using PersistentSubscription = global::EventStore.Client.PersistentSubscription; - -/*public class IApplicationBuilderExtenstionsTests{ - private IApplicationBuilder builder; - - private SubscriptionWorkersRoot subscriptionWorkersRoot; - - private Mock subscriptionRepository; - - private Func subscriptionRepositoryResolver; - - private Dictionary eventHandlerResolvers; - - private Mock domainEventHandlerResolver; - - public IApplicationBuilderExtenstionsTests(){ - this.builder = new ApplicationBuilder(new TestServiceProvider()); - this.subscriptionWorkersRoot = new SubscriptionWorkersRoot(); - this.subscriptionWorkersRoot.InternalSubscriptionService = true; - this.subscriptionWorkersRoot.SubscriptionWorkers = new List(); - - Mock subscriptionRepository = new Mock(); - this.subscriptionRepositoryResolver = (s, i) => subscriptionRepository.Object; - subscriptionRepository.Setup(s => - s.GetSubscriptions(It.IsAny(), It.IsAny())).ReturnsAsync(new PersistentSubscriptions()); - this.eventHandlerResolvers = new Dictionary(); - this.domainEventHandlerResolver = new Mock(); - - } - - [Fact] - public async Task ConfigureSubscriptionService_IsOrdered_ConfiguredSuccessfully() - { - this.subscriptionWorkersRoot.SubscriptionWorkers.Add(new SubscriptionWorkerConfig - { - Enabled = true, - IsOrdered = true - }); - this.eventHandlerResolvers.Add("Ordered", this.domainEventHandlerResolver.Object); - - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "esdb://admin:changeit@127.0.0.1:2113?tls=true&tlsVerifyCert=false", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - } - - private void TraceHandler(TraceEventType arg1, String arg2, String arg3){ - - } - - [Fact] - public async Task ConfigureSubscriptionService_IsConcurrent_ConfiguredSuccessfully() - { - this.subscriptionWorkersRoot.SubscriptionWorkers.Add(new SubscriptionWorkerConfig - { - Enabled = true, - IsOrdered = false, - InstanceCount = 1 - }); - this.eventHandlerResolvers.Add("Main", this.domainEventHandlerResolver.Object); - - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "esdb://admin:changeit@127.0.0.1:2113?tls=true&tlsVerifyCert=false", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - } - - - [Fact] - public async Task ConfigureSubscriptionService_NullWorkerConfig_ErrorThrown() - { - this.subscriptionWorkersRoot = null; - Should.Throw(async () => - { - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - }); - } - - [Fact] - public async Task ConfigureSubscriptionService_NullSubscriptionRepositoryResolver_ErrorThrown() - { - this.subscriptionRepositoryResolver = null; - Should.Throw(async () => - { - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - }); - } - - [Fact] - public async Task ConfigureSubscriptionService_NullSubscriptionWorkersList_ErrorThrown() - { - this.subscriptionWorkersRoot.SubscriptionWorkers = null; - - Should.Throw(async () => - { - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - }); - } - - [Fact] - public async Task ConfigureSubscriptionService_EmptySubscriptionWorkersList_ErrorThrown() - { - this.subscriptionWorkersRoot.SubscriptionWorkers = new List(); - - Should.Throw(async () => - { - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - }); - } - - [Fact] - public async Task ConfigureSubscriptionService_SubscriptionWorkersNotEnabled_NoErrorThrown() - { - - this.subscriptionWorkersRoot.SubscriptionWorkers.Add(new SubscriptionWorkerConfig - { - Enabled = false - }); - - Should.NotThrow(async () => - { - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - }); - } - - [Fact] - public async Task ConfigureSubscriptionService_InternalSubscriptionService_Off_NoError() - { - this.subscriptionWorkersRoot.InternalSubscriptionService = false; - await this.builder.ConfigureSubscriptionService(this.subscriptionWorkersRoot, - "", - new EventStoreClientSettings(), - this.eventHandlerResolvers, - TraceHandler, - this.subscriptionRepositoryResolver, - CancellationToken.None); - } -}*/ \ No newline at end of file diff --git a/Shared.EventStore.Tests/ProjectionHandlerTests.cs b/Shared.EventStore.Tests/ProjectionHandlerTests.cs index 52bf17fe..3609ab80 100644 --- a/Shared.EventStore.Tests/ProjectionHandlerTests.cs +++ b/Shared.EventStore.Tests/ProjectionHandlerTests.cs @@ -86,12 +86,6 @@ public async Task ProjectionHandler_Handle_NullEvent_EventHandled() [Fact] public async Task ProjectionHandler_Handle_EventNotHandled_EventHandled() { - TestState originalState = new TestState(); - TestState updatedState = new TestState - { - Name = "Test Name" - }; - Mock> projectionStateRepository = new Mock>(); Mock> projection = new Mock>(); projection.Setup(p => p.ShouldIHandleEvent(It.IsAny())).Returns(false); diff --git a/Shared.EventStore/Aggregate/EventDataFactory.cs b/Shared.EventStore/Aggregate/EventDataFactory.cs index 12dc13fb..59b036d4 100644 --- a/Shared.EventStore/Aggregate/EventDataFactory.cs +++ b/Shared.EventStore/Aggregate/EventDataFactory.cs @@ -38,7 +38,6 @@ public class EventDataFactory : IEventDataFactory /// public EventDataFactory() { - //this.Serialiser = new JsonSerialiser(jsonOptionsFunc); JsonConvert.DefaultSettings = EventDataFactory.jsonOptionsFunc; } diff --git a/Shared.EventStore/EventStore/EventStoreContext.cs b/Shared.EventStore/EventStore/EventStoreContext.cs index b2b7b667..39004fce 100644 --- a/Shared.EventStore/EventStore/EventStoreContext.cs +++ b/Shared.EventStore/EventStore/EventStoreContext.cs @@ -161,12 +161,6 @@ public async Task InsertEvents(String streamName, Object metadata, CancellationToken cancellationToken) { - List eventData = new List(); - JsonSerializerSettings s = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }; - this.LogInformation($"About to append {aggregateEvents.Count} to Stream {streamName}"); try { await this.EventStoreClient.AppendToStreamAsync(streamName, StreamRevision.FromInt64(expectedVersion), diff --git a/Shared.EventStore/EventStore/IEventStoreContextManager.cs b/Shared.EventStore/EventStore/IEventStoreContextManager.cs index 0035cdec..49c758e7 100644 --- a/Shared.EventStore/EventStore/IEventStoreContextManager.cs +++ b/Shared.EventStore/EventStore/IEventStoreContextManager.cs @@ -7,6 +7,8 @@ namespace Shared.EventStore.EventStore public interface IEventStoreContextManager { + event TraceHandler TraceGenerated; + IEventStoreContext GetEventStoreContext(String connectionIdentifier, String connectionStringIdentifier); IEventStoreContext GetEventStoreContext(String connectionIdentifier); diff --git a/Shared.EventStoreContext.Tests/EventStoreContextTests.cs b/Shared.EventStoreContext.Tests/EventStoreContextTests.cs index 32d75c9d..38662d85 100644 --- a/Shared.EventStoreContext.Tests/EventStoreContextTests.cs +++ b/Shared.EventStoreContext.Tests/EventStoreContextTests.cs @@ -39,7 +39,7 @@ public EventStoreContextTests(){ #region Methods public void Dispose(){ - + // Just needed for the interface } [OneTimeTearDown] @@ -351,42 +351,5 @@ private IEventStoreContext CreateContext(Boolean secureEventStore, TimeSpan? dea #endregion - - //private async Task RunTransientQuery(IEventStoreContext context, String query, Int32 checkType, TimeSpan? deadline = null, TimeSpan? retryTimeout = null){ - // Int32 counter = 0; - // String queryResult = null; - // await Retry.For(async () => { - // counter++; - // this.EventStoreDockerHelper.Trace($"Inside Retry Counter [{counter}] Check Type [{checkType}]"); - // Result? queryResult = await context.RunTransientQuery(query, CancellationToken.None); - // if (checkType == 1){ - // queryResult.IsFailed.ShouldBeTrue(); - - // String errors = String.Join("|", queryResult.Errors); - // this.EventStoreDockerHelper.Trace(errors); - // if (errors.Any()) { - // errors.Contains("Faulted").ShouldBeTrue(); - // } - // else { - // queryResult.Message.Contains("Faulted").ShouldBeTrue(); - // } - // } - // else{ - - // switch(checkType){ - // case 2: // Not Null or Empty - // queryResult.Data.ShouldNotBeNullOrEmpty(); - // break; - // case 3: // Empty - // queryResult.Data.ShouldBeEmpty(); - // break; - // } - // } - // }, - // retryTimeout, - // deadline); - // return queryResult; - - //} } } \ No newline at end of file diff --git a/Shared.Tests/TestHelpers.cs b/Shared.Tests/TestHelpers.cs index 69138bc9..181c1ef7 100644 --- a/Shared.Tests/TestHelpers.cs +++ b/Shared.Tests/TestHelpers.cs @@ -33,7 +33,7 @@ public static ErrorResponse GetErrorResponse(DefaultHttpContext context) return responseData; } - public const String ExceptionMessage = "Test Exception Message"; + public static readonly String ExceptionMessage = "Test Exception Message"; public static T CreateException() where T : Exception{ return (T)System.Activator.CreateInstance(typeof(T), TestHelpers.ExceptionMessage);