Skip to content

Commit 9e64c35

Browse files
authored
Add Recording.NameExists (#1253)
* add Recording.NameExists * Update recording.md
1 parent 0115486 commit 9e64c35

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

docs/recording.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Task RecordingScoped()
8585
return Verify();
8686
}
8787
```
88-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L73-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingScoped' title='Start of snippet'>anchor</a></sup>
88+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L82-L97' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingScoped' title='Start of snippet'>anchor</a></sup>
8989
<!-- endSnippet -->
9090

9191
Results in:
@@ -117,7 +117,7 @@ public Task SameKey()
117117
return Verify("TheValue");
118118
}
119119
```
120-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L272-L283' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSameKey' title='Start of snippet'>anchor</a></sup>
120+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L289-L300' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSameKey' title='Start of snippet'>anchor</a></sup>
121121
<!-- endSnippet -->
122122

123123
Results in:
@@ -154,7 +154,7 @@ public Task Identifier()
154154
return Verify(Recording.Stop("identifier"));
155155
}
156156
```
157-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L90-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIdentifier' title='Start of snippet'>anchor</a></sup>
157+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L99-L109' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIdentifier' title='Start of snippet'>anchor</a></sup>
158158
<!-- endSnippet -->
159159

160160
Results in:
@@ -186,7 +186,7 @@ public Task Case()
186186
return Verify("TheValue");
187187
}
188188
```
189-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L294-L305' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIgnoreCase' title='Start of snippet'>anchor</a></sup>
189+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L311-L322' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIgnoreCase' title='Start of snippet'>anchor</a></sup>
190190
<!-- endSnippet -->
191191

192192
Results in:
@@ -221,7 +221,7 @@ public Task Stop()
221221
return Verify(appends.Where(_ => _.Name != "name1"));
222222
}
223223
```
224-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L132-L144' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStop' title='Start of snippet'>anchor</a></sup>
224+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L149-L161' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStop' title='Start of snippet'>anchor</a></sup>
225225
<!-- endSnippet -->
226226

227227
Results in:
@@ -253,7 +253,7 @@ public Task StopNotInResult()
253253
return Verify("other data");
254254
}
255255
```
256-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L146-L158' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStopNotInResult' title='Start of snippet'>anchor</a></sup>
256+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L163-L175' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStopNotInResult' title='Start of snippet'>anchor</a></sup>
257257
<!-- endSnippet -->
258258

259259
Results in:
@@ -282,7 +282,7 @@ public void IsRecording()
282282
Assert.True(Recording.IsRecording());
283283
}
284284
```
285-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L102-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsRecording' title='Start of snippet'>anchor</a></sup>
285+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L119-L129' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsRecording' title='Start of snippet'>anchor</a></sup>
286286
<!-- endSnippet -->
287287

288288
This can be helpful if the cost of capturing data, to add to recording, is high.
@@ -305,7 +305,7 @@ public Task Clear()
305305
return Verify();
306306
}
307307
```
308-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L192-L204' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingClear' title='Start of snippet'>anchor</a></sup>
308+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L209-L221' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingClear' title='Start of snippet'>anchor</a></sup>
309309
<!-- endSnippet -->
310310

311311
Results in:
@@ -341,7 +341,7 @@ public Task PauseResume()
341341
return Verify();
342342
}
343343
```
344-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L216-L231' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingPauseResume' title='Start of snippet'>anchor</a></sup>
344+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L233-L248' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingPauseResume' title='Start of snippet'>anchor</a></sup>
345345
<!-- endSnippet -->
346346

347347
Results in:

src/Verify.Tests/RecordingTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public Task TryAdd()
7070

7171
#endregion
7272

73+
[Fact]
74+
public void NameExists()
75+
{
76+
Recording.Start();
77+
Assert.False(Recording.NameExists("name"));
78+
Recording.Add("name", "value");
79+
Assert.True(Recording.NameExists("name"));
80+
}
81+
7382
#region RecordingScoped
7483

7584
[Fact]
@@ -99,6 +108,14 @@ public Task Identifier()
99108

100109
#endregion
101110

111+
[Fact]
112+
public Task IdentifierExists()
113+
{
114+
Recording.Start("identifier");
115+
Recording.Add("identifier", "name", "value");
116+
return Verify(Recording.Stop("identifier"));
117+
}
118+
102119
#region IsRecording
103120

104121
[Fact]

src/Verify/Recording/Recording.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public static void Add(string name, object item) =>
1616
CurrentState()
1717
.Add(name, item);
1818

19+
public static bool NameExists(string name) =>
20+
CurrentState()
21+
.Items.Any(_ => _.Name == name);
22+
1923
public static void TryAdd(string name, object item)
2024
{
2125
var value = asyncLocal.Value;

0 commit comments

Comments
 (0)