public double GetCustomerDiscount(ICustomerIdentifier customer) { return(CreateDbContext().Customers.AsNoTracking() .SingleOrDefault(cust => cust.CustomerId == customer.CustomerId) ?.Discount ?? throw new CustomerNotFoundException(customer)); }
private void SetupCustomerDiscount(ICustomerIdentifier customer, double discount) { _repo .Setup(repo => repo.GetCustomerDiscount(customer)) .Returns(discount); }
public CustomerNotFoundException(ICustomerIdentifier customer) : base($"Customer {customer.CustomerId} was not found") { Customer = customer; }