public void NextDatabaseBackupCorrectlyReturnsFullBackupIfNoBackupsTaken()
        {
            var recentBackups = new DatabaseBackupStatus()
            {
                LastFullBackup           = null,
                LastDifferentialBackup   = null,
                LastTransactionLogBackup = null
            };

            var result = Scheduler.NextDatabaseBackup(recentBackups);

            Assert.IsNotNull(result);
            Assert.AreEqual(DatabaseBackupType.Full, result.Value);
        }
        public void NextDatabaseBackupCorrectlyReturnsNoBackupWhenNoBackupsNeedToBeTaken()
        {
            var now = DateTime.Now;

            var recentBackups = new DatabaseBackupStatus()
            {
                LastFullBackup           = now.AddHours(-23),
                LastDifferentialBackup   = now.AddHours(-3),
                LastTransactionLogBackup = now.AddMinutes(-29)
            };

            var result = Scheduler.NextDatabaseBackup(recentBackups);

            Assert.IsNull(result);
        }
        public CompleteDatabaseBackupRequest(
            long backupId,
            DatabaseBackupStatus status,
            long size,
            byte[] sha256,
            string message = null)
        {
            Ensure.IsValidId(backupId, nameof(backupId));

            BackupId = backupId;
            Status   = status;
            Size     = size;
            Sha256   = sha256;
            Message  = message;
        }
        public void NextDatabaseBackupCorrectlyReturnsLogBackupIfNoLogBackupsIn30Minutes()
        {
            var now = DateTime.Now;

            var recentBackups = new DatabaseBackupStatus()
            {
                LastFullBackup           = now.AddHours(-20),
                LastDifferentialBackup   = now.AddHours(-3),
                LastTransactionLogBackup = now.AddMinutes(-30)
            };

            var result = Scheduler.NextDatabaseBackup(recentBackups);

            Assert.IsNotNull(result);
            Assert.AreEqual(DatabaseBackupType.TransactionLog, result.Value);
        }
        public void NextDatabaseBackupCorrectlyPrioritizesLastDifferentialOverLastTransactionLog()
        {
            var now = DateTime.Now;

            var recentBackups = new DatabaseBackupStatus()
            {
                LastFullBackup           = now.AddHours(-20),
                LastDifferentialBackup   = now.AddHours(-5),
                LastTransactionLogBackup = now.AddMinutes(-35)
            };

            var result = Scheduler.NextDatabaseBackup(recentBackups);

            Assert.IsNotNull(result);
            Assert.AreEqual(DatabaseBackupType.Differential, result.Value);
        }