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));
        }
Exemple #3
0
 public ProductService(DataLayer.Context context)
 {
     _context = context;
 }