Exemplo n.º 1
0
        public void Dispatch_OneAction_ShouldDispatchOneAction()
        {
            // arrange
            var context = new Mock <IExecutionTaskContext>();

            context.Setup(t => t.Register(It.IsAny <IExecutionTask>()));
            var hasTask = false;

            var scheduler = new BatchScheduler();

            scheduler.TaskEnqueued += (_, _) => hasTask = true;

            ValueTask Dispatch() => default;

            scheduler.Schedule(Dispatch);
            Assert.True(hasTask);
            hasTask = false;

            // act
            scheduler.BeginDispatch();

            // assert
            Assert.False(hasTask);
        }