public void TryQueueJob_ThrowsJobsNotCreatedExceptionIfApiResponseNull()
        {
            string specificationId = "1234";

            JobManagement jobManagement = new JobManagement(Substitute.For <IJobsApiClient>(),
                                                            Logger.None,
                                                            new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            },
                                                            Substitute.For <IMessengerService>());

            Func <Task <JobCreateResult> > invocation = () => jobManagement.TryQueueJob(new JobCreateModel
            {
                SpecificationId = specificationId
            });

            invocation
            .Should()
            .Throw <JobsNotCreatedException>();
        }
        public async Task TryQueueJob_Called_ReturnsJobCreateResult()
        {
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            JobCreateModel createModel = new JobCreateModel();

            JobCreateResult expectedCreateResult = new JobCreateResult();

            IEnumerable <JobCreateModel> createModels =
                new []
            {
                createModel
            };

            jobsApiClient
            .TryCreateJobs(Arg.Is <IEnumerable <JobCreateModel> >(_ => _.SequenceEqual(createModels)))
            .Returns(new ApiResponse <IEnumerable <JobCreateResult> >(HttpStatusCode.OK, new[]
            {
                expectedCreateResult
            }));

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            JobCreateResult actualResult = await jobManagement.TryQueueJob(createModel);

            actualResult
            .Should()
            .BeSameAs(expectedCreateResult);
        }