public void Create_Success_ReturnEntity() { // Arrange var repository = new WarrantyOrderRepository(); var input = GenerateInput(); // Act var result = repository.Create(input); // Assert Assert.That(CompareProperties(input, result)); }
public void Get_Success_ReturnEntity() { // Arrange var repository = new WarrantyOrderRepository(); var input = repository.Create(GenerateInput()); // Act var result = repository.Get(input.Id); // Assert Assert.IsInstanceOf <WarrantyOrder>(result); }
public void Delete_Success_ReturnNull() { // Arrange var repository = new WarrantyOrderRepository(); var input = repository.Create(GenerateInput()); // Act repository.Delete(input.Id); var result = repository.Get(input.Id); // Assert Assert.IsNull(result); }
public void Update_Success_ReturnTrue() { // Arrange var repository = new WarrantyOrderRepository(); var input = repository.Create(GenerateInput()); var inputForUpdate = GenerateInput(id: input.Id); // Act var result = repository.Update(inputForUpdate); // Assert Assert.IsTrue(result); }
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)); }