Exemplo n.º 1
0
        public Property Only_Overdue_Entries_Are_Deleted()
        {
            return(Prop.ForAll(
                       SupportedProviderSettings(),
                       Arb.Default.PositiveInt(),
                       Arb.Default.PositiveInt(),
                       (specificSettings, insertion, retention) =>
            {
                // Arrange
                int retentionDays = retention.Get;
                OverrideWithSpecificSettings(specificSettings, retentionDays: retentionDays);

                int insertionDays = insertion.Get;
                string id = GenId();

                IConfig config = EnsureLocalConfigPointsToCreatedDatastore();
                var spy = new DatabaseSpy(config);
                var insertionTime = DateTimeOffset.Now.Add(TimeSpan.FromDays(-insertionDays));
                spy.InsertOutException(CreateOutException(id, insertionTime));

                // Act
                ExerciseStartCleaning();

                // Assert
                bool hasEntries = spy.GetOutExceptions(id).Any();
                return (hasEntries == insertionDays < retentionDays)
                .When(insertionDays != retentionDays)
                .Classify(hasEntries, "OutException isn't deleted")
                .Classify(!hasEntries, "OutException is deleted");
            }));
        }
Exemplo n.º 2
0
        public void MessageOlderThanRetentionDateWillBeDeleted(string specificSettings)
        {
            // Arrange: Insert a "retired" OutMessage with a referenced Reception Awareness.
            OverrideWithSpecificSettings(specificSettings);

            IConfig config = EnsureLocalConfigPointsToCreatedDatastore();
            string  outReferenceId = GenId(), outStandaloneId = GenId(),
                    inMessageId = GenId(), outExceptionId = GenId(),
                    inExceptionId = GenId();

            var        spy = new DatabaseSpy(config);
            OutMessage om  = CreateOutMessage(outReferenceId, insertionTime: DayBeforeYesterday, type: MessageType.Error);

            spy.InsertOutMessage(om);
            spy.InsertRetryReliability(RetryReliability.CreateForOutMessage(om.Id, maxRetryCount: 0, retryInterval: default(TimeSpan), type: RetryType.Send));
            spy.InsertOutMessage(CreateOutMessage(outStandaloneId, insertionTime: DayBeforeYesterday, type: MessageType.Receipt));
            spy.InsertInMessage(CreateInMessage(inMessageId, DayBeforeYesterday));
            spy.InsertOutException(CreateOutException(outExceptionId, DayBeforeYesterday));
            spy.InsertInException(CreateInException(inExceptionId, DayBeforeYesterday));

            // Act: AS4.NET Component will start the Clean Up Agent.
            ExerciseStartCleaning();

            // Assert: No OutMessage or Reception Awareness entries must be found for a given EbmsMessageId.
            Assert.Empty(spy.GetOutMessages(outReferenceId, outStandaloneId));
            Assert.Null(spy.GetRetryReliabilityFor(r => r.RefToOutMessageId == om.Id));
            Assert.Empty(spy.GetInMessages(inMessageId));
            Assert.Empty(spy.GetOutExceptions(outExceptionId));
            Assert.Empty(spy.GetInExceptions(inExceptionId));
        }