public async Task GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase_returns_API_data_if_retrieved()
        {
            // Given
            var resource = Builder <ResourceReferenceWithResourceDetails> .CreateNew()
                           .With(r => r.RefId = SingleResourceReferenceId)
                           .And(r => r.AbsentInLearningHub = false)
                           .Build();

            A.CallTo(() => learningHubApiClient.GetResourceByReferenceId(SingleResourceReferenceId))
            .Returns(resource);

            // When
            var result =
                (await learningHubResourceService.GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase(
                     SingleResourceReferenceId
                     )) !;

            // Then
            using (new AssertionScope())
            {
                result.resource.Should().BeEquivalentTo(resource);
                result.resource !.AbsentInLearningHub.Should().BeFalse();
                result.apiIsAccessible.Should().BeTrue();
                A.CallTo(() => learningHubApiClient.GetResourceByReferenceId(SingleResourceReferenceId))
                .MustHaveHappenedOnceExactly();
                A.CallTo(
                    () => learningResourceReferenceDataService.GetResourceReferenceDetailsByReferenceIds(
                        A <IEnumerable <int> > ._
                        )
                    )
                .MustNotHaveHappened();
            }
        }
        GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase_returns_fallback_data_if_API_throws_exception()
        {
            // Given
            var resource = Builder <ResourceReferenceWithResourceDetails> .CreateNew()
                           .With(r => r.RefId = SingleResourceReferenceId)
                           .And(r => r.AbsentInLearningHub = false)
                           .Build();

            A.CallTo(() => learningHubApiClient.GetResourceByReferenceId(SingleResourceReferenceId))
            .Throws(new LearningHubResponseException("exception", HttpStatusCode.Unauthorized));
            A.CallTo(
                () => learningResourceReferenceDataService.GetResourceReferenceDetailsByReferenceIds(
                    A <IEnumerable <int> > ._
                    )
                ).Returns(new List <ResourceReferenceWithResourceDetails> {
                resource
            });

            // When
            var result =
                (await learningHubResourceService.GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase(
                     SingleResourceReferenceId
                     )) !;

            // Then
            using (new AssertionScope())
            {
                result.resource.Should().BeEquivalentTo(resource);
                result.resource !.AbsentInLearningHub.Should().BeFalse();
                result.apiIsAccessible.Should().BeFalse();
                A.CallTo(() => learningHubApiClient.GetResourceByReferenceId(A <int> ._))
                .MustHaveHappenedOnceExactly();
                A.CallTo(
                    () => learningResourceReferenceDataService.GetResourceReferenceDetailsByReferenceIds(
                        A <IEnumerable <int> > .That.IsSameSequenceAs(new[] { SingleResourceReferenceId })
                        )
                    )
                .MustHaveHappenedOnceExactly();
            }
        }