Escali License control 1
AgreementServiceTest.cs
Gå til dokumentasjonen til denne filen.
1using System;
5using Xunit;
6
8{
9
14{
15
21 {
22 return new Agreement()
23 {
24 AgreementName = "Escali Financials",
25 AgreementCreated = DateTime.Now,
26 CurrencySeq = 1,
27 ProductSeq = 1,
28 CustomerSeq = 1
29 };
30 }
31
35 [Fact]
36 public async void AddAgreement_Success()
37 {
40
41 var agreement = CreateAgreement();
42
44 var res = await service.AddAgreement(agreement);
45
46 Assert.Equal(agreement.AgreementName, res.AgreementName);
47 Assert.NotNull(res.Currency);
48 Assert.NotNull(res.Product);
49 Assert.NotNull(res.Customer);
50 }
51
55 [Fact]
57 {
60
61 var agreement = CreateAgreement();
62
64 var res = await service.AddAgreement(agreement);
65
66 Assert.NotNull(res.AgreementUpdated);
67 }
68
72 [Fact]
74 {
77
78 var agreement = CreateAgreement();
79 agreement.AgreementUpdated = DateTime.Now;
80 var res = context.Agreements.Add(agreement);
81 await context.SaveChangesAsync();
82
83 var lastChanged = res.Entity.AgreementUpdated;
84
86 var updatedAgreement = await service.UpdateAgreement(res.Entity);
87
88 Assert.NotEqual(lastChanged, updatedAgreement.AgreementUpdated);
89 }
90
91 }
92}
var context
Definition: Program.cs:49
var service
Definition: Program.cs:48
AgreementService class inserts and updates Agreement in the Database
async void AddAgreement_DateChangedAdded()
passes if correctly added agreeement
async void AddAgreement_Success()
passes if agreement is correctly inserted into agreementlist
async void UpdateAgreement_DateChangedAdded()
passes if correctly updated agreeement-date, and not equal previous set date
static DataContext GetContext()
Creates a testcontext for testing
Definition: TestBase.cs:14
Reusable methods for inserting information into tests
Definition: TestData.cs:11
static DataContext InsertDataForAgreement(DataContext context)
Combined insertion for Currency, Product and Customer into DataContext for broader test option
Definition: TestData.cs:205