Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/VerifyTests/Verify
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jul 25, 2024
2 parents a0db11e + 9e64c35 commit 45ee427
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/recording.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Task RecordingScoped()
return Verify();
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -117,7 +117,7 @@ public Task SameKey()
return Verify("TheValue");
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -154,7 +154,7 @@ public Task Identifier()
return Verify(Recording.Stop("identifier"));
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -186,7 +186,7 @@ public Task Case()
return Verify("TheValue");
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -221,7 +221,7 @@ public Task Stop()
return Verify(appends.Where(_ => _.Name != "name1"));
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -253,7 +253,7 @@ public Task StopNotInResult()
return Verify("other data");
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -282,7 +282,7 @@ public void IsRecording()
Assert.True(Recording.IsRecording());
}
```
<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>
<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>
<!-- endSnippet -->

This can be helpful if the cost of capturing data, to add to recording, is high.
Expand All @@ -305,7 +305,7 @@ public Task Clear()
return Verify();
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down Expand Up @@ -341,7 +341,7 @@ public Task PauseResume()
return Verify();
}
```
<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>
<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>
<!-- endSnippet -->

Results in:
Expand Down
17 changes: 17 additions & 0 deletions src/Verify.Tests/RecordingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public Task TryAdd()

#endregion

[Fact]
public void NameExists()
{
Recording.Start();
Assert.False(Recording.NameExists("name"));
Recording.Add("name", "value");
Assert.True(Recording.NameExists("name"));
}

#region RecordingScoped

[Fact]
Expand Down Expand Up @@ -99,6 +108,14 @@ public Task Identifier()

#endregion

[Fact]
public Task IdentifierExists()
{
Recording.Start("identifier");
Recording.Add("identifier", "name", "value");
return Verify(Recording.Stop("identifier"));
}

#region IsRecording

[Fact]
Expand Down
4 changes: 4 additions & 0 deletions src/Verify/Recording/Recording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public static void Add(string name, object item) =>
CurrentState()
.Add(name, item);

public static bool NameExists(string name) =>
CurrentState()
.Items.Any(_ => _.Name == name);

public static void TryAdd(string name, object item)
{
var value = asyncLocal.Value;
Expand Down

0 comments on commit 45ee427

Please sign in to comment.