Exemple #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));
        }