public async Task AddOrder_ExistingCustomerInvalidParams_ThrowsException() { using (var context = new CustomersDbContext(_options)) { var order = new OrderDto() { Price = -234.45m, CreatedDate = DateTime.Today }; var repository = new CustomersRepository(context, _mapper); Func <Task <OrderDto> > result = async() => await repository.AddOrderAsync(1, order); await result.Should().ThrowAsync <ValidationException>(); } }
public async Task AddOrder_ExistingCustomerValidParams_CreatesAndReturns() { using (var context = new CustomersDbContext(_options)) { var order = new OrderDto() { Price = 234.45m, CreatedDate = DateTime.Today }; var repository = new CustomersRepository(context, _mapper); var result = await repository.AddOrderAsync(1, order); result.Id.Should().BeGreaterThan(0); result.Should().BeEquivalentTo(order, opt => opt.Excluding(o => o.Id)); } }