Closed xavierjohn closed 3 years ago
My current solution is
InMemorySink.Instance.Should()
.HaveMessage("HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms")
.WithLevel(LogEventLevel.Information)
.Appearing().Times(2)
.Subject
.Select(r => r.Properties["CorrelationId"].ToString().Trim('"'))
.Should()
.BeEquivalentTo(new string[] { "CorrelationId1", "CorrelationId2" });
@xavierjohn thanks for the suggestion!
I've introduced the following in #18:
_logger.Information("Message with {Property}", "val1");
_logger.Information("Message with {Property}", "val2");
InMemorySink.Instance
.Should()
.HaveMessage("Message with {Property}")
.Appearing().Times(2)
.WithProperty("Property")
.WithValues("val1", "val2");
This will be available with version 0.7.0 of the assertions package which should be on NuGet shortly.
What is the best way to check for properties in multiple messages?
I would like to write something similar to