public async Task GetLatestJobForSpecification_Called_ReturnsJobSummary()
        {
            string specificationId = "1234";
            string jobType         = "3456";
            string jobId           = "5678";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            string[] jobTypes = new string[]
            {
                jobType
            };

            IDictionary <string, JobSummary> jobSummary = new Dictionary <string, JobSummary> {
                { string.Empty, new JobSummary {
                      JobId = jobId
                  } }
            };
            ApiResponse <IDictionary <string, JobSummary> > jobSummaryApiResponse = new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.OK, jobSummary);

            jobsApiClient
            .GetLatestJobsForSpecification(specificationId, jobTypes)
            .Returns(jobSummaryApiResponse);

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

            //Act
            IDictionary <string, JobSummary> result = await jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes);

            Assert.AreEqual(result, jobSummary);

            await jobsApiClient
            .Received(1)
            .GetLatestJobsForSpecification(specificationId, jobTypes);
        }
        public void GetLatestJobForSpecification_UnsuccessfulApiResponse_ThrowsJobsNotRetrievedException()
        {
            string specificationId = "1234";
            string jobType         = "3456";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            string[] jobTypes = new string[]
            {
                jobType
            };

            string message = $"Error while retrieving latest jobs for Specifiation: {specificationId} and JobTypes: {string.Join(',', jobTypes)}";

            ApiResponse <IDictionary <string, JobSummary> > jobSummaryApiResponse = new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.BadRequest);

            jobsApiClient
            .GetLatestJobsForSpecification(specificationId, jobTypes)
            .Returns(jobSummaryApiResponse);

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

            //Act
            Func <Task> invocation = async() => await jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes);

            //Arrange
            invocation.Should()
            .Throw <JobsNotRetrievedException>()
            .WithMessage(message);
        }