25 DateFrom = DateTime.Parse(
"2020-01-01"),
26 DateTo = DateTime.Parse(
"2020-12-31"),
29 AgreementElementUpdated = DateTime.Now,
30 AgreementElementCreated = DateTime.Now
42 var res = await
service.GetAllAgreementElements();
57 await
context.SaveChangesAsync();
60 var res = await
service.GetAllAgreementElements();
75 await
context.SaveChangesAsync();
78 var res = await
service.GetAgreementElementById(1);
80 Assert.Equal(ae.DateFrom, res.DateFrom);
81 Assert.NotNull(res.Agreement);
82 Assert.NotNull(res.ModuleLevel);
96 var res = await
service.AddAgreementElement(ae);
98 Assert.Equal(ae.Discount, res.Discount);
114 var res = await
service.AddAgreementElement(ae);
116 Assert.Equal(ae.Discount, res.Discount);
131 ae.DateFrom = DateTime.Parse(
"2021-01-01");
132 var op = async () => await
service.AddAgreementElement(ae);
134 await Assert.ThrowsAsync<InvalidOperationException>(op);
AgreementElementService class inserts and updates AgreementElement in the Database
AgreementElementService Testing Environment
AgreementElement CreateAgreementElement()
Creates an agreementelement
async void GetAgreementElementsById_Success()
passes if agreementelement is added to list and found by id in the agreementelementlist
async void AddAgreementElement_FieldMissing()
passes if added agreementelement with missing fields
async void AddAgreementElement_DateFromNotBeforeDateTo()
passes if datefrom is after dateto, and throws InvalidOperationException
async void GetAllAgreementElements_Empty()
passes if agreementelement-list is empty
async void GetAllAgreementElements_NotEmpty()
passses if agreementelement-list is not empty after insertion
async void AddAgreementElement_Success()
passes if agreementelement is added
static DataContext GetContext()
Creates a testcontext for testing
Reusable methods for inserting information into tests
static DataContext InsertDataForAgreementElement(DataContext context)
Uses InsertDataForAgreement Then add agreement with references to a currency, a product and a custome...