コード例 #1
0
ファイル: EventMilestoneTests.cs プロジェクト: Minoxsys/CPMS
        public void GetRemainingDays_ReturnsComputedDaysNumber_WhenBreachDateIsNotNull()
        {
            // Arrange
            var period = new RTT18WeekPeriod();

            period.Add(new ClockStartingCompletedEvent
            {
                EventDate  = new DateTime(2014, 7, 1),
                TargetDate = new DateTime(2014, 7, 1)
            });
            var @event = new ClockTickingCompletedEvent
            {
                Period    = period,
                EventDate = new DateTime(2014, 7, 1)
            };
            var eventMilestone = new EventMilestone
            {
                TargetNumberOfDays     = 3,
                DateReferenceForTarget = new DateTime(2014, 7, 1),
                Id             = 1,
                CompletedEvent = @event
            };


            // Act
            var result = eventMilestone.GetDaysToBreachAt(new DateTime(2014, 7, 6));

            // Assert
            Assert.AreEqual(-2, result);
        }
コード例 #2
0
        private bool IsEventMilestoneMatched(EventMilestone eventMilestone, PeriodEventsFilterInputInfo periodEventsFilterInput)
        {
            if ((periodEventsFilterInput == null))
            {
                return(true);
            }
            var daysToBreachAt          = eventMilestone.GetDaysToBreachAt(_clock.TodayDate);
            var isEventMilestoneMatched = (String.IsNullOrEmpty(periodEventsFilterInput.Specialty) || eventMilestone.CompletedEvent.Clinician.Specialty.Name.ToLowerInvariant().Contains(periodEventsFilterInput.Specialty.ToLowerInvariant())) &&
                                          (periodEventsFilterInput.TargetYear == null || (eventMilestone.BreachDate != null && eventMilestone.BreachDate.Value.Year == periodEventsFilterInput.TargetYear)) &&
                                          (periodEventsFilterInput.ActualYear == null) &&
                                          (string.IsNullOrEmpty(periodEventsFilterInput.EventDescription) || eventMilestone.Name.Description.Contains(periodEventsFilterInput.EventDescription));

            if (periodEventsFilterInput.Breaches == null)
            {
                return(isEventMilestoneMatched);
            }
            if (daysToBreachAt == null)
            {
                return(false);
            }
            if (periodEventsFilterInput.Breaches < 0)
            {
                return(isEventMilestoneMatched && (((int)daysToBreachAt) < 0));
            }
            if (periodEventsFilterInput.Breaches == FourDaysToBreach)
            {
                return(isEventMilestoneMatched && (((int)daysToBreachAt) >= FourDaysToBreach));
            }
            return(isEventMilestoneMatched && daysToBreachAt == periodEventsFilterInput.Breaches);
        }
コード例 #3
0
ファイル: EventMilestoneTests.cs プロジェクト: Minoxsys/CPMS
        public void GetRemainingDays_ReturnsNull_WhenBreachDateIsNull()
        {
            // Arrange
            var eventMilestone = new EventMilestone
            {
                TargetNumberOfDays     = null,
                DateReferenceForTarget = new DateTime(2014, 7, 1),
                Id = 1
            };

            // Act
            var result = eventMilestone.GetDaysToBreachAt(new DateTime(2014, 7, 6));

            // Assert
            Assert.IsNull(result);
        }