private void AddPeriodToPathway(Pathway pathway, Period period, UnitOfWork unitOfWork) { pathway.ValidationFailed += ruleViolation => { ruleViolation.CreatedAt = DateTime.UtcNow; unitOfWork.RuleViolations.Add(ruleViolation); }; pathway.Add(period); }
public void Add_DoesNotRaiseValidationFailedEvent_WhenAllPreviousPeriodsAreInactive() { //Arrange var pathway = new Pathway { PPINumber = "123" }; pathway.Add(new RTT18WeekPeriod { Name = "p2", IsActive = false, StopDate = new DateTime(2014, 4, 3), Pathway = new Pathway { PPINumber = "ppi" } }); pathway.Add(new RTT18WeekPeriod { Name = "p3", IsActive = false, StopDate = new DateTime(2014, 4, 3), Pathway = new Pathway { PPINumber = "ppi" } }); pathway.Add(new RTT18WeekPeriod { Name = "p4", IsActive = false, StopDate = new DateTime(2014, 4, 3), Pathway = new Pathway { PPINumber = "ppi" } }); RuleViolation eventRaised = null; pathway.ValidationFailed += delegate { eventRaised = new RuleViolation(); }; var period = new RTT18WeekPeriod { Name = "p1", IsActive = true, Pathway = new Pathway { PPINumber = "ppi" } }; //Act pathway.Add(period); //Assert Assert.IsNull(eventRaised); }