diff --git a/Shared.EventStore.Tests/AggregateExtensionsTests.cs b/Shared.EventStore.Tests/AggregateExtensionsTests.cs index 686bf3f..d718d1c 100644 --- a/Shared.EventStore.Tests/AggregateExtensionsTests.cs +++ b/Shared.EventStore.Tests/AggregateExtensionsTests.cs @@ -15,7 +15,7 @@ public class AggregateExtensionsTests{ public void AggregateExtensions_Apply_EventIsApplied() { TestAggregate t = TestAggregate.Create(TestData.AggregateId); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); t.Apply(aggregateNameSetEvent); t.AggregateName.ShouldBe("Test"); } @@ -24,7 +24,7 @@ public void AggregateExtensions_Apply_EventIsApplied() public void AggregateExtensions_Apply_DuplicateEvent_EventIsSilentlyHandled() { TestAggregate t = TestAggregate.Create(TestData.AggregateId); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); t.Apply(aggregateNameSetEvent); t.AggregateName.ShouldBe("Test"); t.Apply(aggregateNameSetEvent); @@ -34,7 +34,7 @@ public void AggregateExtensions_Apply_DuplicateEvent_EventIsSilentlyHandled() public void AggregateExtensions_GetHistoricalEvents_EventsReturned() { TestAggregate t = TestAggregate.Create(TestData.AggregateId); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); t.Apply(aggregateNameSetEvent); t.AggregateName.ShouldBe("Test"); IList events = t.GetHistoricalEvents(); diff --git a/Shared.EventStore.Tests/AggregateRepositoryManagerTests.cs b/Shared.EventStore.Tests/AggregateRepositoryManagerTests.cs index b4499b2..7a56bee 100644 --- a/Shared.EventStore.Tests/AggregateRepositoryManagerTests.cs +++ b/Shared.EventStore.Tests/AggregateRepositoryManagerTests.cs @@ -13,9 +13,9 @@ namespace Shared.EventStore.Tests; public class AggregateRepositoryManagerTests{ [Fact] public void AggregateRepositoryManager_GetAggregateRepository_AggregateRepositoryReturned(){ - Mock eventStoreContextManager = new Mock(); + Mock eventStoreContextManager = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateRepositoryManager aggregateRepositoryManager = new AggregateRepositoryManager(eventStoreContextManager.Object, factory); + AggregateRepositoryManager aggregateRepositoryManager = new(eventStoreContextManager.Object, factory); IAggregateRepository r = aggregateRepositoryManager.GetAggregateRepository(Guid.NewGuid()); r.ShouldNotBeNull(); diff --git a/Shared.EventStore.Tests/AggregateRepositoryTests.cs b/Shared.EventStore.Tests/AggregateRepositoryTests.cs index 902841a..921e9df 100644 --- a/Shared.EventStore.Tests/AggregateRepositoryTests.cs +++ b/Shared.EventStore.Tests/AggregateRepositoryTests.cs @@ -18,13 +18,13 @@ namespace Shared.EventStore.Tests; public class AggregateRepositoryTests{ [Fact] public async Task AggregateRepository_GetLatestVersion_AggregateReturned(){ - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object,factory); + AggregateRepository testAggregateRepository = new(context.Object,factory); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new(){ new ResolvedEvent(r, null, null) }; context.Setup(c => c.ReadEvents(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(e); @@ -49,15 +49,16 @@ public async Task AggregateRepository_GetLatestVersion_NotFound_AggregateReturne [Fact] public async Task AggregateRepository_GetLatestVersion_ErrorApplyingEvents_ErrorThrown() { - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Error"); + AggregateRepository testAggregateRepository = new(context.Object, factory); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Error"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ - new ResolvedEvent(r, null, null) - }; + List e = new() + { + new ResolvedEvent(r, null, null) + }; context.Setup(c => c.ReadEvents(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(e); Result result = await testAggregateRepository.GetLatestVersion(TestData.AggregateId, CancellationToken.None); result.IsFailed.ShouldBeTrue(); @@ -81,14 +82,14 @@ public async Task AggregateRepository_GetLatestVersion_NoEvents_AggregateReturne [Fact] public async Task AggregateRepository_GetLatestVersionFromLastEvent_AggregateReturned() { - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); + AggregateRepository testAggregateRepository = new(context.Object, factory); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new(){ new ResolvedEvent(r, null, null) }; context.Setup(c => c.GetEventsBackward(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(e); @@ -100,17 +101,17 @@ public async Task AggregateRepository_GetLatestVersionFromLastEvent_AggregateRet [Fact] public async Task AggregateRepository_SaveChanges_NoChangesMade_ChangesAreSaved() { - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new(){ new ResolvedEvent(r, null, null) }; context.Setup(c => c.GetEventsBackward(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(e); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); + AggregateRepository testAggregateRepository = new(context.Object, factory); Result testAggregate = await testAggregateRepository.GetLatestVersionFromLastEvent(TestData.AggregateId, CancellationToken.None); Result result = await testAggregateRepository.SaveChanges(testAggregate.Data, CancellationToken.None); @@ -120,18 +121,18 @@ public async Task AggregateRepository_SaveChanges_NoChangesMade_ChangesAreSaved( [Fact] public async Task AggregateRepository_SaveChanges_ErrorsOnInsert_FailedResult() { - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new() { new ResolvedEvent(r, null, null) }; context.Setup(c => c.GetEventsBackward(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(e)); context.Setup(c => c.InsertEvents(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(Result.Failure("error")); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); + AggregateRepository testAggregateRepository = new(context.Object, factory); Result testAggregate = await testAggregateRepository.GetLatestVersionFromLastEvent(TestData.AggregateId, CancellationToken.None); testAggregate.Data.SetAggregateName("New name", Guid.NewGuid()); Result result = await testAggregateRepository.SaveChanges(testAggregate.Data, CancellationToken.None); @@ -141,14 +142,14 @@ public async Task AggregateRepository_SaveChanges_ErrorsOnInsert_FailedResult() [Fact] public async Task AggregateRepository_GetLatestVersionFromLastEvent_GetEventsFailed_FailedResult() { - Mock context = new Mock(); + Mock context = new(); IDomainEventFactory factory = new DomainEventFactory(); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); + AggregateRepository testAggregateRepository = new(context.Object, factory); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new(){ new ResolvedEvent(r, null, null) }; context.Setup(c => c.GetEventsBackward(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure("error")); @@ -160,18 +161,18 @@ public async Task AggregateRepository_GetLatestVersionFromLastEvent_GetEventsFai [Fact] public async Task AggregateRepository_SaveChanges_ChangesMade_ChangesAreSaved() { - Mock context = new Mock(); + Mock context = new(); context.Setup(c => c.InsertEvents(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(Result.Success); IDomainEventFactory factory = new DomainEventFactory(); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventRecord r = TestData.CreateEventRecord(aggregateNameSetEvent, "TestAggregate"); - List e = new List{ + List e = new() { new ResolvedEvent(r, null, null) }; context.Setup(c => c.GetEventsBackward(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(e); - AggregateRepository testAggregateRepository = new AggregateRepository(context.Object, factory); + AggregateRepository testAggregateRepository = new(context.Object, factory); Result testAggregaterResult = await testAggregateRepository.GetLatestVersionFromLastEvent(TestData.AggregateId, CancellationToken.None); var testAggregate = testAggregaterResult.Data; testAggregate.SetAggregateName("New name", Guid.NewGuid()); diff --git a/Shared.EventStore.Tests/ApplicationBuilderExtensionsTests.cs b/Shared.EventStore.Tests/ApplicationBuilderExtensionsTests.cs index 0a338d8..0145c55 100644 --- a/Shared.EventStore.Tests/ApplicationBuilderExtensionsTests.cs +++ b/Shared.EventStore.Tests/ApplicationBuilderExtensionsTests.cs @@ -26,10 +26,9 @@ public ApplicationBuilderExtensionsTests(ITestOutputHelper testOutputHelper) { [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot { + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List() { new SubscriptionWorkerConfig @@ -51,7 +50,7 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_WorkerListReturn } }; - Mock deh = new Mock(); + Mock deh = new(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); eventHandlerResolvers.Add("Ordered", deh.Object); @@ -66,10 +65,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_WorkerListReturn [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_NoneEnabled_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List() { @@ -86,7 +84,7 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_NoneEnabled_Work } } }; - Mock deh = new Mock(); + Mock deh = new(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); eventHandlerResolvers.Add("Ordered", deh.Object); @@ -100,14 +98,12 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_NoneEnabled_Work [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_NoWorkers_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List() }; - Mock deh = new Mock(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); Action traceHandler = null; @@ -119,10 +115,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_NoWorkers_Worker [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorkers_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List { @@ -133,7 +128,7 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorke }, } }; - Mock deh = new Mock(); + Mock deh = new(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); eventHandlerResolvers.Add("Ordered", deh.Object); @@ -147,10 +142,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorke [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorkers_NoHandlers_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List { @@ -161,7 +155,6 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorke }, } }; - Mock deh = new Mock(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); Action traceHandler = (et, type, msg) => { TestOutputHelper.WriteLine(msg); }; @@ -173,10 +166,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_OrderedOnlyWorke [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List { @@ -189,7 +181,7 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_ } } }; - Mock deh = new Mock(); + Mock deh = new(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); eventHandlerResolvers.Add("Main", deh.Object); @@ -203,10 +195,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_ [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_NoHandlers_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List { @@ -219,7 +210,6 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_ } } }; - Mock deh = new Mock(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); Action traceHandler = (et, type, msg) => { TestOutputHelper.WriteLine(msg); }; @@ -231,10 +221,9 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_ [Fact] public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_InstanceCount2_WorkerListReturned() { - Mock appBuilder = new Mock(); - Mock subscriptionRepository = new Mock(); + Mock subscriptionRepository = new(); - SubscriptionWorkersRoot config = new SubscriptionWorkersRoot + SubscriptionWorkersRoot config = new() { SubscriptionWorkers = new List { @@ -247,7 +236,7 @@ public void ApplicationBuilderExtensions_ConfigureSubscriptions_MainOnlyWorkers_ } } }; - Mock deh = new Mock(); + Mock deh = new(); String eventStoreConnectionString = "esdb://192.168.0.133:2113?tls=true&tlsVerifyCert=false"; Dictionary eventHandlerResolvers = new(); eventHandlerResolvers.Add("Main", deh.Object); diff --git a/Shared.EventStore.Tests/DomainEventFactoryTests.cs b/Shared.EventStore.Tests/DomainEventFactoryTests.cs index 26cffc4..fe9e078 100644 --- a/Shared.EventStore.Tests/DomainEventFactoryTests.cs +++ b/Shared.EventStore.Tests/DomainEventFactoryTests.cs @@ -18,9 +18,9 @@ public class DomainEventFactoryTests { [Fact] public void DomainEventFactory_CreateDomainEvent_StringAndType_DomainEventCreated(){ - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); String eventData = JsonConvert.SerializeObject(aggregateNameSetEvent); - DomainEventFactory factory = new DomainEventFactory(); + DomainEventFactory factory = new(); DomainEvent newEvent = factory.CreateDomainEvent(eventData, typeof(AggregateNameSetEvent)); ((AggregateNameSetEvent)newEvent).AggregateName.ShouldBe(aggregateNameSetEvent.AggregateName); } @@ -28,10 +28,10 @@ public void DomainEventFactory_CreateDomainEvent_StringAndType_DomainEventCreate [Fact] public void DomainEventFactory_CreateDomainEvent_StringAndType_InvalidJson_ExceptionThrown() { - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); String eventData = JsonConvert.SerializeObject(aggregateNameSetEvent); eventData = eventData.Replace(":", ""); - DomainEventFactory factory = new DomainEventFactory(); + DomainEventFactory factory = new(); Should.Throw(() => { factory.CreateDomainEvent(eventData, typeof(AggregateNameSetEvent)); }); @@ -40,10 +40,10 @@ public void DomainEventFactory_CreateDomainEvent_StringAndType_InvalidJson_Excep [Fact] public void DomainEventFactory_CreateDomainEvent_GuidAndResolvedEvent_DomainEventCreated() { - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); - ResolvedEvent resolvedEvent = new ResolvedEvent(TestData.CreateEventRecord(aggregateNameSetEvent, "TestStream"),null,null); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); + ResolvedEvent resolvedEvent = new(TestData.CreateEventRecord(aggregateNameSetEvent, "TestStream"), null, null); - DomainEventFactory factory = new DomainEventFactory(); + DomainEventFactory factory = new(); DomainEvent newEvent = factory.CreateDomainEvent(TestData.AggregateId, resolvedEvent); ((AggregateNameSetEvent)newEvent).AggregateName.ShouldBe(aggregateNameSetEvent.AggregateName); } @@ -51,10 +51,10 @@ public void DomainEventFactory_CreateDomainEvent_GuidAndResolvedEvent_DomainEven [Fact] public void DomainEventFactory_CreateDomainEvent_GuidAndResolvedEvent_UnknownEventType_ExceptionThrown() { - UnknownEvent unknownEvent = new UnknownEvent(TestData.AggregateId, TestData.EventId, "Test"); - ResolvedEvent resolvedEvent = new ResolvedEvent(TestData.CreateEventRecord(unknownEvent, "TestStream", false), null, null); + UnknownEvent unknownEvent = new(TestData.AggregateId, TestData.EventId, "Test"); + ResolvedEvent resolvedEvent = new(TestData.CreateEventRecord(unknownEvent, "TestStream", false), null, null); - DomainEventFactory factory = new DomainEventFactory(); + DomainEventFactory factory = new(); Should.Throw(() => { factory.CreateDomainEvent(TestData.AggregateId, resolvedEvent); }); @@ -63,12 +63,12 @@ public void DomainEventFactory_CreateDomainEvent_GuidAndResolvedEvent_UnknownEve [Fact] public void DomainEventFactory_CreateDomainEvents_GuidAndResolvedEventList_DomainEventCreated() { - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); - List resolvedEventList = new List{ + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); + List resolvedEventList = new() { new ResolvedEvent(TestData.CreateEventRecord(aggregateNameSetEvent, "TestStream"), null, null) }; - DomainEventFactory factory = new DomainEventFactory(); + DomainEventFactory factory = new(); DomainEvent[] newEvent = factory.CreateDomainEvents(TestData.AggregateId, resolvedEventList); ((AggregateNameSetEvent)newEvent.Single()).AggregateName.ShouldBe(aggregateNameSetEvent.AggregateName); } @@ -77,8 +77,8 @@ public void DomainEventFactory_CreateDomainEvents_GuidAndResolvedEventList_Domai public class EventDataFactoryTests{ [Fact] public void EventDataFactory_CreateEventData_EventDataCreated(){ - EventDataFactory factory = new EventDataFactory(); - AggregateNameSetEvent aggregateNameSetEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, "Test"); + EventDataFactory factory = new(); + AggregateNameSetEvent aggregateNameSetEvent = new(TestData.AggregateId, TestData.EventId, "Test"); EventData eventData = factory.CreateEventData(aggregateNameSetEvent); eventData.EventId.ToGuid().ShouldBe(aggregateNameSetEvent.EventId); } @@ -86,7 +86,7 @@ public void EventDataFactory_CreateEventData_EventDataCreated(){ [Fact] public void EventDataFactory_CreateEventData_NullEvent_ErrorThrown() { - EventDataFactory factory = new EventDataFactory(); + EventDataFactory factory = new(); Should.Throw(() => { factory.CreateEventData(null); @@ -96,10 +96,10 @@ public void EventDataFactory_CreateEventData_NullEvent_ErrorThrown() [Fact] public void EventDataFactory_CreateEventDataList_EventDataCreated() { - EventDataFactory factory = new EventDataFactory(); - List events = new List(); - AggregateNameSetEvent aggregateNameSetEvent1 = new AggregateNameSetEvent(TestData.AggregateId, Guid.NewGuid(), "Test"); - AggregateNameSetEvent aggregateNameSetEvent2 = new AggregateNameSetEvent(TestData.AggregateId, Guid.NewGuid(), "Test"); + EventDataFactory factory = new(); + List events = new(); + AggregateNameSetEvent aggregateNameSetEvent1 = new(TestData.AggregateId, Guid.NewGuid(), "Test"); + AggregateNameSetEvent aggregateNameSetEvent2 = new(TestData.AggregateId, Guid.NewGuid(), "Test"); events.Add(aggregateNameSetEvent1); events.Add(aggregateNameSetEvent2); diff --git a/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs b/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs index 0314787..b89cfd6 100644 --- a/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs +++ b/Shared.EventStore.Tests/DomainEventHandlerResolverTests.cs @@ -13,7 +13,7 @@ public class DomainEventHandlerResolverTests { [Fact] public void DomainEventHandlerResolver_GetDomainEventHandlers_HandlerResolved(){ - Dictionary eventHandlerConfiguration= new Dictionary(); + Dictionary eventHandlerConfiguration= new(); IDomainEventHandler CreateEventHandlerFunc(Type t) { if (t.Name == nameof(TestDomainEventHandler)) return new TestDomainEventHandler(); @@ -25,7 +25,7 @@ IDomainEventHandler CreateEventHandlerFunc(Type t) { eventHandlerConfiguration.Add("Shared.EventStore.Tests.TestObjects.TestDomainEventHandler, Shared.EventStore.Tests", new String[]{"EstateCreatedEvent"}); eventHandlerConfiguration.Add("Shared.EventStore.Tests.TestObjects.TestDomainEventHandler2, Shared.EventStore.Tests", new String[] { "EstateCreatedEvent" }); - DomainEventHandlerResolver r = new DomainEventHandlerResolver(eventHandlerConfiguration, CreateEventHandlerFunc); + DomainEventHandlerResolver r = new(eventHandlerConfiguration, CreateEventHandlerFunc); List result = r.GetDomainEventHandlers(new EstateCreatedEvent(TestData.AggregateId, TestData.EstateName)); result.Count.ShouldBe(2); result.Count(x => x.GetType() == typeof(TestDomainEventHandler)).ShouldBe(1); @@ -35,12 +35,12 @@ IDomainEventHandler CreateEventHandlerFunc(Type t) { [Fact] public void DomainEventHandlerResolver_EventNotConfigured_NullReturned() { - Dictionary eventHandlerConfiguration = new Dictionary(); + Dictionary eventHandlerConfiguration = new(); Func createEventHandlerFunc = (t) => { return new TestDomainEventHandler(); }; - DomainEventHandlerResolver r = new DomainEventHandlerResolver(eventHandlerConfiguration, createEventHandlerFunc); + DomainEventHandlerResolver r = new(eventHandlerConfiguration, createEventHandlerFunc); List result = r.GetDomainEventHandlers(new EstateCreatedEvent(TestData.AggregateId, TestData.EstateName)); result.ShouldBeNull(); } diff --git a/Shared.EventStore.Tests/DomainEventHelperTests.cs b/Shared.EventStore.Tests/DomainEventHelperTests.cs index e855de4..981ef7c 100644 --- a/Shared.EventStore.Tests/DomainEventHelperTests.cs +++ b/Shared.EventStore.Tests/DomainEventHelperTests.cs @@ -18,7 +18,7 @@ public class DomainEventHelperTests public void DomainEventHelper_GetProperty_CorrectCase_PropertyNotFound() { - AggregateNameSetEvent domainEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, TestData.EstateName); + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName1"); propertyValue.ShouldBe(default); } @@ -30,7 +30,7 @@ public void DomainEventHelper_GetProperty_CorrectCase_PropertyNotFound() public void DomainEventHelper_GetProperty_IgnoreCase_PropertyNotFound(String propertyName) { - AggregateNameSetEvent domainEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, TestData.EstateName); + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); propertyValue.ShouldBe(default); } @@ -38,7 +38,7 @@ public void DomainEventHelper_GetProperty_IgnoreCase_PropertyNotFound(String pro [Fact] public void DomainEventHelper_GetProperty_CorrectCase_PropertyFound(){ - AggregateNameSetEvent domainEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, TestData.EstateName); + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName"); propertyValue.ShouldBe(TestData.EstateName); } @@ -50,7 +50,7 @@ public void DomainEventHelper_GetProperty_CorrectCase_PropertyFound(){ public void DomainEventHelper_GetProperty_IgnoreCase_PropertyFound(String propertyName) { - AggregateNameSetEvent domainEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, TestData.EstateName); + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); propertyValue.ShouldBe(TestData.EstateName); } @@ -63,7 +63,7 @@ public void DomainEventHelper_GetProperty_IgnoreCase_PropertyFound(String proper public void DomainEventHelper_HasProperty_ExpectedResultReturned(String propertyName, Boolean expectedResult) { - AggregateNameSetEvent domainEvent = new AggregateNameSetEvent(TestData.AggregateId, TestData.EventId, TestData.EstateName); + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); var result = DomainEventHelper.HasProperty(domainEvent, propertyName); result.ShouldBe(expectedResult); } diff --git a/Shared.EventStore/EventStore/EventStoreContextManager.cs b/Shared.EventStore/EventStore/EventStoreContextManager.cs index b95d46e..f17e62f 100644 --- a/Shared.EventStore/EventStore/EventStoreContextManager.cs +++ b/Shared.EventStore/EventStore/EventStoreContextManager.cs @@ -40,7 +40,7 @@ public class EventStoreContextManager : IEventStoreContextManager /// /// The padlock /// - private readonly Object padlock = new Object(); + private readonly Object padlock = new(); #endregion @@ -54,7 +54,7 @@ public class EventStoreContextManager : IEventStoreContextManager public EventStoreContextManager(Func eventStoreContextFunc, IConnectionStringConfigurationRepository connectionStringConfigurationRepository) { - this.EventStoreContexts = new Dictionary(); + this.EventStoreContexts = new(); this.EventStoreContextFunc = eventStoreContextFunc; this.ConnectionStringConfigurationRepository = connectionStringConfigurationRepository; } diff --git a/Shared.EventStore/Extensions/IApplicationBuilderExtenstions.cs b/Shared.EventStore/Extensions/IApplicationBuilderExtenstions.cs index b753506..08206c0 100644 --- a/Shared.EventStore/Extensions/IApplicationBuilderExtenstions.cs +++ b/Shared.EventStore/Extensions/IApplicationBuilderExtenstions.cs @@ -24,7 +24,7 @@ public static async Task ConfigureSubscriptionService(this IApplicationBuilder a Action traceHandler, Func subscriptionRepositoryResolver) { - using (CancellationTokenSource cts = new CancellationTokenSource()) + using (CancellationTokenSource cts = new()) { if (workerConfig == null) throw new Exception("No Worker configuration supplied"); diff --git a/Shared.EventStore/SubscriptionWorker/InMemoryPersistentSubscriptionsClient.cs b/Shared.EventStore/SubscriptionWorker/InMemoryPersistentSubscriptionsClient.cs index c84c907..4793f77 100644 --- a/Shared.EventStore/SubscriptionWorker/InMemoryPersistentSubscriptionsClient.cs +++ b/Shared.EventStore/SubscriptionWorker/InMemoryPersistentSubscriptionsClient.cs @@ -46,7 +46,7 @@ public void WriteEvent(String @event, String @type, CancellationToken cancellati metadata.Add("created", "1000"); metadata.Add("content-type", "application/json"); - EventRecord er = new EventRecord(this.Stream, Uuid.NewUuid(), StreamPosition.Start, Position.Start, metadata, data, custommetadata); + EventRecord er = new(this.Stream, Uuid.NewUuid(), StreamPosition.Start, Position.Start, metadata, data, custommetadata); ResolvedEvent re = new(er, null, null); this.EventAppeared(default(global::EventStore.Client.PersistentSubscription), re, 0, cancellationToken);