public void CRUD_Succeeds() { var contact = Retriever.GetAllContacts(_policy).First(); var orgDatastore = new OrganisationsDatastore(DatastoreBaseSetup.OrganisationsDatastore, new Mock <ILogger <OrganisationsDatastore> >().Object, _policy, _config, new Mock <ILongTermCache>().Object); var org = orgDatastore.ById(contact.OrganisationId); var solnDatastore = new SolutionsDatastore(DatastoreBaseSetup.SolutionsDatastore, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config, new Mock <IShortTermCache>().Object, new Mock <IServiceProvider>().Object); var soln = solnDatastore.ByOrganisation(org.Id).First(); var std = Retriever.GetAllStandards(_policy).First(); var claimDatastore = new StandardsApplicableDatastore(DatastoreBaseSetup.StandardsApplicableDatastore, new Mock <ILogger <StandardsApplicableDatastore> >().Object, _policy); var evidenceDatastore = new StandardsApplicableEvidenceDatastore(DatastoreBaseSetup.StandardsApplicableEvidenceDatastore, new Mock <ILogger <StandardsApplicableEvidenceDatastore> >().Object, _policy); var datastore = new StandardsApplicableReviewsDatastore(DatastoreBaseSetup.StandardsApplicableReviewsDatastore, _logger, _policy); var newClaim = Creator.GetStandardsApplicable(solnId: soln.Id, claimId: std.Id, ownerId: contact.Id); var createdClaim = claimDatastore.Create(newClaim); StandardsApplicableReviews createdReview = null; try { var newEvidence = Creator.GetStandardsApplicableEvidence(claimId: createdClaim.Id, createdById: contact.Id); var createdEvidence = evidenceDatastore.Create(newEvidence); // create var newReview = Creator.GetStandardsApplicableReviews(evidenceId: createdEvidence.Id, createdById: contact.Id); createdReview = datastore.Create(newReview); createdReview.Should().BeEquivalentTo(newReview, opts => opts .Excluding(ent => ent.CreatedOn)); // retrieve ById datastore.ById(createdReview.Id) .Should().NotBeNull() .And.Subject .Should().BeEquivalentTo(createdReview, opts => opts .Excluding(ent => ent.CreatedOn)); // retrieve ByEvidence var retrievedReviews = datastore.ByEvidence(createdEvidence.Id) .SelectMany(x => x).ToList(); retrievedReviews.Should().ContainSingle() .And.Subject.Single() .Should().BeEquivalentTo(createdReview, opts => opts .Excluding(ent => ent.CreatedOn)); } finally { claimDatastore.Delete(createdClaim); } // delete datastore.ById(createdReview.Id) .Should().BeNull(); }
public void Setup() { _solutionDatastore = new SolutionsDatastore(DatastoreBaseSetup.SolutionsDatastore, new Mock<ILogger<SolutionsDatastore>>().Object, _policy, _config, new Mock<IShortTermCache>().Object, new Mock<IServiceProvider>().Object); _technicalContactDatastore = new TechnicalContactsDatastore(DatastoreBaseSetup.TechnicalContactsDatastore, new Mock<ILogger<TechnicalContactsDatastore>>().Object, _policy); _claimedCapabilityDatastore = new CapabilitiesImplementedDatastore(DatastoreBaseSetup.CapabilitiesImplementedDatastore, new Mock<ILogger<CapabilitiesImplementedDatastore>>().Object, _policy); _claimedCapabilityEvidenceDatastore = new CapabilitiesImplementedEvidenceDatastore(DatastoreBaseSetup.CapabilitiesImplementedEvidenceDatastore, new Mock<ILogger<CapabilitiesImplementedEvidenceDatastore>>().Object, _policy); _claimedCapabilityReviewsDatastore = new CapabilitiesImplementedReviewsDatastore(DatastoreBaseSetup.CapabilitiesImplementedReviewsDatastore, new Mock<ILogger<CapabilitiesImplementedReviewsDatastore>>().Object, _policy); _claimedStandardDatastore = new StandardsApplicableDatastore(DatastoreBaseSetup.StandardsApplicableDatastore, new Mock<ILogger<StandardsApplicableDatastore>>().Object, _policy); _claimedStandardEvidenceDatastore = new StandardsApplicableEvidenceDatastore(DatastoreBaseSetup.StandardsApplicableEvidenceDatastore, new Mock<ILogger<StandardsApplicableEvidenceDatastore>>().Object, _policy); _claimedStandardReviewsDatastore = new StandardsApplicableReviewsDatastore(DatastoreBaseSetup.StandardsApplicableReviewsDatastore, new Mock<ILogger<StandardsApplicableReviewsDatastore>>().Object, _policy); _datastore = new SolutionsExDatastore(DatastoreBaseSetup.SolutionsExDatastore, _logger, _policy, _config, new Mock<IShortTermCache>().Object, new Mock<IServiceProvider>().Object); var soln = Retriever.GetAllSolutions(_policy).First(); _solnOrig = _datastore.BySolution(soln.Id); _solnEx = _solnOrig.Clone(); }