Ejemplo n.º 1
0
        public async Task Given_2TypesOfEvaluator_When_PersistForOneEventType_Then_OneEvaluatorChecked()
        {
            var @event             = A.Dummy <Event>();
            var innerSink          = A.Dummy <IEventSink>();
            var evaluator          = A.Fake <IEventOccurredConditionEvaluator>();
            var evaluator2         = A.Fake <IEventOccurredConditionEvaluator>();
            IEventMonitorSink sink = new EventMonitorSink(innerSink);

            // Act
            sink.AddEvaluator(typeof(DeviceAuthorizationFailureEvent), evaluator);
            sink.AddEvaluator(@event.GetType(), evaluator2);
            await sink.PersistAsync(@event);

            // Assert
            A.CallTo(() => evaluator.CheckEventAsync(@event, A <CancellationToken> ._)).MustNotHaveHappened();
            A.CallTo(() => evaluator2.CheckEventAsync(@event, A <CancellationToken> ._)).MustHaveHappened();
        }
Ejemplo n.º 2
0
        public async Task Given_Evaluator_When_AddEvaluatorAndPersist_Then_EvaluatorChecked()
        {
            var @event             = A.Dummy <Event>();
            var innerSink          = A.Dummy <IEventSink>();
            var evaluator          = A.Fake <IEventOccurredConditionEvaluator>();
            IEventMonitorSink sink = new EventMonitorSink(innerSink);

            // Act
            sink.AddEvaluator(@event.GetType(), evaluator);
            await sink.PersistAsync(@event);

            // Assert
            A.CallTo(() => evaluator.CheckEventAsync(@event, A <CancellationToken> ._)).MustHaveHappened();
        }