예제 #1
0
        public void TimeOfWorkForDay_DataCorrect_CorrectTimeOfWork()
        {
            // Arrange
            // Target day is 01.03.2016
            DateTime targetDay              = new DateTime(2016, 3, 1);
            int      targetEmployerID       = 1;
            List <EmployerTimeStamp> stamps = new List <EmployerTimeStamp>()
            {
                // In-stamp at 9.00 am of target day
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.In, Time = targetDay.AddHours(9)
                },

                // Out-stamp at 11.00 am of target day
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.Out, Time = targetDay.AddHours(10).AddMinutes(10)
                },

                // In-stamp at 12.00 am of target day
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.In, Time = targetDay.AddHours(12)
                },

                // Out-stamp at 14.00 am of target day
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.Out, Time = targetDay.AddHours(18)
                },
            };
            DailyReportsManager dailyReporter = this.СreateDailyReporter(stamps);

            // Expected time of work.
            // It should 7 hours and 10 minutes.
            TimeSpan expectedTime = new TimeSpan(7, 10, 0);

            // Act
            var protocol = dailyReporter.TimeOfWorkForDay(targetEmployerID, targetDay);

            // Assertions
            // Check that computation was successful carried out.
            Assert.That(protocol.IsSucceed, Is.True);
            Assert.That(protocol.Result, Is.EqualTo(expectedTime));
        }
예제 #2
0
        public void TimeOfWorkForDay_NoDataForDay_TimeOfWorkEqualsZero()
        {
            // Arrange
            // Target day is 01.03.2016
            DateTime targetDay                     = new DateTime(2016, 3, 1);
            int      targetEmployerID              = 1;
            List <EmployerTimeStamp> stamps        = new List <EmployerTimeStamp>();
            DailyReportsManager      dailyReporter = this.СreateDailyReporter(stamps);

            // Expected time of work.
            // It should 0 hours 0 minutes and 0 seconds.
            TimeSpan expectedTime = new TimeSpan(0);

            // Act
            var protocol = dailyReporter.TimeOfWorkForDay(targetEmployerID, targetDay);

            // Assertions
            // Check that computation was successful carried out.
            Assert.That(protocol.IsSucceed, Is.True);
            Assert.That(protocol.Result, Is.EqualTo(expectedTime));
        }
예제 #3
0
        static void Main(string[] args)
        {
            DailyReportsManager dailyReporter = new DailyReportsManager(BuildStampsSource());

            ReportProtocol <TimeSpan>        dayWork     = dailyReporter.TimeOfWorkForDay(TargetEmployer(), TagetDay());
            ReportProtocol <List <Respite> > dayRespites = dailyReporter.RespitesForDay(TargetEmployer(), TagetDay(), MaxRespiteDuration());

            Console.WriteLine("Time for day:");
            if (dayWork.IsSucceed)
            {
                Console.WriteLine("\t{0} hrs.", dayWork.Result.TotalHours);
                Console.WriteLine("\tNotifications count: {0}", dayWork.Notifications.Count);
            }
            else
            {
                Console.WriteLine("\tError was occurred. Reporting end unsuccessfully.");
            }
            foreach (var n in dayWork.Notifications)
            {
                Console.WriteLine("\tType: {0}. Message: {1}", n.Type, n.Description);
            }


            Console.WriteLine("Respites for day:");
            if (dayRespites.IsSucceed)
            {
                Console.WriteLine("\tAmount of respites: {0}", dayRespites.Result.Count);
                Console.WriteLine("\tNotifications count: {0}", dayRespites.Notifications.Count);
            }
            else
            {
                Console.WriteLine("\tError was occurred. Reporting end unsuccessfully.");
            }
            foreach (var n in dayRespites.Notifications)
            {
                Console.WriteLine("\tType: {0}. Message: {1}", n.Type, n.Description);
            }

            Console.ReadKey();
        }