Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
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));
        }