Beispiel #1
0
        public void CreateStatisticTableRow_GoodCase_ReturnsCorrectTableRow()
        {
            var trainingDate = new DateTime(2021, 3, 1);
            var session1     = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(0, 0, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(4, 0, 0)
            };
            var session2 = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(4, 00, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(24, 00, 0)
            };
            var          sessions            = new[] { session1, session2 };
            const string expectedPlannedTime = "24:00";
            var          expectedTableRow    = new StatisticTableRow
            {
                Simulator        = SimulatorName,
                NumberOfSessions = sessions.Length,
                PlannedTime      = expectedPlannedTime,
                AchievedTime     = expectedPlannedTime
            };

            var result = StatisticTableRow.CreateStatisticTableRow(SimulatorName, sessions);

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedTableRow, result);
        }
Beispiel #2
0
        public void GetSessionsStatistic_GoodCase_ReturnsCorrectStatistic()
        {
            var trainingDate = new DateTime(2021, 3, 1);
            var session      = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(8, 0, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(12, 0, 0)
            };
            var simulators = new List <string> {
                SimulatorName
            };
            const string expectedSessionTime = "04:00";
            var          expectedStatistic   = new StatisticTableRow
            {
                Simulator        = SimulatorName,
                NumberOfSessions = 1,
                PlannedTime      = expectedSessionTime,
                AchievedTime     = expectedSessionTime
            };
            var docWriterMock    = new Mock <IDocumentsWriter>();
            var documentsService = new DocumentsService(docWriterMock.Object);

            var statistic = documentsService.GetSessionsStatistic(new[] { session }, simulators).ToArray();

            Assert.AreEqual(1, statistic.Length);
            Assert.AreEqual(expectedStatistic, statistic[0]);
        }
        public IEnumerable <StatisticTableRow> GetSessionsStatistic(
            IReadOnlyCollection <TrainingSession> sessions,
            IReadOnlyCollection <string> simulators)
        {
            var statisticTableRows = new List <StatisticTableRow>();

            foreach (var simulator in simulators)
            {
                var simulatorSessions = sessions
                                        .Where(ses => ses.Simulator == simulator)
                                        .ToArray();
                statisticTableRows.Add(StatisticTableRow.CreateStatisticTableRow(simulator, simulatorSessions));
            }

            return(statisticTableRows);
        }