public void GetAll_PagingLimitIsZero_ArgumentExceptionThrown() { var builder = new DbContextOptionsBuilder <DataLayer.Context>(); builder.UseInMemoryDatabase(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()); using var context = new DataLayer.Context(builder.Options); var tested = new ProductService(context); Assert.Throws <ArgumentException>(() => tested.GetAll(new PagingParam { Limit = 0, Offset = 0 })); }
private DataLayer.Context CreateContextWithTestProducts(IEnumerable <Product> testData) { var builder = new DbContextOptionsBuilder <DataLayer.Context>(); builder.UseInMemoryDatabase(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()); var options = builder.Options; using (var context = new DataLayer.Context(options)) { context.Products.RemoveRange(context.Products); context.Products.AddRange(testData); context.SaveChanges(); } return(new DataLayer.Context(options)); }
public ProductService(DataLayer.Context context) { _context = context; }