public static SoftwareHutPreviewDbContext Create() { var options = new DbContextOptionsBuilder <SoftwareHutPreviewDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new SoftwareHutPreviewDbContext(options); context.Database.EnsureCreated(); context.Categories.Add(new Category { Id = 1, Name = "Cpus" }); var cpus = context.Categories.SingleOrDefault(); context.Products.AddRange(new[] { new Product() { Id = 3, Name = "Ryzen 4600fx", Description = "Procesor nowej generacji od Amd.", Category = cpus, Price = 1900 }, new Product() { Id = 4, Name = "Intel i7-9900k", Description = "Procesor 9 już generacji od intela.", Category = cpus, Price = 1400 }, new Product() { Id = 5, Name = "Intel i5-9900k", Description = "Budzetowa wersja dla kazdego.", Category = cpus, Price = 1400 } }); context.SaveChanges(); return(context); }
public UpdateProductValidator(SoftwareHutPreviewDbContext context) { _context = context; RuleFor(x => x.Name) .NotEmpty() .NotNull() .MaximumLength(60); RuleFor(d => d.Description) .NotEmpty() .NotNull() .MaximumLength(60); RuleFor(p => p.Price) .NotEmpty() .GreaterThan(0.0m).WithMessage("Wartość pola cena musi być większa od 0"); }
public DeleteProductHandler(SoftwareHutPreviewDbContext context) { _context = context; }
public GetAllProductsHandler(SoftwareHutPreviewDbContext context) { _context = context; }
public GetAllCategoriesHandler(SoftwareHutPreviewDbContext context) { _context = context; }
public static void Destroy(SoftwareHutPreviewDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public CommandTestBase() { _context = SoftwareHutPreviewContextFactory.Create(); }