public void Handle(AccessionNumberChangedEvent e) { var study = _studyRepository.GetById(e.StudyId); 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()); }
public void Apply(AccessionNumberChangedEvent e) { _accessionNumber = e.AccessionNumber; }