Esempio n. 1
0
        public void Should_remove_finished_wait_task_and_launch_a_send_job()
        {
            var waitJobTask = Task.FromResult(new WaitingJobResult(job));

            state.WaitingJobs.Add(Task.CompletedTask);
            state.WaitingJobs.Add(waitJobTask);
            state.WaitingJobs.Add(Task.CompletedTask);

            handler.HandleCompletedJob(waitJobTask, state);

            state.WaitingJobs.Should().HaveCount(2);
            state.WaitingJobs.Should().NotContain(waitJobTask);

            launcher.Received(1).LaunchSendJob(job, state);
        }
        public void Should_add_and_launch_wait_jobs_for_missing_states()
        {
            state.AllJobs[state2.Name] = Substitute.For <IStreamJob>();

            synchronizer.Synchronize(state);

            state.AllJobs.Should().HaveCount(3);
            state.AllJobs.Keys.Should().BeEquivalentTo("state1", "state2", "state3");

            jobFactory.ReceivedCalls().Should().HaveCount(2);
            jobFactory.Received(1).CreateJob(state1);
            jobFactory.Received(1).CreateJob(state3);

            jobLauncher.ReceivedCalls().Should().HaveCount(2);
            jobLauncher.Received(1).LaunchWaitJob(state.AllJobs[state1.Name], state);
            jobLauncher.Received(1).LaunchWaitJob(state.AllJobs[state3.Name], state);
        }