From ebab2a351d0ab0a0d2357268baaa16f4ffcd6063 Mon Sep 17 00:00:00 2001 From: jschick04 Date: Fri, 24 Jul 2026 21:52:41 +0000 Subject: [PATCH] Add integration test guarding event-log reducer registration --- .../EventLogReducerRegistrationTests.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EventLogReducerRegistrationTests.cs diff --git a/tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EventLogReducerRegistrationTests.cs b/tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EventLogReducerRegistrationTests.cs new file mode 100644 index 00000000..67b3c44a --- /dev/null +++ b/tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EventLogReducerRegistrationTests.cs @@ -0,0 +1,48 @@ +// // Copyright (c) Microsoft Corporation. +// // Licensed under the MIT License. + +using EventLogExpert.Eventing.Common.Channels; +using EventLogExpert.Eventing.Common.EventLogs; +using EventLogExpert.Filtering.TestUtils; +using EventLogExpert.Runtime.EventLog; +using EventLogExpert.Runtime.Tests.TestUtils.Constants; +using Fluxor; +using Fluxor.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Immutable; + +namespace EventLogExpert.Runtime.Tests.EventLog; + +public sealed class EventLogReducerRegistrationTests +{ + [Fact] + public void RegisteredReducers_AddThenConsumeEvents_UpdateNewEventBuffer() + { + using ServiceProvider provider = new ServiceCollection() + .AddFluxor(options => options.RegisterStateLibrary().WithLifetime(StoreLifetime.Singleton)) + .BuildServiceProvider(); + + var feature = provider.GetRequiredService>(); + + feature.RestoreState(feature.State with + { + ContinuouslyUpdate = false, + OpenLogs = ImmutableDictionary.Empty + .Add(Constants.LogNameTestLog, new OpenLogInfo(EventLogId.Create(), LogPathType.Channel)) + }); + + var first = FilterEventBuilder.CreateTestEvent(100, owningLog: Constants.LogNameTestLog); + var second = FilterEventBuilder.CreateTestEvent(200, owningLog: Constants.LogNameTestLog); + + feature.ReceiveDispatchNotificationFromStore(new AddEventAction(first)); + feature.ReceiveDispatchNotificationFromStore(new AddEventAction(second)); + + Assert.Equal(2, feature.State.NewEventBuffer.Count); + Assert.Same(second, feature.State.NewEventBuffer[0]); + Assert.Same(first, feature.State.NewEventBuffer[1]); + + feature.ReceiveDispatchNotificationFromStore(new NewEventBufferConsumedAction([first, second])); + + Assert.Empty(feature.State.NewEventBuffer); + } +}