コード例 #1
0
        private static JobSpy MakeJobSpy(string name)
        {
            JobSpy jobSpy = new JobSpy {
                Name = name
            };

            return(jobSpy);
        }
コード例 #2
0
        public void GivenProjectWithJob__WhenAddingJobWithSameName__ShouldThrowDuplicateJobNameException()
        {
            JobSpy jobSpy = MakeJobSpy("job");

            Assert.IsNotNull(_sut != null, nameof(_sut) + " != null");
            _sut.AddJob(jobSpy);
            _sut.AddJob(MakeJobSpy("job"));
        }
コード例 #3
0
        public async Task GivenProjectWithNamedJob__WhenCallingRunWithJobName__ShouldRunJob()
        {
            JobSpy jobSpy = MakeJobSpy("job");

            _sut.AddJob(jobSpy);

            await _sut.RunJobAsync("job");

            AssertJobWasRun(jobSpy);
        }
コード例 #4
0
        public void GivenProjectWithMultipleJobs__WhenCallingRunAll__AllJobsRan()
        {
            JobSpy job1 = MakeJobSpy("job1");

            _sut.AddJob(job1);
            JobSpy job2 = MakeJobSpy("job2");

            _sut.AddJob(job2);

            Task.WaitAll(_sut.RunAllJobsAsync().ToArray());

            AssertJobWasRun(job1);
            AssertJobWasRun(job2);
        }
コード例 #5
0
        GivenProjectWithTwoJobs__WhenCallingRunWithJobName__ShouldOnlyRunWithMatchingName()
        {
            JobSpy otherJob = MakeJobSpy("other");

            _sut.AddJob(otherJob);
            JobSpy expected = MakeJobSpy("job");

            _sut.AddJob(expected);

            await _sut.RunJobAsync("job");

            AssertJobWasRun(expected);
            AssertJobWasNotRun(otherJob);
        }
コード例 #6
0
 private static void AssertJobWasRun(JobSpy jobSpy)
 {
     Assert.IsNotNull(jobSpy != null, nameof(jobSpy) + " != null");
     Assert.IsTrue(jobSpy.WasRun, $"Job {jobSpy.Name} should have been run, but wasn't.");
 }
コード例 #7
0
 private static void AssertJobWasNotRun(JobSpy otherJob)
 {
     Assert.IsNotNull(otherJob != null, nameof(otherJob) + " != null");
     Assert.IsFalse(otherJob.WasRun, $"Should not have run Job {otherJob.Name}, but did.");
 }