Skip to content

Commit 5410425

Browse files
committed
Merge branch 'main' into fix-verify-result-encoding
2 parents 002269e + ff42d46 commit 5410425

44 files changed

Lines changed: 460 additions & 61 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/recording.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public Task Usage()
2525
return Verify("TheValue");
2626
}
2727
```
28-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L54-L64' title='Snippet source file'>snippet source</a> | <a href='#snippet-Recording' title='Start of snippet'>anchor</a></sup>
28+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L84-L94' title='Snippet source file'>snippet source</a> | <a href='#snippet-Recording' title='Start of snippet'>anchor</a></sup>
2929
<!-- endSnippet -->
3030

3131
Results in:
@@ -61,7 +61,7 @@ public Task TryAdd()
6161
return Verify("TheValue");
6262
}
6363
```
64-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L90-L102' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingTryAdd' title='Start of snippet'>anchor</a></sup>
64+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L120-L132' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingTryAdd' title='Start of snippet'>anchor</a></sup>
6565
<!-- endSnippet -->
6666

6767

@@ -85,7 +85,7 @@ public Task RecordingScoped()
8585
return Verify();
8686
}
8787
```
88-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L113-L128' 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#L143-L158' 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#L312-L323' 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#L342-L353' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSameKey' title='Start of snippet'>anchor</a></sup>
121121
<!-- endSnippet -->
122122

123123
Results in:
@@ -156,7 +156,7 @@ public Task Identifier()
156156
return Verify(Recording.Stop("identifier"));
157157
}
158158
```
159-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L130-L140' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIdentifier' title='Start of snippet'>anchor</a></sup>
159+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L160-L170' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIdentifier' title='Start of snippet'>anchor</a></sup>
160160
<!-- endSnippet -->
161161

162162
Results in:
@@ -188,7 +188,7 @@ public Task Case()
188188
return Verify("TheValue");
189189
}
190190
```
191-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L334-L345' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIgnoreCase' title='Start of snippet'>anchor</a></sup>
191+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L364-L375' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIgnoreCase' title='Start of snippet'>anchor</a></sup>
192192
<!-- endSnippet -->
193193

194194
Results in:
@@ -223,7 +223,7 @@ public Task Stop()
223223
return Verify(appends.Where(_ => _.Name != "name1"));
224224
}
225225
```
226-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L172-L184' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStop' title='Start of snippet'>anchor</a></sup>
226+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L202-L214' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStop' title='Start of snippet'>anchor</a></sup>
227227
<!-- endSnippet -->
228228

229229
Results in:
@@ -255,7 +255,7 @@ public Task StopNotInResult()
255255
return Verify("other data");
256256
}
257257
```
258-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L186-L198' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStopNotInResult' title='Start of snippet'>anchor</a></sup>
258+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L216-L228' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStopNotInResult' title='Start of snippet'>anchor</a></sup>
259259
<!-- endSnippet -->
260260

261261
Results in:
@@ -284,7 +284,7 @@ public void IsRecording()
284284
Assert.True(Recording.IsRecording());
285285
}
286286
```
287-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L142-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsRecording' title='Start of snippet'>anchor</a></sup>
287+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L172-L182' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsRecording' title='Start of snippet'>anchor</a></sup>
288288
<!-- endSnippet -->
289289

290290
This can be helpful if the cost of capturing data, to add to recording, is high.
@@ -307,7 +307,7 @@ public Task Clear()
307307
return Verify();
308308
}
309309
```
310-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L232-L244' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingClear' title='Start of snippet'>anchor</a></sup>
310+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L262-L274' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingClear' title='Start of snippet'>anchor</a></sup>
311311
<!-- endSnippet -->
312312

313313
Results in:
@@ -343,7 +343,7 @@ public Task PauseResume()
343343
return Verify();
344344
}
345345
```
346-
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L256-L271' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingPauseResume' title='Start of snippet'>anchor</a></sup>
346+
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L286-L301' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingPauseResume' title='Start of snippet'>anchor</a></sup>
347347
<!-- endSnippet -->
348348

349349
Results in:

src/Verify.ClipboardAccept/ClipboardAccept.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,28 @@ static async Task Append(string command)
111111
try
112112
{
113113
builder.AppendLine(command);
114-
await ClipboardService.SetTextAsync(builder.ToString());
114+
await SetClipboardText(builder.ToString());
115115
}
116116
finally
117117
{
118118
semaphore.Release();
119119
}
120120
}
121+
122+
static async Task SetClipboardText(string text)
123+
{
124+
try
125+
{
126+
await ClipboardService.SetTextAsync(text);
127+
}
128+
catch (Exception exception)
129+
{
130+
// This runs from the OnFirstVerify and OnVerifyMismatch callbacks, which the
131+
// engine awaits while building the failure. Letting a clipboard failure out
132+
// replaces the snapshot diff with an unrelated error: no xsel or wl-copy on a
133+
// headless Linux box, or another process holding the Windows clipboard.
134+
// Copying the accept command is a convenience, so it fails quietly.
135+
Trace.WriteLine($"Verify: could not write the accept command to the clipboard. {exception}");
136+
}
137+
}
121138
}

src/Verify.Fixie/Execution/ExecutionState.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ public static ExecutionState Current
2525

2626
throw new(
2727
"""
28-
No State found. Ensure a class inheriting from VerifyTestProject exists in the test project.
29-
public class TestProject :
30-
VerifyTestProject;
28+
No State found. Fixie leaves test execution up to the consumer, so Verify needs a class in the test project implementing Fixie's ITestProject and IExecution:
29+
* ITestProject.Configure must call VerifierSettings.AssignTargetAssembly(environment.Assembly)
30+
* IExecution.Run must wrap each test.Run in `using (ExecutionState.Set(testClass, test, parameters))`
31+
See https://github.com/VerifyTests/Verify/blob/main/docs/mdsource/fixie-convention.include.md for a full example.
3132
""");
3233
}
3334
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAssemblyAttribute.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAssemblyAttributeAndCustomTestClassAttribute.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAttributeOnClass.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasBothAssemblyAndClassAttributes.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAssemblyAttributeAndTestClassInheritance.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAssemblyAttributeWithTestClassOnDerivedAndMarkerAttributeOnBase.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAttributeOnBaseAndDerivedClasses.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

0 commit comments

Comments
 (0)