public async Task SaveSupplierUpdateSuccess_Test() { Suppliers supplier1 = new Suppliers() { Id = 1, Name = "abc", Address = "123", Phone = "123456789", Email = "*****@*****.**" }; _dbContext.Set <Suppliers>().Add(supplier1); SupplierViewModel model = new SupplierViewModel() { Id = 1, Name = "abc123", Address = "123", Phone = "123456789", Email = "*****@*****.**" }; await _dbContext.SaveChangesAsync(); var efRepository = new EfRepository <Suppliers>(_dbContext); var saveSupplierCommand = new SaveSupplierCommand(efRepository); var result = await saveSupplierCommand.ExecuteAsync(model); var getListSupplier = new GetListSupplier(efRepository); var supplier = (await getListSupplier.ExecuteAsync()).FirstOrDefault(); Assert.Equal(result.Data, model.Id); Assert.Equal(model.Name, supplier.Name); }
public async Task GetListSupplier_Test() { var supplier1 = new Suppliers { Id = 1, Name = "Supplier1", Enabled = true }; _dbContext.Set <Suppliers>().Add(supplier1); var supplier2 = new Suppliers { Id = 2, Name = "Supplier2", Enabled = false }; _dbContext.Set <Suppliers>().Add(supplier2); await _dbContext.SaveChangesAsync(); var efRepository = new EfRepository <Suppliers>(_dbContext); var getListSupplier = new GetListSupplier(efRepository); var suppliers = await getListSupplier.ExecuteAsync(); Assert.NotNull(suppliers); Assert.Equal(2, suppliers.Count); }
public async Task SaveSupplierInsertSuccess_Test() { SupplierViewModel model = new SupplierViewModel() { Id = 0, Name = "abc", Address = "123", Phone = "123456789", Email = "*****@*****.**", Enabled = true }; var efRepository = new EfRepository <Suppliers>(_dbContext); var saveSupplierCommand = new SaveSupplierCommand(efRepository); var result = await saveSupplierCommand.ExecuteAsync(model); var getListSupplier = new GetListSupplier(efRepository); var supplier = (await getListSupplier.ExecuteAsync()).FirstOrDefault(); Assert.Equal(result.Data, model.Id); Assert.Equal(model.Name, supplier.Name); Assert.Equal(model.Address, supplier.Address); Assert.Equal(model.Phone, supplier.Phone); Assert.Equal(model.Email, supplier.Email); Assert.Equal(model.Enabled, supplier.Enabled); }