Exemple #1
0
        public void Schedule_OneAction_HasTasksShouldReturnTrue()
        {
            // arrange
            var scheduler             = new BatchScheduler();
            Func <ValueTask> dispatch = () => default;

            // act
            scheduler.Schedule(dispatch);

            // assert
            Assert.True(scheduler.HasTasks);
        }
        public void Schedule_OneAction_HasTasksShouldReturnTrue()
        {
            // arrange
            var hasTask   = false;
            var scheduler = new BatchScheduler();

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

            // act
            scheduler.Schedule(Dispatch);

            // assert
            Assert.True(hasTask);
        }
Exemple #3
0
        public void Dispatch_OneAction_ShouldDispatchOneAction()
        {
            // arrange
            var scheduler             = new BatchScheduler();
            Func <ValueTask> dispatch = () => default;

            scheduler.Schedule(dispatch);
            Assert.True(scheduler.HasTasks);

            // act
            scheduler.Dispatch(d => { });

            // assert
            Assert.False(scheduler.HasTasks);
        }
        public void Schedule_OneAction_ShouldRaiseTaskEnqueued()
        {
            // arrange
            var hasBeenRaised = false;
            var scheduler     = new BatchScheduler();

            ValueTask Dispatch() => default;

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

            // act
            scheduler.Schedule(Dispatch);

            // assert
            Assert.True(hasBeenRaised);
        }
Exemple #5
0
        public void Schedule_OneAction_ShouldRaiseTaskEnqueued()
        {
            // arrange
            var hasBeenRaised         = false;
            var scheduler             = new BatchScheduler();
            Func <ValueTask> dispatch = () => default;

            scheduler.TaskEnqueued += (s, e) =>
            {
                hasBeenRaised = true;
            };

            // act
            scheduler.Schedule(dispatch);

            // assert
            Assert.True(hasBeenRaised);
        }
Exemple #6
0
        public async Task Dispatch_OneAction_ShouldDispatchOneAction()
        {
            // arrange
            var context = new Mock <IExecutionTaskContext>();

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

            var scheduler = new BatchScheduler();

            ValueTask Dispatch() => default;

            scheduler.Schedule(Dispatch);
            Assert.True(scheduler.HasTasks);

            // act
            await scheduler.DispatchAsync();

            // assert
            Assert.False(scheduler.HasTasks);
        }
        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);
        }