public async Task EditLoadAsync_WithCorrectData_ShouldEditLoad() { var context = SteuDbContextInMemoryFactory.InitializeContext(); LoadsService service = IntializeLoadService(context); var repository = new EfDeletableEntityRepository <Order>(context); await repository.AddAsync(new Order() { Id = "asdasd", Load = new Load(), }); await context.SaveChangesAsync(); EditLoadViewModel model = new EditLoadViewModel() { Id = "asdasd", CountryFrom = "Bulgaria", TownFrom = "Sofia", CountryTo = "Croatia", TownTo = "Zagreb", TruckTypeName = "Normal", Priority = "Normal", Circle = false, ExpireTime = DateTime.UtcNow, LoadDeliveryTime = DateTime.UtcNow, LoadTime = DateTime.UtcNow, LoadVolume = 100, LoadWeight = 20000, Price = 12312231, Referer = "dasada", InputModel = new LoadEditViewModel(), }; await service.EditLoadAsync(model); var actualResult = await repository.All().ToListAsync(); Assert.Equal(12312231, actualResult[0].Price); }
public async Task EditLoadAsync_WithIncorectOrderId_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); LoadsService service = IntializeLoadService(context); var repository = new EfDeletableEntityRepository <Order>(context); await repository.AddAsync(new Order() { Id = "asdasd", Load = new Load(), }); await context.SaveChangesAsync(); EditLoadViewModel model = new EditLoadViewModel() { Id = "asd", CountryFrom = "Bulgaria", TownFrom = "Sofia", CountryTo = "Croatia", TownTo = "Zagreb", TruckTypeName = "Normal", Priority = "Normal", Circle = false, ExpireTime = DateTime.UtcNow, LoadDeliveryTime = DateTime.UtcNow, LoadTime = DateTime.UtcNow, LoadVolume = 100, LoadWeight = 20000, Price = 12312231, Referer = "dasada", InputModel = new LoadEditViewModel(), }; await Assert.ThrowsAsync <ArgumentNullException>(() => service.EditLoadAsync(model)); }