Example #1
0
        public void OlderRecordsAboveLimitAreSelected()
        {
            // Arrange
            var now = DateTime.Now;
            List <IPersistedScriptExecutionRecord> records = new List <IPersistedScriptExecutionRecord>();

            for (int i = 1; i <= 25; i++)
            {
                var recordMock = new Mock <IPersistedScriptExecutionRecord>();
                recordMock.Setup(r => r.LastUpdateDate).Returns(now - new TimeSpan(i, 0, 0, 0));
                records.Add(recordMock.Object);
            }

            // Act
            var rule   = new LastNumberOfRecordsRetentionRule(20);
            var actual = rule.Evaluate(records.ToArray());

            // Assert
            Assert.AreEqual(5, actual.Length);
            Assert.IsNotNull(actual.Select(r => r.LastUpdateDate == (now - new TimeSpan(25))));
            Assert.IsNotNull(actual.Select(r => r.LastUpdateDate == (now - new TimeSpan(24))));
            Assert.IsNotNull(actual.Select(r => r.LastUpdateDate == (now - new TimeSpan(23))));
            Assert.IsNotNull(actual.Select(r => r.LastUpdateDate == (now - new TimeSpan(22))));
            Assert.IsNotNull(actual.Select(r => r.LastUpdateDate == (now - new TimeSpan(21))));
        }
Example #2
0
        public void EvaluateReturnsNullOnEmptyInput()
        {
            // Arrange
            var rule = new LastNumberOfRecordsRetentionRule(20);

            // Act
            var actual = rule.Evaluate(new IPersistedScriptExecutionRecord[] { });

            // Assert
            Assert.IsNull(actual);
        }
Example #3
0
        public void EvaluateReturnsNullOnNullInput()
        {
            // Arrange
            var rule = new LastNumberOfRecordsRetentionRule(20);

            // Act
            var actual = rule.Evaluate(null);

            // Assert
            Assert.IsNull(actual);
        }