public void GetResourceReferenceDetailsByReferenceIds_gets_expected_records() { using var transaction = new TransactionScope(); // Given var resourceReferenceIds = new[] { 1, 2, 3 }; var expectedFirstResourceDetails = new LearningResourceReference { Id = 1, ResourceRefId = 2, AdminId = 7, OriginalResourceName = "Resource 1", ResourceLink = "www.resource1.com", OriginalDescription = "description 1", OriginalResourceType = "resource type 1", OriginalCatalogueName = "catalogue 1", OriginalRating = 1, }; testHelper.InsertLearningResourceReference( expectedFirstResourceDetails.Id, expectedFirstResourceDetails.ResourceRefId, expectedFirstResourceDetails.AdminId, expectedFirstResourceDetails.OriginalResourceName, expectedFirstResourceDetails.ResourceLink, expectedFirstResourceDetails.OriginalDescription, expectedFirstResourceDetails.OriginalResourceType, expectedFirstResourceDetails.OriginalCatalogueName, expectedFirstResourceDetails.OriginalRating ); testHelper.InsertLearningResourceReference( 2, 3, 7, "Resource 2" ); // When var result = service.GetResourceReferenceDetailsByReferenceIds(resourceReferenceIds).ToList(); // Then using (new AssertionScope()) { result.Should().HaveCount(2); result.First().RefId.Should().Be(expectedFirstResourceDetails.ResourceRefId); result.First().Title.Should().Be(expectedFirstResourceDetails.OriginalResourceName); result.First().Link.Should().Be(expectedFirstResourceDetails.ResourceLink); result.First().Description.Should().Be(expectedFirstResourceDetails.OriginalDescription); result.First().ResourceType.Should().Be(expectedFirstResourceDetails.OriginalResourceType); result.First().Catalogue.Name.Should().Be(expectedFirstResourceDetails.OriginalCatalogueName); result.First().Rating.Should().Be(expectedFirstResourceDetails.OriginalRating); result[1].RefId.Should().Be(3); } }
public async Task GetResourceByReferenceId_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.GetResourceByReferenceId(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(); } }