-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
FakerUsage.cs
73 lines (65 loc) · 2.14 KB
/
FakerUsage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using Bogus;
// ReSharper disable RedundantArgumentDefaultValue
// ReSharper disable UnusedParameter.Local
[TestFixture]
public class FakerUsage
{
[Test]
public void Sample()
{
#region BogusUsage
var faker = new Faker<Target>()
.RuleFor(
property: u => u.Title,
setter: (f, u) => f.WaffleTitle())
.RuleFor(
property: u => u.Property1,
setter: (f, u) => f.WaffleHtml())
.RuleFor(
property: u => u.Property2,
setter: (f, u) => f.WaffleHtml(
paragraphs: 4,
includeHeading: true))
.RuleFor(
property: u => u.Property3,
setter: (f, u) => f.WaffleText())
.RuleFor(
property: u => u.Property4,
setter: (f, u) => f.WaffleText(
paragraphs: 4,
includeHeading: false));
var target = faker.Generate();
Debug.WriteLine(target.Title);
Debug.WriteLine(target.Property1);
Debug.WriteLine(target.Property2);
Debug.WriteLine(target.Property3);
Debug.WriteLine(target.Property4);
#endregion
}
[Test]
public void Run()
{
var faker = new Faker<Target>()
.RuleFor(u => u.Title, (f, u) => f.WaffleTitle())
.RuleFor(u => u.Property1, (f, u) => f.WaffleHtml())
.RuleFor(u => u.Property2, (f, u) => f.WaffleText());
var target = faker.Generate();
Trace.WriteLine(target.Title);
Trace.WriteLine(target.Property1);
Trace.WriteLine(target.Property2);
NotNull(target.Title);
IsNotEmpty(target.Title);
NotNull(target.Property1);
IsNotEmpty(target.Property1);
NotNull(target.Property2);
IsNotEmpty(target.Property2);
}
public class Target
{
public string? Property1 { get; set; }
public string? Property2 { get; set; }
public string? Property3 { get; set; }
public string? Property4 { get; set; }
public string? Title { get; set; }
}
}