public void GetNumberOfProductByInvoiceId_Success_ReturnInt() { // Arrange var repository = new InvoiceProductRepository(); // Act var result = repository.GetNumberOfProductByInvoiceId(1, 1); // Assert Assert.That(result >= 0); }
public WarrantyOrder AddNewWarrantyOrder(ProductForWarrantyDto customerProduct) { // check if this product has already been add to warranty order? (through InvoiceId, ProductId) var noProductsBought = _invoiceProductRepository.GetNumberOfProductByInvoiceId(customerProduct.InvoiceId, customerProduct.Id); var noProductsOnWarratyOrders = _warrantyOrderRepository.GetNumberOfWarrantyOrderByInvoiceIdAndProductId(customerProduct.InvoiceId, customerProduct.Id); if (noProductsOnWarratyOrders == noProductsBought) { throw new Exception("Sản phẩm này đang được bảo hành rồi!"); } // now we can actually add it var warrantyOrder = Mapper.Map <WarrantyOrder>(customerProduct); warrantyOrder.Status = (int)WarrantyOrderStatus.WaitForSent; warrantyOrder.CreationTime = DateTime.Now; return(_warrantyOrderRepository.Create(warrantyOrder)); }