예제 #1
0
        public void VerifyFirstStamp_NoFirstInStamp_AddBeginOfDayAsFirstInStamp()
        {
            // Arrange
            // Target day is 01.03.2016
            DateTime targetDay              = new DateTime(2016, 3, 1);
            int      targetEmployerID       = 1;
            List <EmployerTimeStamp> stamps = new List <EmployerTimeStamp>()
            {
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.Out, Time = targetDay
                }
            };
            int originalStampsCount           = stamps.Count;
            DailyReportsManager dailyReporter = this.СreateDailyReporter(stamps);
            EmployerTimeStamp   expectedStamp = new EmployerTimeStamp()
            {
                EmployerID = targetEmployerID, Type = StampType.In, Time = new DateTime(targetDay.Year, targetDay.Month, targetDay.Day, 0, 0, 0)
            };
            List <Notification> notifications = new List <Notification>();

            // Act
            dailyReporter.VerifyFirstStamp(stamps, targetEmployerID, targetDay, notifications);

            // Assertions
            // Check
            Assert.AreEqual(stamps.Count, originalStampsCount + 1);
            Assert.That(stamps[0], Is.EqualTo(expectedStamp).Using(new EmployerTimeStampComparer()));
        }
예제 #2
0
        public void VerifyFirstStamp_EmptyCollection_NoExceptions()
        {
            // Arrange
            DateTime targetDay                     = new DateTime(2016, 3, 1);
            int      targetEmployerID              = 1;
            List <EmployerTimeStamp> stamps        = new List <EmployerTimeStamp>();
            DailyReportsManager      dailyReporter = this.СreateDailyReporter(stamps);
            List <Notification>      notifications = new List <Notification>();

            // Act and Assert
            // Check that call method with empty collection not throwing any exceptions.
            Assert.That(() => dailyReporter.VerifyFirstStamp(stamps, targetEmployerID, targetDay, notifications), Throws.Nothing);
        }
예제 #3
0
        public void VerifyFirstStamp_NotificationsIsNull_ThrowArgumentNullException()
        {
            // Arrange
            DateTime targetDay                     = new DateTime(2016, 3, 1);
            int      targetEmployerID              = 1;
            List <EmployerTimeStamp> stamps        = new List <EmployerTimeStamp>();
            DailyReportsManager      dailyReporter = this.СreateDailyReporter(stamps);
            List <Notification>      notifications = null;

            // Act and Assert
            // Check that call method with null protocol throws "ArgumentNullException".
            Assert.That(() => dailyReporter.VerifyFirstStamp(stamps, targetEmployerID, targetDay, notifications), Throws.Exception.TypeOf <ArgumentNullException>());
        }
예제 #4
0
        public void VerifyFirstStamp_DataIsCorrect_NoAnyChange()
        {
            // 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 10.00 am of target day
                new EmployerTimeStamp()
                {
                    EmployerID = targetEmployerID, Type = StampType.Out, Time = targetDay.AddHours(10)
                }
            };
            int originalStampsCount = stamps.Count;
            DailyReportsManager      dailyReporter  = this.СreateDailyReporter(stamps);
            List <Notification>      notifications  = new List <Notification>();
            List <EmployerTimeStamp> expectedStamps = new List <EmployerTimeStamp>()
            {
                stamps[0],
                stamps[1]
            };

            // Act
            dailyReporter.VerifyFirstStamp(stamps, targetEmployerID, targetDay, notifications);

            // Assertions
            // Check that collections contain same items in same order.
            Assert.That(stamps, Is.EqualTo(expectedStamps));
        }