public async Task GetPolicyTypes() { var options = TestHelper.GetDbContext("GetPolicyTypes"); //Given var lkp1 = new PolicyTypeEntity { Id = Guid.NewGuid(), Name = "C", Code = "cc", DisplayOrder = 1 }; var lkp2 = new PolicyTypeEntity { Id = Guid.NewGuid(), Name = "B", Code = "bb", DisplayOrder = 2 }; var lkp3 = new PolicyTypeEntity { Id = Guid.NewGuid(), Name = "A", Code = "aa", DisplayOrder = 3 }; using (var context = new DataContext(options)) { //Jumbled order context.PolicyType.Add(lkp2); context.PolicyType.Add(lkp1); context.PolicyType.Add(lkp3); context.SaveChanges(); } using (var context = new DataContext(options)) { var service = new ClientLookupService(context); //When var actual = await service.GetPolicyTypes(); //Then Assert.Equal(3, actual.Count); var actual1 = actual[0]; Assert.Equal(lkp1.Id, actual1.Id); Assert.Equal(lkp1.Name, actual1.Name); Assert.Equal(lkp1.Code, actual1.Code); var actual2 = actual[1]; Assert.Equal(lkp2.Id, actual2.Id); var actual3 = actual[2]; Assert.Equal(lkp3.Id, actual3.Id); } }
public static PolicyTypeEntity InsertPolicyType(DbContextOptions <DataContext> options) { var type = new PolicyTypeEntity { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), Code = Guid.NewGuid().ToString() }; using (var context = new DataContext(options)) { context.PolicyType.Add(type); context.SaveChanges(); }; return(type); }