public void GetByPersnrTest() { var options = CreateNewContextOptions(); // Run the test against one instance of the context using (var context = new ModelDbContext(options)) { List <Person> list = createData(); foreach (var p in list) { context.Person.Add(p); } context.SaveChanges(); PersonCreateUpdateDeleteFake crudFake = new PersonCreateUpdateDeleteFake(); PersonController controller = new PersonController(context, crudFake); var response = controller.GetByPersnr("min", "pse", 12345); Assert.True(response.success == "true"); Assert.True(response.result.First().ForNamn == "Per"); } }
public void CreateTest() { var options = CreateNewContextOptions(); // Run the test against one instance of the context using (var context = new ModelDbContext(options)) { PersonViewModelSave PVmodel = new PersonViewModelSave(); PVmodel.PersonNummer = "12345"; PVmodel.ForNamn = "Per"; PVmodel.EfterNamn = "Nilsson"; PersonCode pc = new PersonCode(context); PersonCreateUpdateDeleteFake crudFake = new PersonCreateUpdateDeleteFake(); PersonController controller = new PersonController(context, crudFake); var response = controller.Create(PVmodel); Assert.True(response.success == "true"); } }