public void TestProductServiceAfterUpdated() { var dbcontext = new MemoryDbContext { Products = new MemDbSet <Product>() }; var productService = new ProductService(dbcontext); var productToCheck = new Product { Id = 1, Name = "123", Price = 100 }; productService.Add(productToCheck); productService.Add(new Product { Id = 2, Name = "123", Price = 350 }); var productToCheck2 = new Product { Id = 1, Name = "333", Price = 0 }; productService.Update(productToCheck2); productToCheck2 = new Product { Id = 2, Name = "333", Price = 10 }; productService.Update(productToCheck2); Assert.AreEqual(productService.Sum, 10); }
static void Main() { var options = new DbContextOptionsBuilder <MemoryDbContext>() .UseInMemoryDatabase(databaseName: "TEST") .Options; _context = new MemoryDbContext(options); _bus = CreateRabbitBus(); while (true) { } }
public void TestProductsCountAfterAdd() { var dbcontext = new MemoryDbContext(); var product = new Product { Id = 1, Name = "123" }; dbcontext.Products.Add(product); dbcontext.Products.Add(new Product { Id = 2, Name = "345" }); dbcontext.Products.Remove(product); Assert.AreEqual(dbcontext.Products.Count(), 1); }
public void TestProductServiceSumAfterAdd() { var dbcontext = new MemoryDbContext { Products = new MemDbSet <Product>() }; var productService = new ProductService(dbcontext); productService.Add(new Product { Id = 1, Name = "123", Price = 100 }); productService.Add(new Product { Id = 2, Name = "123", Price = 350 }); Assert.AreEqual(productService.Sum, 450); }
public void TestProductServiceCountAfterAdd() { var dbcontext = new MemoryDbContext { Products = new MemDbSet <Product>() }; var productService = new ProductService(dbcontext); productService.Add(new Product { Id = 1, Name = "123" }); productService.Add(new Product { Id = 2, Name = "123" }); Assert.AreEqual(productService.Count(), 2); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MemoryDbContext( serviceProvider.GetRequiredService <DbContextOptions <MemoryDbContext> >())) { if (context.DistrictsCoordinates.Any()) { return; // Data was already seeded } var type = "FeatureCollection"; var test = Directory.GetParent(Environment.CurrentDirectory).ToString(); var districtsCoordinatesJSONString = File.ReadAllText(Path.Combine(Directory.GetParent(Environment.CurrentDirectory).ToString(), "Web.Api.Infrastructure\\Data\\Generator\\districtscoordinates.json")); context.DistrictsCoordinates.Add( new DistrictsCoordinates(type, districtsCoordinatesJSONString) ); context.SaveChanges(); } }
public void TestProductsSetAfterUpdated() { var dbcontext = new MemoryDbContext { Products = new MemDbSet <Product>() }; dbcontext.Products.Add(new Product { Id = 1, Name = "123" }); dbcontext.Products.Add(new Product { Id = 2, Name = "345" }); // product.Name = "555"; var newProduct = new Product { Id = 1, Name = "999" }; dbcontext.Update(newProduct); dbcontext.SaveChanges(); Assert.AreEqual(dbcontext.Products.ToArray()[0].Name, "999"); }
public DataTableService(MemoryDbContext context, AutoMapper.IConfigurationProvider mappingConfiguration) { this._context = context; this._mappingConfiguration = mappingConfiguration; }
public BaseRepository(MemoryDbContext context) { _context = context; }
public ProductRepository(MemoryDbContext context) : base(context) { }
public ProductGeneratedConsumer(MemoryDbContext _context) { this.dbContext = _context; }
public MemoryController(MemoryDbContext db) { this.db = db; }