Esempio n. 1
0
        public void BuildProductivities_IntegrationTest()
        {
            var service = GetFakeRaportService();

            var sheetTable = ExcelImporter.GetSheetTable("test.xlsx".AppendAssemblyPath("Contexts\\IntegrationTests"));

            TypeRepository.TryGetPropertyMap(sheetTable, typeof(TestImportModel), out var propertyMap);
            var visitor = new TestImportModelVisitor(_operations);
            var actions = ExcelImporter.GetDataFromTable(sheetTable, propertyMap, new ImportModelConverter <TestImportModel, EmployeeActionBase>(visitor));

            var shortBreaks = new ShortBreakSchedule {
                Duration       = TimeSpan.FromMinutes(10),
                FirstBreakTime = new TimeSpan(9, 55, 0),
                Periodicity    = TimeSpan.FromHours(2)
            };

            var shift = new Shift {
                Lunch = TimeSpan.FromMinutes(30),
            };

            var productivities = service.Build(actions, shortBreaks, shift);

            var employeeProductivity = new EmployeeProductivity(new Employee(), productivities);

            var totalTime = employeeProductivity.GetTotalWorkHours();

            Assert.That(totalTime, Is.GreaterThan(5.7));

            var pause = employeeProductivity.DowntimePeriods.Sum(d => d.Duration.TotalSeconds);

            Assert.That(pause, Is.GreaterThan(16000));
        }
 public IShortBreakInspector GetShortBreakInspector(ShortBreakSchedule shortBreaks)
 {
     if (!_map.ContainsKey(shortBreaks))
     {
         lock ( _locker ) {
             _map[shortBreaks] = new ShortBreakInspector(shortBreaks);
         }
     }
     return(_map[shortBreaks]);
 }
Esempio n. 3
0
        public void BreaksGetter__ReturnsExpected()
        {
            // Arrange:
            var shortBreaks = new ShortBreakSchedule {
                Duration       = TimeSpan.FromMinutes(5),
                FirstBreakTime = new TimeSpan(8, 55, 0),
                Periodicity    = TimeSpan.FromHours(1)
            };

            var expected = new List <(TimeSpan, TimeSpan)>(new (TimeSpan, TimeSpan)[] {
        private ShortBreakSchedule GetShortBreakForSmokers()
        {
            var shortBreak = new ShortBreakSchedule {
                Id            = 2,
                Periodicity   = TimeSpan.FromHours(1),
                Duration      = TimeSpan.FromMinutes(5),
                DayOffsetTime = new TimeSpan(8, 0, 0)
            };

            return(shortBreak);
        }
        public void GetDayPeriods__ShortBreak_DurationGreaterShortBreakUpLimit__Throw()
        {
            var repo = new BreakRepository();

            var shortBreak = new ShortBreakSchedule()
            {
                Duration    = repo.ShortBreakUpLimit + TimeSpan.FromSeconds(1),
                Periodicity = repo.ShortBreakIntervalUpLimit,
            };

            Assert.Catch <ArgumentException>(() => repo.GetDayPeriods(shortBreak));
        }
Esempio n. 6
0
        public void SubstractBreaks__ShipmentActionWhenBreakTime_FirstDowntimeInTime__DowntimesNotEmptyInResult()
        {
            // Arrange:
            var builder           = GetBuilder();
            var momento           = builder.BuildNew();
            var shipmentOperation = new Operation {
                Name = "Packing Operation", Group = OperationGroups.Shipment
            };
            var gatheringOperation = new Operation {
                Name = "Packing Operation", Group = OperationGroups.Gathering
            };

            var shortBreaks = new ShortBreakSchedule {
                Duration       = TimeSpan.FromMinutes(5),
                FirstBreakTime = new TimeSpan(8, 55, 0),
                Periodicity    = TimeSpan.FromHours(1)
            };

            var actions = new EmployeeActionBase[] {
                new ShipmentAction()
                {
                    StartTime = DateTime.Parse("22.02.2019 8:00:00"),
                    Duration  = TimeSpan.FromMinutes(110),
                    Operation = shipmentOperation,
                },

                new DoubleAddressAction()
                {
                    StartTime = DateTime.Parse("22.02.2019 10:10:20"),
                    Duration  = TimeSpan.FromMinutes(55),
                    Operation = gatheringOperation,
                },
            };

            // Action:
            var next    = builder.CheckDuration(actions[1], momento);
            var current = builder.CheckDuration(actions[0], momento);

            builder.CheckPause(current, next, momento);
            builder.SubstractBreaks(shortBreaks, momento);

            // Assert:
            Assert.That(momento.DowntimePeriods, Is.Not.Empty);
        }
Esempio n. 7
0
        public void SubstractBreaks_ActionBreakGreaterBreakTime_DowntimesNotEmptyInResult(string st0, int dur0, string st1)
        {
            // Arrange:
            var builder   = GetBuilder();
            var momento   = builder.BuildNew();
            var operation = new Operation {
                Name = "Packing Operation", Group = OperationGroups.Gathering
            };

            var shortBreaks = new ShortBreakSchedule {
                Duration       = TimeSpan.FromMinutes(5),
                FirstBreakTime = new TimeSpan(8, 55, 0),
                Periodicity    = TimeSpan.FromHours(1)
            };

            var actions = new DoubleAddressAction[] {
                new DoubleAddressAction()
                {
                    StartTime = DateTime.Parse(st0),
                    Duration  = TimeSpan.FromMinutes(dur0),
                    Operation = operation,
                },

                new DoubleAddressAction()
                {
                    StartTime = DateTime.Parse(st1),
                    Duration  = TimeSpan.FromMinutes(55),
                    Operation = operation,
                },
            };

            // Action:
            var next    = builder.CheckDuration(actions[1], momento);
            var current = builder.CheckDuration(actions[0], momento);

            builder.CheckPause(current, next, momento);
            builder.SubstractBreaks(shortBreaks, momento);

            // Assert:
            Assert.That(momento.DowntimePeriods, Is.Not.Empty);
        }
Esempio n. 8
0
 public ShortBreakScheduleViewModel(ShortBreakSchedule shortBreakSchedule)
 {
     _shortBreakSchedule = shortBreakSchedule;
 }
Esempio n. 9
0
        protected virtual (IReadOnlyDictionary <Operation, IProductivity>, HashSet <Period>) BuildProductivities(IEnumerable <EmployeeActionBase> actions, ShortBreakSchedule breaks, Shift shift)
        {
            var actionArr = actions.OrderByDescending(a => a.StartTime).ToArray();

            if (actionArr.Length == 0)
            {
                return(new Dictionary <Operation, IProductivity>(0), new HashSet <Period>());
            }

            var momento = _productivityBuilder.BuildNew();
            var next    = _productivityBuilder.CheckDuration(actionArr[0], momento);

            for (int i = 1; i < actionArr.Length; ++i)
            {
                var current = _productivityBuilder.CheckDuration(actionArr[i], momento);
                next = _productivityBuilder.CheckPause(current, next, momento);
            }

            _productivityBuilder.SubstractBreaks(breaks, momento);
            _productivityBuilder.SubstractLunch(shift, momento);

            return(momento.ProductivityMap, momento.DowntimePeriods);
        }
Esempio n. 10
0
        public Productivity GetProductivity(IEnumerable <EmployeeActionBase> employeeActions, OperationThresholds thresholds, ShortBreakSchedule breaks = null, Shift shift = null)
        {
            foreach (var action in employeeActions)
            {
            }

            throw new NotImplementedException();
        }
Esempio n. 11
0
 public void AddFixedBreaks(ShortBreakSchedule shortBreak)
 {
     PauseBetweenActions.BreakRepository.AddFixedBreak(shortBreak, (e) => !e.IsSmoker ?? false);
 }
Esempio n. 12
0
 public (IReadOnlyDictionary <Operation, IProductivity>, HashSet <Period>) Build(IEnumerable <EmployeeActionBase> actions, ShortBreakSchedule breaks, Shift shift)
 {
     return(BuildProductivities(actions, breaks, shift));
 }