Exemplo n.º 1
0
        public void Get_NotStarted_ThrowsInvalidJobOperationException()
        {
            // Arrange
            using IJobManager jobManager = TestHelper.CreateJobManager(false);

            // Act
            var ex = Assert.Throws <InvalidJobOperationException>(() => jobManager.Get("my-job"));

            // Assert
            Assert.That(ex.Message, Is.EqualTo($"'{typeof(IJobManager).FullName}' not started."));
        }
Exemplo n.º 2
0
        public void Get_BadJobName_ThrowsArgumentException(string badJobName)
        {
            // Arrange
            using IJobManager jobManager = TestHelper.CreateJobManager(true);

            // Act
            var ex = Assert.Throws <ArgumentException>(() => jobManager.Get(badJobName));

            // Assert
            Assert.That(ex.Message, Does.StartWith("Job name cannot be null or empty."));
            Assert.That(ex.ParamName, Is.EqualTo("jobName"));
        }
Exemplo n.º 3
0
        public void Get_NonExistingJobName_ThrowsInvalidJobOperationException()
        {
            // Arrange
            using IJobManager jobManager = TestHelper.CreateJobManager(true);

            jobManager.Create("job1");
            jobManager.Create("job2");

            // Act
            var ex = Assert.Throws <InvalidJobOperationException>(() => jobManager.Get("non-existing"));

            // Assert
            Assert.That(ex.Message, Is.EqualTo("Job not found: 'non-existing'."));
        }
Exemplo n.º 4
0
        public void Get_Started_ReturnsJob()
        {
            // Arrange
            using IJobManager jobManager = TestHelper.CreateJobManager(false);
            jobManager.Start();
            var job1 = jobManager.Create("job1");
            var job2 = jobManager.Create("job2");

            // Act
            var gotJob1 = jobManager.Get("job1");

            // Assert
            Assert.That(gotJob1, Is.SameAs(job1));
        }
Exemplo n.º 5
0
        public void Get_Disposed_ThrowsJobObjectDisposedException()
        {
            // Arrange
            using IJobManager jobManager = TestHelper.CreateJobManager(true);

            jobManager.Create("job1");
            jobManager.Create("job2");
            jobManager.Dispose();

            // Act
            var ex = Assert.Throws <JobObjectDisposedException>(() => jobManager.Get("job1"));

            // Assert
            Assert.That(ex.Message, Is.EqualTo($"'{typeof(IJobManager).FullName}' is disposed."));
            Assert.That(ex.ObjectName, Is.EqualTo(typeof(IJobManager).FullName));
        }