public void RunMailService_NotificationWithRepeat_ShouldCall_SendMails_AndAddNewNotification()
        {
            var preLength = repoMock.AsQueryable().ToList().Count;

            var mailSub = NSubstitute.Substitute.For <IMailService>();

            repoMock.noti1 = new MailNotificationSchedule()
            {
                Id            = 1,
                DateTimestamp = ToUnixTime(DateTime.Now),
                Notified      = false,
                Repeat        = false
            };
            repoMock.noti2 = new MailNotificationSchedule()
            {
                Id            = 2,
                DateTimestamp = ToUnixTime(DateTime.Now),
                Notified      = false,
                Repeat        = true
            };
            repoMock.ReSeed();
            var uut = new ConsoleMailerService(mailSub, repoMock, _logger);

            uut.RunMailService();
            mailSub.ReceivedWithAnyArgs().SendMails(new DateTime());
            Assert.AreEqual(preLength + 1, repoMock.AsQueryable().ToList().Count);
        }
        public void RunMailService_2NotificationsWithRepeat_ShouldCall_SendMails()
        {
            var preLength         = repoMock.AsQueryable().ToList().Count;
            var customText1       = "customText1";
            var customText2       = "";
            var datetimeNoMilisec = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            var mailSub           = NSubstitute.Substitute.For <IMailService>();
            var substituteSub     = NSubstitute.Substitute.For <ISubstituteService>();

            repoMock.noti1 = new MailNotificationSchedule()
            {
                Id                     = 1,
                DateTimestamp          = Utilities.ToUnixTime(datetimeNoMilisec),
                FileGenerationSchedule = new FileGenerationSchedule {
                    DateTimestamp = Utilities.ToUnixTime(datetimeNoMilisec)
                },
                CustomText = customText1
            };
            repoMock.noti2 = new MailNotificationSchedule()
            {
                Id                     = 2,
                DateTimestamp          = Utilities.ToUnixTime(datetimeNoMilisec),
                FileGenerationSchedule = new FileGenerationSchedule {
                    DateTimestamp = Utilities.ToUnixTime(datetimeNoMilisec)
                },
                CustomText = customText2
            };
            repoMock.ReSeed();
            var uut = new ConsoleMailerService(mailSub, substituteSub, repoMock, _logger, _customSettings);

            uut.RunMailService();
            mailSub.Received().SendMails(datetimeNoMilisec, customText1);
            mailSub.Received().SendMails(datetimeNoMilisec, customText2);
        }
        public void RunMailService_NoNotificationsForToday_ShouldNotCall_SendMails()
        {
            var mailSub       = NSubstitute.Substitute.For <IMailService>();
            var substituteSub = NSubstitute.Substitute.For <ISubstituteService>();

            repoMock.noti1 = new MailNotificationSchedule()
            {
                Id                     = 1,
                DateTimestamp          = Utilities.ToUnixTime(DateTime.Now.AddDays(1)),
                FileGenerationSchedule = new FileGenerationSchedule {
                    DateTimestamp = Utilities.ToUnixTime(DateTime.Now)
                }
            };
            repoMock.noti2 = new MailNotificationSchedule()
            {
                Id                     = 2,
                DateTimestamp          = Utilities.ToUnixTime(DateTime.Now.AddDays(2)),
                FileGenerationSchedule = new FileGenerationSchedule {
                    DateTimestamp = Utilities.ToUnixTime(DateTime.Now)
                }
            };
            repoMock.ReSeed();
            var uut = new ConsoleMailerService(mailSub, substituteSub, repoMock, _logger, _customSettings);

            uut.RunMailService();
            mailSub.DidNotReceive().SendMails(new DateTime(), "");
        }
        public void RunMailService_NoUnnotifiedNotifications_ShouldNotCall_SendMails()
        {
            var mailSub = NSubstitute.Substitute.For <IMailService>();

            repoMock.noti1 = new MailNotificationSchedule()
            {
                Id            = 1,
                DateTimestamp = ToUnixTime(DateTime.Now),
                Notified      = true,
                Repeat        = true
            };
            repoMock.noti2 = new MailNotificationSchedule()
            {
                Id            = 2,
                DateTimestamp = ToUnixTime(DateTime.Now),
                Notified      = true,
                Repeat        = true
            };
            repoMock.ReSeed();
            var uut = new ConsoleMailerService(mailSub, repoMock, _logger);

            uut.RunMailService();
            mailSub.DidNotReceive().SendMails(new DateTime());
        }