Example #1
0
        public void EventStatus_ReturnCorrectEventStatus_WhenEventTypeIsClockStoppingEvent()
        {
            //Arrange
            var completedEvent = new ClockStoppingCompletedEvent
            {
                Name = new EventName {
                    Code = EventCode.PathwayCompletion
                },
                EventDate = new DateTime(2014, 8, 10)
            };

            //Act
            var result = completedEvent.EventStatus;

            //Assert
            Assert.AreEqual(EventStatus.Closed, result);
        }
Example #2
0
        public void Validate_DoesNotRaiseValidationFailedEvent_WhenClockStopsAndEventPathwayCompletion()
        {
            //Arrange
            var completedEvent = new ClockStoppingCompletedEvent {
                Name = new EventName {
                    Code = EventCode.PathwayCompletion
                }, Period = new RTT18WeekPeriod {
                    Name = "period 1", Pathway = new Pathway {
                        PPINumber = "ppi"
                    }
                }
            };
            var eventRaised = false;

            completedEvent.ValidationFailed += delegate { eventRaised = true; };

            //Act
            completedEvent.Validate();

            //Assert
            Assert.IsFalse(eventRaised);
        }
Example #3
0
        public void Validate_RaisesValidationFailedEvent_WhenClockStopsAndEventOtherThanPathwayCompletion()
        {
            //Arrange
            var completedEvent = new ClockStoppingCompletedEvent {
                Name = new EventName {
                    Code = EventCode.DiagnosticsOrderPlaced
                }, 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.IsNotNull(eventRaised);
        }
Example #4
0
        public void Validate_RaisesValidationFailedEvent_WhenClockStopsAndEventOtherThanInpatientDischarged()
        {
            //Arrange
            var completedEvent = new ClockStoppingCompletedEvent {
                Name = new EventName {
                    Code = EventCode.PatientAddedToInpatientWaitingList
                }, Period = new RTT18WeekPeriod {
                    Name = "period 1", Pathway = new Pathway {
                        PPINumber = "ppi"
                    }
                }
            };
            var eventRaised = false;

            completedEvent.ValidationFailed += delegate { eventRaised = true; };

            //Act
            completedEvent.Validate();

            //Assert
            Assert.IsTrue(eventRaised);
        }
Example #5
0
        public void Validate_DoesNotRaiseValidationFailedEvent_WhenClockStopsAndEventOutpatientDischarged()
        {
            //Arrange
            var completedEvent = new ClockStoppingCompletedEvent {
                Name = new EventName {
                    Code = EventCode.OutpatientDischarged
                }, 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()
 {
     _clockStoppingCompletedEvent = new ClockStoppingCompletedEvent {
         EventDate = new DateTime(2000, 12, 25)
     };
 }
Example #7
0
        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);
        }