コード例 #1
0
        public void MeasureAvailabilityWithPartialEnd()
        {
            var(_, product, _, feature) = TestDataFactory.BuildCustomerProductJourneyFeature();
            var source = TestDataFactory.BuildSource(product);

            var sourceItemA = SourceEntity.Factory.CreateItemsFromRange(source,
                                                                        OwlveyCalendar.January201908,
                                                                        OwlveyCalendar.January201914,
                                                                        900, 1000, DateTime.Now, "test", SourceGroupEnum.Availability);

            foreach (var item in sourceItemA)
            {
                source.SourceItems.Add(item);
            }

            var aggregate = new SourceDailyAggregate(source,
                                                     new Core.Values.DatePeriodValue(
                                                         OwlveyCalendar.January201910,
                                                         OwlveyCalendar.January201920));

            var result = aggregate.MeasureAvailability();

            Assert.Equal(5, result.Count());
            Assert.Equal(0.902M, result.First().Measure.Availability);
        }
コード例 #2
0
        public void MeasureAvailabilityNotMinusOne()
        {
            var(_, product, _, feature) = TestDataFactory.BuildCustomerProductJourneyFeature();
            var source = TestDataFactory.BuildSource(product);

            var indicator = IndicatorEntity.Factory.Create(feature, source, DateTime.Now, "test");

            var sourceItemA = SourceEntity.Factory.CreateItemsFromRange(source,
                                                                        OwlveyCalendar.StartJuly2019,
                                                                        OwlveyCalendar.EndJuly2019,
                                                                        3900223, 3911869, DateTime.Now, "test", SourceGroupEnum.Availability);

            foreach (var item in sourceItemA)
            {
                source.SourceItems.Add(item);
            }

            var aggregate = new SourceDailyAggregate(source,
                                                     new Core.Values.DatePeriodValue(
                                                         OwlveyCalendar.StartJuly2019,
                                                         OwlveyCalendar.EndJuly2019));

            var availabilities = aggregate.MeasureAvailability();

            Assert.Equal(31, availabilities.Count());
            foreach (var item in availabilities)
            {
                Assert.NotEqual(-1, item.Measure.Availability);
            }
        }
コード例 #3
0
        public void MeasureAvailabilityNoDataFirstDates()
        {
            var(_, product, _, feature) = TestDataFactory.BuildCustomerProductJourneyFeature();
            var source = TestDataFactory.BuildSource(product);

            var indicator = IndicatorEntity.Factory.Create(feature, source, DateTime.Now, "test");

            var sourceItemA = SourceEntity.Factory.CreateItem(source,
                                                              OwlveyCalendar.January201905, 900, 1200, DateTime.Now, "test", SourceGroupEnum.Availability);
            var sourceItemB = SourceEntity.Factory.CreateItem(source,
                                                              OwlveyCalendar.EndJanuary2019,
                                                              900, 1200, DateTime.Now, "test", SourceGroupEnum.Availability);

            source.SourceItems.Add(sourceItemA);
            source.SourceItems.Add(sourceItemB);

            var aggregate = new SourceDailyAggregate(indicator.Source,
                                                     new Core.Values.DatePeriodValue(
                                                         OwlveyCalendar.StartJanuary2019,
                                                         OwlveyCalendar.EndJanuary2019));

            var availabilities = aggregate.MeasureAvailability();

            Assert.Equal(2, availabilities.Count());
            Assert.Equal(0.75m, availabilities.ElementAt(0).Measure.Availability);
            Assert.Equal(0.75m, availabilities.ElementAt(1).Measure.Availability);
        }
コード例 #4
0
        public void MeasureAvailabilityEmpty()
        {
            var(_, product, _, feature) = TestDataFactory.BuildCustomerProductJourneyFeature();
            var source = TestDataFactory.BuildSource(product);

            var indicator = IndicatorEntity.Factory.Create(feature, source, DateTime.Now, "test");

            var aggregate = new SourceDailyAggregate(
                indicator.Source,
                new Core.Values.DatePeriodValue(
                    OwlveyCalendar.StartJanuary2019,
                    OwlveyCalendar.EndJanuary2019));

            var availabilities = aggregate.MeasureAvailability();

            Assert.Empty(availabilities);
        }