private void WithDbContext(Action <FooContext> action) { using (var context = new FooContext(optionsBuilder.Options)) { action.Invoke(context); } }
public void use_ModelFooService_to_interact() { using (var context = new FooContext(optionsBuilder.Options)) { var modelFooRepository = new ModelFooRepository(context); var modelFooService = new ModelFooService(modelFooRepository); var modelFoo = modelFooService.ValidateAndInsertOrUpdate(new ModelFoo { Name = "Test 1" }); modelFooService.SaveChanges(); Assert.NotEqual(default(ModelFoo), modelFoo); } }
public void composite_foo_tests() { using (var context = new FooContext(optionsBuilder.Options)) { var compositeFooRepository = new CompositeFooRepository(context); var compositeFooService = new CompositeFooService(compositeFooRepository); var modelFoo = compositeFooService.InsertOrUpdate(new CompositeFoo { Name = "Test 1" }, true); compositeFooService.SaveChanges(); modelFoo = compositeFooService.Find(0, 0); Assert.NotNull(modelFoo); } }
public CompositeFooRepository(FooContext fooContext) : base(fooContext) { }
public ModelFooRepository(FooContext fooContext) : base(fooContext) { }