public void Ctor_Should_Throw_ArgumentNullException_If_Context_Is_Null() { RegistriesContext context = null; var ex = Assert.Throws <ArgumentNullException>(() => new EFCore.Repository.Repository(context)); Assert.Equal(nameof(context), ex.ParamName); }
private void BuildContext() { var options = new DbContextOptionsBuilder <RegistriesContext>() .UseInMemoryDatabase(databaseName: "InMemory-ReadModels-Registries") .Options; Context = new RegistriesContext(options); }
public void CleanAllData(RegistriesContext context) { if (context.ShippingAddresses.Any()) { context.ShippingAddresses.RemoveRange(context.ShippingAddresses); } if (context.BillingInfos.Any()) { context.BillingInfos.RemoveRange(context.BillingInfos); } if (context.Customers.Any()) { context.Customers.RemoveRange(context.Customers); } context.SaveChanges(); }
/// <summary> /// Construct the registries database /// </summary> /// <param name="context">The instance of the registries context</param> public RegistriesDatabase(RegistriesContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
/// <summary> /// Construct the repository the registries context /// </summary> /// <param name="context">The registries context instance</param> public Repository(RegistriesContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public void PrepareData(RegistriesContext context, Action <RegistriesContext> prepare) { prepare.Invoke(context); context.SaveChanges(); }