-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathProduct.cs
185 lines (138 loc) · 5.09 KB
/
Product.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Collections.Generic;
using System;
namespace DotnetIsolatedTests.Common
{
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductWithOptionalId
{
public int? ProductId { get; set; }
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductName
{
public string Name { get; set; }
}
public class ProductWithoutId
{
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductWithDefaultPK
{
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductIncorrectCasing
{
public int ProductID { get; set; }
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductUtilities
{
/// <summary>
/// Returns a list of <paramref name="num"/> Products with sequential IDs, a cost of 100, and "test" as name.
/// </summary>
public static List<Product> GetNewProducts(int num)
{
var products = new List<Product>();
for (int i = 0; i < num; i++)
{
var product = new Product
{
ProductId = i,
Cost = 100 * i,
Name = "test"
};
products.Add(product);
}
return products;
}
/// <summary>
/// Returns a list of <paramref name="num"/> Products with a random cost between 1 and <paramref name="cost"/>.
/// Note that ProductId is randomized too so list may not be unique.
/// </summary>
public static List<Product> GetNewProductsRandomized(int num, int cost)
{
var r = new Random();
var products = new List<Product>(num);
for (int i = 0; i < num; i++)
{
var product = new Product
{
ProductId = r.Next(1, num),
Cost = (int)Math.Round(r.NextDouble() * cost),
Name = "test"
};
products.Add(product);
}
return products;
}
}
public class ProductColumnTypes
{
public int ProductId { get; set; }
public long BigInt { get; set; }
public bool Bit { get; set; }
public decimal DecimalType { get; set; }
public decimal Money { get; set; }
public decimal Numeric { get; set; }
public short SmallInt { get; set; }
public decimal SmallMoney { get; set; }
public short TinyInt { get; set; }
public Double FloatType { get; set; }
public Single Real { get; set; }
public DateTime Date { get; set; }
public DateTime Datetime { get; set; }
public DateTime Datetime2 { get; set; }
public DateTimeOffset DatetimeOffset { get; set; }
public DateTime SmallDatetime { get; set; }
public TimeSpan Time { get; set; }
public string CharType { get; set; }
public string Varchar { get; set; }
public string Nchar { get; set; }
public string Nvarchar { get; set; }
public override bool Equals(object obj)
{
if (obj is ProductColumnTypes)
{
var that = obj as ProductColumnTypes;
return this.ProductId == that.ProductId && this.BigInt == that.BigInt && this.Bit == that.Bit &&
this.DecimalType == that.DecimalType && this.Money == that.Money && this.Numeric == that.Numeric &&
this.SmallInt == that.SmallInt && this.SmallMoney == that.SmallMoney && this.TinyInt == that.TinyInt &&
this.FloatType == that.FloatType && this.Real == that.Real && this.Date == that.Date &&
this.Datetime == that.Datetime && this.Datetime2 == that.Datetime2 && this.DatetimeOffset == that.DatetimeOffset &&
this.SmallDatetime == that.SmallDatetime && this.Time == that.Time && this.CharType == that.CharType &&
this.Varchar == that.Varchar && this.Nchar == that.Nchar && this.Nvarchar == that.Nvarchar;
}
return false;
}
}
public class ProductExtraColumns
{
public int ProductId { get; set; }
public string Name { get; set; }
public int Cost { get; set; }
public int ExtraInt { get; set; }
public string ExtraString { get; set; }
}
public class ProductIncludeIdentity
{
public int ProductId { get; set; }
public string Name { get; set; }
public int Cost { get; set; }
}
public class ProductMissingColumns
{
public int ProductId { get; set; }
public string Name { get; set; }
}
}