public void Handle(StudyCreatedEvent e) { var study = new Study(); study.Apply(e); _studyRepository.Save(study); }
public void InvalidDoesNotStartsWithTest() { var target = new PrefixAccessionNumberValidationRule(); target.Option = PrefixAccessionNumberValidationRule.PrefixOption.DoesNotStartWith; target.Prefix = "abc123"; string accessionNumber = "abc123xyz456"; AccessionNumberChangedEvent e = new AccessionNumberChangedEvent(Guid.NewGuid(), accessionNumber); Study study = new Study(); study.Apply(e); // ensure a validation exception Assert.True(target.Validate(study).Count() == 1); }
public void ValidStartsWithTest() { var target = new PrefixAccessionNumberValidationRule(); target.Option = PrefixAccessionNumberValidationRule.PrefixOption.StartsWith; target.Prefix = "abc123"; string accessionNumber = "abc123xyz456"; AccessionNumberChangedEvent e = new AccessionNumberChangedEvent(Guid.NewGuid(), accessionNumber); Study study = new Study(); study.Apply(e); // ensure no validation exceptions Assert.False(target.Validate(study).Any()); }