Skip to content

Commit 160a7c3

Browse files
(#171) Update docs
1 parent d526172 commit 160a7c3

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

docs/docs/library/test-capture-logger-provider.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,33 @@ var allLogs = logProvider.GetAllLogEntries();
7878

7979
The result of the method can be passed into `RenderLogs()` extension method. See [Renderer](log-entry-renderer-extensions.md)
8080

81+
---
82+
83+
## GetLogs(predicate)
84+
85+
The `TestCaptureLoggerProvider.GetLogs(predicate)` allows you to retrieve specific logs within your test method that match the predicate. The log entries will be in sequence, timestamps will be incremental, however adjacent log entries created sufficiently close to one another may contain the same timestamp due to the resolution of the clock.
86+
87+
#### Returns
88+
89+
`IReadOnlyList<LogEntry>`: A read only list of log entries. See [LogEntry](log-entry.md)
90+
91+
##### Example
92+
93+
This example checks that a specific log entry was generated.
94+
95+
```csharp
96+
// Arrange
97+
var logProvider = new TestCaptureLoggerProvider();
98+
99+
// Act: Do something using the log provider.
100+
101+
// Assert
102+
var logs = logProvider.GetLogs(
103+
static le => le.LogLevel == LogLevel.Warning &&
104+
le.OriginalMessage == "A thing happened.");
105+
logs.Count.ShouldBe(1);
106+
```
107+
81108
---
82109
## GetAllLogEntriesWithExceptions()
83110

docs/docs/library/test-capture-logger.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This class implements
1313

1414
## GetLogs()
1515

16-
The `TestCaptureLogger.GetLogs()` allows you to retrieve the logs within your test method. The property will be in sequence, timestamps will be incremental, however adjacent log entries created sufficiently close to one another may contain the same timestamp due to the resolution of the clock.
16+
The `TestCaptureLogger.GetLogs()` allows you to retrieve the logs within your test method. The log entries will be in sequence, timestamps will be incremental, however adjacent log entries created sufficiently close to one another may contain the same timestamp due to the resolution of the clock.
1717

1818
#### Returns
1919

@@ -23,6 +23,33 @@ The `TestCaptureLogger.GetLogs()` allows you to retrieve the logs within your te
2323

2424
The result of the method can be passed into `RenderLogs()` extension method. See [Renderer](log-entry-renderer-extensions.md)
2525

26+
---
27+
## GetLogs(predicate)
28+
29+
The `TestCaptureLogger.GetLogs(predicate)` allows you to retrieve specific logs within your test method that match the predicate. The log entries will be in sequence, timestamps will be incremental, however adjacent log entries created sufficiently close to one another may contain the same timestamp due to the resolution of the clock.
30+
31+
#### Returns
32+
33+
`IReadOnlyList<LogEntry>`: A read only list of log entries. See [LogEntry](log-entry.md)
34+
35+
##### Example
36+
37+
This example checks that a specific log entry was generated.
38+
39+
```csharp
40+
// Arrange
41+
var logger = new TestCaptureLogger();
42+
43+
// Act: Do something using the logger
44+
45+
// Assert
46+
var logs = logger.GetLogs(
47+
static le => le.LogLevel == LogLevel.Warning &&
48+
le.OriginalMessage == "A thing happened.");
49+
logs.Count.ShouldBe(1);
50+
```
51+
52+
2653

2754
---
2855
## GetLogEntriesWithExceptions()

0 commit comments

Comments
 (0)