public Property Only_Awnsered_UserMessages_Are_Deleted() { return(Prop.ForAll( SupportedProviderSettings(), Arb.From <OutStatus>(), (specificSettings, status) => { // Arrange OverrideWithSpecificSettings(specificSettings); string id = GenId(); OutMessage m = CreateOutMessage( id, insertionTime: DayBeforeYesterday, type: MessageType.UserMessage); m.SetStatus(status); IConfig config = EnsureLocalConfigPointsToCreatedDatastore(); var spy = new DatabaseSpy(config); spy.InsertOutMessage(m); // Act ExerciseStartCleaning(); // Assert bool isCleaned = !spy.GetOutMessages(id).Any(); bool isAckOrNack = status == OutStatus.Ack || status == OutStatus.Nack; return isCleaned == isAckOrNack; })); }
public async Task Received_Bundled_Response_Should_Process_All_Messages() { // Arrange string pullSenderUrl = RetrievePullingUrlFromConfig(); string storedMessageId = "stored-" + Guid.NewGuid(); StoreToBeAckOutMessage(storedMessageId); AS4Message bundled = CreateBundledMultipleUserMessagesWithRefTo(); bundled.AddMessageUnit(new Receipt($"receipt-{Guid.NewGuid()}", storedMessageId)); // Act await RespondToPullRequestAsync( pullSenderUrl, response => { response.ContentType = bundled.ContentType; response.StatusCode = 200; using (Stream output = response.OutputStream) { SerializerProvider.Default .Get(bundled.ContentType) .Serialize(bundled, output); } }); // Assert IEnumerable <InMessage> storedBundled = await PollUntilPresent( () => _databaseSpy.GetInMessages(bundled.UserMessages.Select(u => u.MessageId).ToArray()) .Where(m => m.Operation == Operation.ToBeDelivered), timeout : TimeSpan.FromSeconds(20)); Assert.Collection( storedBundled, userMessage1 => { Assert.Equal(MessageExchangePattern.Pull, userMessage1.MEP); Assert.Equal(InStatus.Received, userMessage1.Status.ToEnum <InStatus>()); Assert.Equal(Operation.ToBeDelivered, userMessage1.Operation); }, userMessage2 => { Assert.Equal(MessageExchangePattern.Pull, userMessage2.MEP); Assert.Equal(InStatus.Received, userMessage2.Status.ToEnum <InStatus>()); Assert.Equal(Operation.ToBeDelivered, userMessage2.Operation); }); Assert.Collection( _databaseSpy.GetInMessages(bundled.SignalMessages.Select(s => s.MessageId).ToArray()), signal => { Assert.Equal(MessageExchangePattern.Pull, signal.MEP); Assert.Equal(InStatus.Received, signal.Status.ToEnum <InStatus>()); Assert.Equal(Operation.ToBeNotified, signal.Operation); }); Assert.Collection( _databaseSpy.GetOutMessages(storedMessageId), stored => Assert.Equal(OutStatus.Ack, stored.Status.ToEnum <OutStatus>())); }
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)); }