Escali License control 1
TestData.cs
Gå til dokumentasjonen til denne filen.
1using System;
4
6{
10public class TestData
11{
12
17 public static Product CreateProduct()
18 {
19 return new Product() { ProductName = "BestProductEver" };
20 }
21
29 {
30 context.Products.Add(CreateProduct());
31 context.SaveChanges();
32 return context;
33 }
34
42 {
43 var product = context.Products.Add(new Product() { ProductName = "BestProductEver" });
44 context.Modules.Add(new Module() { ModuleName = "FirstModule", Product = product.Entity });
45 context.SaveChanges();
46 return context;
47 }
48
56 {
57 var product = context.Products.Add(new Product() { ProductName = "BestProductEver" });
58 context.Products.Add(new Product() { ProductName = "AnotherProduct" });
59 context.Modules.Add(new Module() { ModuleName = "FirstModule", Product = product.Entity });
60 context.SaveChanges();
61 return context;
62 }
63
70 {
72 context.ModuleLevels.Add(new ModuleLevel()
73 {
74 ModuleLevelName = "Stock and fond 1",
75 ModuleLevelRestriction = "250M/100tr",
76 ModuleSeq = 1,
77 });
78 context.SaveChanges();
79 return context;
80 }
81
88 {
89 context.Currencies.Add(new Currency() { CurrencyName = "USD" });
90 context.SaveChanges();
91 return context;
92 }
93
101 {
103 context.PriceLists.Add(new PriceList()
104 {
105 PriceListName = "2022",
106 DateFrom = DateTime.Parse("2017-01-01"),
107 DateTo = DateTime.Parse("2017-12-31"),
108 CurrencySeq = 1,
109 ProductSeq = 1
110 });
111 context.SaveChanges();
112 return context;
113 }
114
121 {
124 return context;
125 }
126
133 {
134 context.Customers.Add(new Customer
135 {
136 OrganizationNumber = "123 456 789",
137 CustomerName = "Customer1",
138 CustomerSince = DateTime.Now
139 });
140 context.SaveChanges();
141 return context;
142 }
143
150 {
151 context.Customers.Add(new Customer
152 {
153 OrganizationNumber = "123 456 789",
154 CustomerName = "Customer1",
155 CustomerSince = DateTime.Now
156 });
157 context.Customers.Add(new Customer
158 {
159 OrganizationNumber = "111 111 111",
160 CustomerName = "Customer2",
161 CustomerSince = DateTime.Now
162 });
163 context.SaveChanges();
164 return context;
165 }
166
173 {
174 context.Customers.Add(new Customer
175 {
176 OrganizationNumber = "123 456 789",
177 CustomerName = "Customer1",
178 CustomerSince = DateTime.Now,
179 Region = new Region()
180 {
181 Country = "Norge",
182 Area = "Bergen"
183 }
184 });
185 context.Customers.Add(new Customer
186 {
187 OrganizationNumber = "888 888 888",
188 CustomerName = "CustomerTest",
189 CustomerSince = DateTime.Now,
190 Region = new Region()
191 {
192 Country = "Norge"
193 }
194 });
195 context.SaveChanges();
196 return context;
197 }
198
206 {
210 return context;
211 }
212
221 {
223 context.Agreements.Add(new Agreement()
224 {
225 AgreementName = "Escali Financials",
226 AgreementCreated = DateTime.Now,
227 CurrencySeq = 1,
228 ProductSeq = 1,
229 CustomerSeq = 1,
230 AgreementUpdated = DateTime.Now
231 });
232 context.SaveChanges();
233 context.Modules.Add(new Module() { ModuleName = "Module1", ProductSeq = 1 });
234 context.SaveChanges();
235 context.ModuleLevels.Add(new ModuleLevel()
236 {
237 ModuleLevelName = "Stock and fond 1",
238 ModuleLevelRestriction = "250M/100tr",
239 ModuleSeq = 1,
240 });
241 context.SaveChanges();
242
243 return context;
244 }
245
246 }
247
248}
249
var context
Definition: Program.cs:49
Reusable methods for inserting information into tests
Definition: TestData.cs:11
static DataContext InsertCustomers(DataContext context)
Insert two Customers into DataContext
Definition: TestData.cs:149
static DataContext InsertProductAndModule(DataContext context)
Inserts Product and Module into the context Used for inserting product and module into the test envir...
Definition: TestData.cs:41
static DataContext InsertCustomerWithRegionData(DataContext context)
Inserts two Customer combined with region data into the DataContext
Definition: TestData.cs:172
static DataContext InsertDataForPriceElement(DataContext context)
Definition: TestData.cs:120
static DataContext InsertDataForAgreement(DataContext context)
Combined insertion for Currency, Product and Customer into DataContext for broader test option
Definition: TestData.cs:205
static DataContext InsertProduct(DataContext context)
Inserts Product into the context Used for inserting product into the test environment
Definition: TestData.cs:28
static Product CreateProduct()
Creates a Product
Definition: TestData.cs:17
static DataContext InsertDataForAgreementElement(DataContext context)
Uses InsertDataForAgreement Then add agreement with references to a currency, a product and a custome...
Definition: TestData.cs:220
static DataContext InsertCurrency(DataContext context)
Inserts Currency into DataContext
Definition: TestData.cs:87
static DataContext InsertDoubleProductAndModule(DataContext context)
Inserts two Product and Module into the context Used for inserting product and module into the test e...
Definition: TestData.cs:55
static DataContext InsertModuleLevelAndFKs(DataContext context)
Adds a ModuleLevel to an Module with a FK
Definition: TestData.cs:69
static DataContext InsertCustomer(DataContext context)
Inserting customer into DB (only non nullable field defined)
Definition: TestData.cs:132
static DataContext InsertPriceList(DataContext context)
Inserts a PriceList into DataContext Product must be inserted before this method is called
Definition: TestData.cs:100