示例#1
0
        public void Execute_When_Action_Returns_True_And_Job_Update_Returns_True()
        {
            // Arrange
            var job = new Job
            {
                Id = Fake.Random.Long()
            };

            var jobReadConductorMock = new Mock <IRepositoryReadConductor <Job> >();

            jobReadConductorMock
            .Setup((e => e.FindById(It.IsAny <long>())))
            .ReturnsGivenResult(job);

            var jobUpdateConductorMock = new Mock <IRepositoryUpdateConductor <Job> >();

            jobUpdateConductorMock
            .Setup((e => e.Update(It.IsAny <Job>(), null)))
            .ReturnsGivenResult(true);

            var worker = new WorkerImplementation(
                jobReadConductorMock.Object,
                jobUpdateConductorMock.Object,
                (x) => true
                );

            // Act
            var result = worker.Execute(job.Id, null);

            // Assert
            result.ResultObject.ShouldBeTrue();
        }
示例#2
0
        public void Execute_Throws_Error_When_Job_Read_Conductor_Returns_Error()
        {
            // Arrange
            var jobId = Fake.Random.Long();

            var jobReadConductorMock = new Mock <IRepositoryReadConductor <Job> >();

            jobReadConductorMock
            .Setup((e => e.FindById(It.IsAny <long>())))
            .ReturnsBasicErrorResult();

            var worker = new WorkerImplementation(
                jobReadConductor: jobReadConductorMock.Object,
                jobUpdateConductor: null,
                actionExpression: null
                );

            // Act
            var ex = Record.Exception(() => worker.Execute(jobId, null));

            // Assert
            ex.ShouldNotBeNull();
        }