Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing extensions for TestableMessageSession are missing #535

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,12 @@ namespace NServiceBus.Testing
}
public static class TestingExtensions
{
public static TMessage FindPublishedMessage<TMessage>(this NServiceBus.Testing.TestableMessageSession context) { }
public static TMessage FindPublishedMessage<TMessage>(this NServiceBus.Testing.TestablePipelineContext context) { }
public static TMessage FindReplyMessage<TMessage>(this NServiceBus.Testing.TestableMessageProcessingContext context) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not FindReplyMessage on TestableMessageSession as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReplyMessages only exist on TestableMessageProcessingContex. TestableMessageSession doesn't even have the property.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good reason!

public static TMessage FindSentMessage<TMessage>(this NServiceBus.Testing.TestableMessageSession context) { }
public static TMessage FindSentMessage<TMessage>(this NServiceBus.Testing.TestablePipelineContext context) { }
public static TMessage FindTimeoutMessage<TMessage>(this NServiceBus.Testing.TestableMessageSession context) { }
public static TMessage FindTimeoutMessage<TMessage>(this NServiceBus.Testing.TestablePipelineContext context) { }
}
public class TestingLoggerFactory : NServiceBus.Logging.LoggingFactoryDefinition
Expand Down
29 changes: 25 additions & 4 deletions src/NServiceBus.Testing/NSB.Testing.Fakes/TestingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static class TestingExtensions
(TMessage)context.PublishedMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first sent message of a given type,
/// or a default value if there is no sent message of the given type.
/// Returns the first published message of a given type,
/// or a default value if there is no published message of the given type.
/// </summary>
public static TMessage FindSentMessage<TMessage>(this TestablePipelineContext context) =>
(TMessage)context.SentMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;
public static TMessage FindPublishedMessage<TMessage>(this TestableMessageSession context) =>
(TMessage)context.PublishedMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first timeout message of a given type,
Expand All @@ -28,6 +28,27 @@ public static class TestingExtensions
public static TMessage FindTimeoutMessage<TMessage>(this TestablePipelineContext context) =>
(TMessage)context.TimeoutMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first timeout message of a given type,
/// or a default value if there is no timeout message of the given type.
/// </summary>
public static TMessage FindTimeoutMessage<TMessage>(this TestableMessageSession context) =>
(TMessage)context.TimeoutMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first sent message of a given type,
/// or a default value if there is no sent message of the given type.
/// </summary>
public static TMessage FindSentMessage<TMessage>(this TestableMessageSession context) =>
(TMessage)context.SentMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first sent message of a given type,
/// or a default value if there is no sent message of the given type.
/// </summary>
public static TMessage FindSentMessage<TMessage>(this TestablePipelineContext context) =>
(TMessage)context.SentMessages.FirstOrDefault(msg => msg.Message is TMessage)?.Message;

/// <summary>
/// Returns the first replied message of a given type,
/// or a default value if there is no replied message of the given type.
Expand Down