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); }
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); }
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); }
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); }