public void Validate_RaisesValidationFailedEvent_WhenPatientIsAChildAndDoesNotAttendForTheSecondTimeAndPeriodIsNotStopped() { // Arrange var period = new RTT18WeekPeriod { Pathway = new Pathway { Patient = new Patient { DateOfBirth = new DateTime(1990, 3, 5) } } }; var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.DidNotAttend }, EventDate = new DateTime(2001, 1, 8), Period = period }; period.Add(new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.DidNotAttend }, EventDate = new DateTime(2001, 1, 9) }); var eventRaised = false; completedEvent.ValidationFailed += delegate { eventRaised = true; }; // Act completedEvent.Validate(); // Assert Assert.IsTrue(eventRaised); }
public void Validate_RaisesValidationFailedEvent_WhenHospitalCancelsEventAndPeriodIsPaused() { // Arrange var period = new RTT18WeekPeriod { Pathway = new Pathway { Patient = new Patient { DateOfBirth = new DateTime(1980, 3, 5) } } }; var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.HospitalCancelEvent }, EventDate = new DateTime(2001, 1, 8), Period = period }; var eventRaised = false; completedEvent.ValidationFailed += delegate { eventRaised = true; }; // Act completedEvent.Validate(); // Assert Assert.IsTrue(eventRaised); }
public void PostBreachDays_ReturnsNull_WhenTargetDateIsNull() { //Arrange var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.InpatientTCIOffer }, EventDate = new DateTime(2014, 8, 10) }; //Act var result = completedEvent.PostBreachDays; //Assert Assert.AreEqual(null, result); }
public void EventStatus_ReturnCorrectEventStatus_WhenEventTypeIsClockPausingEvent() { //Arrange var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.InpatientTCIOffer }, EventDate = new DateTime(2014, 8, 10), TargetDate = new DateTime(2014, 8, 9) }; //Act var result = completedEvent.EventStatus; //Assert Assert.AreEqual(EventStatus.Paused, result); }
public void PostBreachDays_ReturnsCorrectNumberOfDays_WhenEventDateHappensAfterTargetDate() { //Arrange var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.InpatientTCIOffer }, EventDate = new DateTime(2014, 8, 12), TargetDate = new DateTime(2014, 8, 9) }; //Act var result = completedEvent.PostBreachDays; //Assert Assert.AreEqual(3, result); }
public void Validate_RaisesValidationFailedEvent_WhenCancerPeriodAndEventPausesPeriod() { // Arrange var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.InpatientTCIOffer }, EventDate = new DateTime(2014, 12, 26), Period = new CancerPeriod { Name = "period 1", Pathway = new Pathway { PPINumber = "ppi" } } }; var eventRaised = false; completedEvent.ValidationFailed += delegate { eventRaised = true; }; // Act completedEvent.Validate(); // Assert Assert.IsTrue(eventRaised); }
public void Validate_DoesNotRaiseValidationFailedEvent_WhenClockPausesAndEventInpatientTciAgreed() { //Arrange var completedEvent = new ClockPausingCompletedEvent { Name = new EventName { Code = EventCode.InpatientTCIOffer }, Period = new RTT18WeekPeriod { Name = "period 1", Pathway = new Pathway { PPINumber = "ppi" } } }; RuleViolation eventRaised = null; completedEvent.ValidationFailed += delegate { eventRaised = new RuleViolation(); }; //Act completedEvent.Validate(); //Assert Assert.IsNull(eventRaised); }
public void PerTestSetup() { _clockPausingCompletedEvent = new ClockPausingCompletedEvent { EventDate = new DateTime(2000, 12, 25) }; }
private CompletedEvent BuildCompletedEvent(ClockType clockType, EventCode eventCode, DateTime eventDate, Period period) { CompletedEvent newCompletedEvent; if (eventCode == EventCode.PatientCancelEvent && period.IsSecondCancelByPatient(EventCode.PatientCancelEvent)) { newCompletedEvent = new ClockStoppingCompletedEvent(); } else { if (eventCode == EventCode.HospitalCancelEvent) { newCompletedEvent = new ClockTickingCompletedEvent(); } else { if (eventCode == EventCode.DidNotAttend && (period.IsSecondDidNotAttend(eventCode) && period.Pathway.Patient.IsChild(eventDate) || period.IsSecondDidNotAttend(eventCode) && period.AbleToNotAttendFirstEvent || !(period.Pathway.Patient.IsChild(eventDate) || period.AbleToNotAttendFirstEvent))) { newCompletedEvent = new ClockStoppingCompletedEvent(); } else { switch (clockType) { case ClockType.ClockStarting: { newCompletedEvent = new ClockStartingCompletedEvent(); break; } case ClockType.ClockTicking: { newCompletedEvent = new ClockTickingCompletedEvent(); break; } case ClockType.ClockPausing: { newCompletedEvent = new ClockPausingCompletedEvent(); break; } case ClockType.ClockStopping: { newCompletedEvent = new ClockStoppingCompletedEvent(); break; } default: { newCompletedEvent = new ClockTickingCompletedEvent(); break; } } } } } return(newCompletedEvent); }