public async Task AddOrderIncome(CreateViewModel orderModel) { // we create the date with the current date var dateOrderIncome = DateTime.Now; OrderIncome order = new OrderIncome { IdProvider = orderModel.IdProvider, IdUser = orderModel.IdUser, Total = orderModel.Total, State = "Accept" }; _context.OrderIncomes.Add(order); await _context.SaveChangesAsync(); // Adding details to detailOrder var IdOrderIncome = order.IdOrderIncome; // We loop de property details in CreateViewModel to add every // detail in OrderDetail Table in the same method Add of OrderIncome foreach (var det in orderModel.Details) { OrderIncomeDetails detail = new OrderIncomeDetails { IdOrderIncome = IdOrderIncome, IdProduct = det.IdProduct, Amount = det.Amount, DueDate = det.DueDate, UnitCost = det.UnitCost }; _context.OrderIncomeDetails.Add(detail); } await _context.SaveChangesAsync(); }
public void SetRegistroBitacoraStatusOk() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); //Act(Actuar) order.SetRegistroBitacoraStatus(); //Assert(Afirmar) order.OrderIncomeStatusId.ShouldBe(OrderIncomeStatus.RegistroBitacora.Id); }
public void SetCompletadoStatusOk() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); //Act(Actuar) order.SetRegistroBitacoraStatus(); order.SetDianStatus(); order.SetVerificacionBitacoraStatus(); order.SetCompletadoStatus(); //Assert(Afirmar) order.OrderIncomeStatusId.ShouldBe(OrderIncomeStatus.Completado.Id); }
public void SetCompletadoStatusFail() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); //Act(Actuar) // No se hacen los Estados previos //Assert(Afirmar) Should.Throw <Exception>(() => { order.SetCompletadoStatus(); }); }
public void SetRegistroBitacoraStatusFail() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); //Act(Actuar) order.SetRegistroBitacoraStatus(); //Assert(Afirmar) Should.Throw <Exception>(() => { order.SetRegistroBitacoraStatus(); }); }
public void SetTheCustomerForThisOrderOk() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); string lastName = "El rojo"; string firstName = "Jhon"; string telephone = "+34111111"; string company = "company name"; Customer customernew = CustomerFactory.CreateCustomer(firstName, lastName, telephone, company, "*****@*****.**", _country, new Address("city", "zipcode", "AddressLine1", "AddressLine2")); //Act(Actuar) order.CustomerId.ShouldBe(_customer.Id); order.SetTheCustomerForThisOrder(customernew); //Assert(Afirmar) order.CustomerId.ShouldBe(customernew.Id); }
public OrderIncomeAggTest() { OrderIncome order = new OrderIncome(); //Constructor EF string lastName = "El rojo"; string firstName = "Jhon"; string telephone = "+34111111"; string company = "company name"; _country = CountryFactory.CreateCountry("Spain", "es-ES"); _customer = CustomerFactory.CreateCustomer(firstName, lastName, telephone, company, "*****@*****.**", _country, new Address("city", "zipcode", "AddressLine1", "AddressLine2")); for (int i = 0; i < 5; i++) { Product prod = ProductFactory.CreateProduct("product" + i, "description" + i); _products.Add(prod); } }
public void SetTheCustomerReferenceForThisOrderFail() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); string lastName = "El Negro"; string firstName = "Alex"; string telephone = "+34111111"; string company = "company name"; Customer customernew = CustomerFactory.CreateCustomer(firstName, lastName, telephone, company, "*****@*****.**", _country, new Address("city", "zipcode", "AddressLine1", "AddressLine2")); //Act(Actuar) order.CustomerId.ShouldBe(_customer.Id); //Assert(Afirmar) Should.Throw <Exception>(() => { order.SetTheCustomerReferenceForThisOrder(Guid.Empty); }); }
public void AddOrderItemOk() { //Arrange(Preparar) OrderIncome order = OrderFactory.CreateOrder(_customer, "", "", ""); MeasurentUnit measurentUnit = MeasurentUnitFactory.CreateMeasurentUnit(MeasurentUnitType.Longitud, "Litro"); //Act(Actuar) Product product = _products.First(); int amount = 1; order.AddOrderItem(product, measurentUnit, amount); //Assert(Afirmar) order.OrderIncomeLines.Count.ShouldBe(1); OrderIncomeLine xline = order.OrderIncomeLines .SingleOrDefault(o => (o.ProductId == product.Id && o.MeasurentUnitId == measurentUnit.Id)); xline.ShouldNotBeNull(); xline?.ProductId.ShouldBe(product.Id); xline?.Amount.ShouldBe(amount); }
public async Task DeleteOrderIncome(OrderIncome order) { _context.OrderIncomes.Remove(order); await _context.SaveChangesAsync(); }