-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestUtils.cs
112 lines (100 loc) · 2.76 KB
/
TestUtils.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using Bogus;
using ExcelBattle.Models;
using Person = ExcelBattle.Models.Person;
namespace ExcelBattle;
public static class TestUtils
{
private static readonly Faker _faker = new();
public static Company GenerateCompany()
{
return new Company(
_faker.Company.CompanyName(),
_faker.Address.StreetAddress(),
_faker.Address.City(),
_faker.Address.State(),
_faker.Address.ZipCode(),
(double)_faker.Random.Decimal(1000, 1000000),
_faker.Random.Int(10, 10000)
);
}
public static Company[] GenerateCompanies(int count)
{
var companies = new List<Company>();
for (var i = 0; i < count; i++)
{
companies.Add(GenerateCompany());
}
return companies.ToArray();
}
public static Product GenerateProduct()
{
return new Product(
_faker.Commerce.ProductName(),
_faker.Commerce.ProductDescription(),
(double)_faker.Finance.Amount(10, 1000)
);
}
public static Product[] GenerateProducts(int count)
{
var products = new List<Product>();
for (var i = 0; i < count; i++)
{
products.Add(GenerateProduct());
}
return products.ToArray();
}
public static Contact GenerateContact()
{
return new Contact(
_faker.Name.FirstName(),
_faker.Name.LastName(),
_faker.Internet.Email(),
_faker.Phone.PhoneNumber()
);
}
public static Contact[] GenerateContacts(int count)
{
var contacts = new List<Contact>();
for (var i = 0; i < count; i++)
{
contacts.Add(GenerateContact());
}
return contacts.ToArray();
}
public static Address GenerateAddress()
{
return new Address(
_faker.Address.StreetAddress(),
_faker.Address.City(),
_faker.Address.State(),
_faker.Address.ZipCode()
);
}
public static Address[] GenerateAddresses(int count)
{
var addresses = new List<Address>();
for (var i = 0; i < count; i++)
{
addresses.Add(GenerateAddress());
}
return addresses.ToArray();
}
public static Person GeneratePerson()
{
return new Person(
_faker.Name.FirstName(),
_faker.Name.LastName(),
_faker.Random.Int(18, 80),
_faker.Address.StreetAddress()
);
}
public static Person[] GeneratePeople(int count)
{
var people = new List<Person>();
for (var i = 0; i < count; i++)
{
people.Add(GeneratePerson());
}
return people.ToArray();
}
}