public void ShouldCreateANewConsentRecord() { Assert.NotNull(CreatedConsent); Assert.Equal(StudyId, CreatedConsent.StudySubject.StudyId); Assert.Same(StudySubject, CreatedConsent.StudySubject); Assert.Equal(StudySubject.PersonId, CreatedConsent.GivenByPersonId); Assert.Equal(2.January(1837), CreatedConsent.DateGiven); Assert.Equal(Evidences.MedwayEvidence(takenBy: "Peter Crowther"), CreatedConsent.GivenEvidence.Single()); }
public void StoresConsentGivenEvidenceWhenAddingConsent() { var subjectIdentifier = Random.String(); var(personId, _, studySubject) = CreateStudySubject(subjectIdentifier); var dateGiven = Random.Date().Date; var evidence = Evidences.MedwayEvidence(competencyStatus: "Competent", takenBy: "Nurse Randall"); var marshalledEvidence = new CompositeIdentifierXmlMarshaller <Evidence, EvidenceDefinition>(KnownEvidence.Medway) .MarshallToXml(evidence) .ToString(SaveOptions.DisableFormatting); var consent = CreateConsentRepository(updateContext) .AddConsent( new Common.Consent.Consent(studySubject, dateGiven, personId, new [] { evidence }) ); updateContext.SaveChanges(); var savedConsent = readContext.Set <ConsentEntity>().AsNoTracking() .Where(_ => _.Id == consent.Id) .Include(_ => _.GivenEvidence) .SingleOrDefault(); savedConsent.Should().NotBeNull(); savedConsent.GivenEvidence.Should().ContainSingle(); var storedEvidence = savedConsent.GivenEvidence.SingleOrDefault(); storedEvidence.Should().NotBeNull().And.BeOfType <GivenEvidenceEntity>(); Assert.Equal(KnownEvidence.Medway.SystemName, storedEvidence.Type); Assert.Equal(marshalledEvidence, storedEvidence.Value); Assert.NotNull(storedEvidence.Consent); }