File tree Expand file tree Collapse file tree 7 files changed +107
-1
lines changed
Expand file tree Collapse file tree 7 files changed +107
-1
lines changed Original file line number Diff line number Diff line change 1+ # Numeric Ids
2+
3+ snippet: NumericIdSample
4+
5+ Produces
6+
7+ snippet: NumericIdSample.Test.verified.txt
Original file line number Diff line number Diff line change @@ -168,4 +168,5 @@ snippet: Verify.Xunit.Tests/Scrubbers/ScrubberLevelsSample.Usage.verified.txt
168168## See also
169169
170170 * [ Guid behavior] ( guids.md )
171- * [ Date behavior] ( dates.md )
171+ * [ Date behavior] ( dates.md )
172+ * [ Numeric Ids] ( numericIds.md )
Original file line number Diff line number Diff line change 1+ <!--
2+ GENERATED FILE - DO NOT EDIT
3+ This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets).
4+ Source File: /docs/mdsource/numericIds.source.md
5+ To change this file edit the source file and then run MarkdownSnippets.
6+ -->
7+
8+ # Numeric Ids
9+
10+ <!-- snippet: NumericIdSample -->
11+ <a id =' snippet-NumericIdSample ' ></a >
12+ ``` cs
13+ public class NumericIdSample
14+ {
15+ public class Target : IHasId
16+ {
17+ public required int Id { get ; init ; }
18+ public required string Name { get ; init ; }
19+ }
20+
21+ [ModuleInitializer ]
22+ public static void Init () =>
23+ VerifierSettings .ScrubMembers (
24+ _ => typeof (IHasId ).IsAssignableFrom (_ .DeclaringType ) &&
25+ _ .Name == " Id" );
26+
27+ [Fact ]
28+ public Task Test ()
29+ {
30+ var target = new Target
31+ {
32+ Id = new Random ().Next (),
33+ Name = " The Name"
34+ };
35+ return Verify (target );
36+ }
37+
38+ public interface IHasId
39+ {
40+ public int Id { get ; init ; }
41+ }
42+ }
43+ ```
44+ <sup ><a href =' /src/Verify.Tests/Snippets/NumericIdSample.cs#L1-L34 ' title =' Snippet source file ' >snippet source</a > | <a href =' #snippet-NumericIdSample ' title =' Start of snippet ' >anchor</a ></sup >
45+ <!-- endSnippet -->
46+
47+ Produces
48+
49+ <!-- snippet: NumericIdSample.Test.verified.txt -->
50+ <a id =' snippet-NumericIdSample.Test.verified.txt ' ></a >
51+ ``` txt
52+ {
53+ Id: {Scrubbed},
54+ Name: The Name
55+ }
56+ ```
57+ <sup ><a href =' /src/Verify.Tests/Snippets/NumericIdSample.Test.verified.txt#L1-L4 ' title =' Snippet source file ' >snippet source</a > | <a href =' #snippet-NumericIdSample.Test.verified.txt ' title =' Start of snippet ' >anchor</a ></sup >
58+ <!-- endSnippet -->
Original file line number Diff line number Diff line change @@ -861,3 +861,4 @@ A B C
861861
862862 * [ Guid behavior] ( guids.md )
863863 * [ Date behavior] ( dates.md )
864+ * [ Numeric Ids] ( numericIds.md )
Original file line number Diff line number Diff line change 44global using Argon ;
55global using DiffEngine ;
66global using EmptyFiles ;
7+ global using Polyfills ;
78global using Xunit . Abstractions ;
Original file line number Diff line number Diff line change 1+ {
2+ Id: {Scrubbed},
3+ Name: The Name
4+ }
Original file line number Diff line number Diff line change 1+ #region NumericIdSample
2+
3+ public class NumericIdSample
4+ {
5+ public class Target : IHasId
6+ {
7+ public required int Id { get ; init ; }
8+ public required string Name { get ; init ; }
9+ }
10+
11+ [ ModuleInitializer ]
12+ public static void Init ( ) =>
13+ VerifierSettings . ScrubMembers (
14+ _ => typeof ( IHasId ) . IsAssignableFrom ( _ . DeclaringType ) &&
15+ _ . Name == "Id" ) ;
16+
17+ [ Fact ]
18+ public Task Test ( )
19+ {
20+ var target = new Target
21+ {
22+ Id = new Random ( ) . Next ( ) ,
23+ Name = "The Name"
24+ } ;
25+ return Verify ( target ) ;
26+ }
27+
28+ public interface IHasId
29+ {
30+ public int Id { get ; init ; }
31+ }
32+ }
33+
34+ #endregion
You can’t perform that action at this time.
0 commit comments