public CategoryRepositoryTests()
        {
            DbContextOptionsBuilder <MMTShopContext> optionsBuilder = new DbContextOptionsBuilder <MMTShopContext>()
                                                                      .UseInMemoryDatabase(Guid.NewGuid().ToString());

            _context = new MMTShopContext(optionsBuilder.Options);

            _context.Categories.AddRange(new List <Category>()
            {
                new Category()
                {
                    Id = Guid.NewGuid(), Name = "CategoryOne"
                },
                new Category()
                {
                    Id = Guid.NewGuid(), Name = "CategoryTwo"
                },
                new Category()
                {
                    Id = Guid.NewGuid(), Name = "CategoryThree"
                }
            });
            _context.SaveChanges();

            _logger = new NullLogger <CategoryRepository>();
        }
Example #2
0
        public ProductRepositoryTests()
        {
            DbContextOptionsBuilder <MMTShopContext> optionsBuilder = new DbContextOptionsBuilder <MMTShopContext>()
                                                                      .UseInMemoryDatabase(Guid.NewGuid().ToString());

            _context = new MMTShopContext(optionsBuilder.Options);

            _context.Products.AddRange(new List <Product>()
            {
                new Product()
                {
                    Sku = "12345", Name = "Product1", Description = "Product1 is nice", Price = 9.99d
                },
                new Product()
                {
                    Sku = "22345", Name = "Product2", Description = "Product2 is nice", Price = 9.99d
                },
                new Product()
                {
                    Sku = "32345", Name = "Product3", Description = "Product3 is nice", Price = 9.99d
                },
                new Product()
                {
                    Sku = "42345", Name = "Product4", Description = "Product4 is nice", Price = 9.99d
                },
                new Product()
                {
                    Sku = "52345", Name = "Product5", Description = "Product5 is nice", Price = 9.99d
                },
            });
            _context.SaveChanges();

            _logger     = new NullLogger <ProductRepository>();
            _configMock = new Mock <IOptions <ApiOptions> >();
        }
Example #3
0
 public CategoryController(MMTShopContext context)
 {
     _context = context;
 }
Example #4
0
 public ProductController(MMTShopContext context)
 {
     _context = context;
 }
Example #5
0
 public ProductRepository(MMTShopContext context)
 {
     this._context = context;
 }
Example #6
0
        public UnitOfWork(string connectionString)
        {
            var contextOptions = new DbContextOptionsBuilder <MMTShopContext>().UseSqlServer(connectionString).Options;

            _MMTShopContext = new MMTShopContext(contextOptions);
        }
Example #7
0
 public CategoryRepository(MMTShopContext context)
 {
     this._context = context;
 }