Ejemplo n.º 1
0
        private bool ValidateOrderItemCollection(Order order)
        {
            var isValid = true;

            if (order.OrderItemCollection.Count != ORDER_ITEMS_COUNT)
            {
                isValid = false;
            }
            else
            {
                foreach (var orderItem in order.OrderItemCollection)
                {
                    var orderItemIsValid =
                        order.OrderItemCollection.Count(q => q.Sequence == orderItem.Sequence) == 1 &&
                        orderItem.Description == CreateOrderItemDescription(orderItem.Sequence) &&
                        orderItem.Quantity == ORDER_ITEM_QUANTITY &&
                        orderItem.UnitPrice == ORDER_ITEM_UNIT_PRICE &&
                        orderItem.Total == ORDER_ITEM_UNIT_PRICE * ORDER_ITEM_QUANTITY &&
                        orderItem.Order == order &&
                        orderItem.Product.Code == ProductTest.PRODUCT_CODE &&
                        AuditableInfoValueObjectTest.IsValidForCreation(orderItem.AuditableInfo)
                    ;

                    if (!orderItemIsValid)
                    {
                        isValid = false;
                        break;
                    }
                }
            }

            return(isValid);
        }
Ejemplo n.º 2
0
 public static bool ActiveCustomerIsValidToImport(Customer customer)
 {
     return
         (customer.Id != Guid.Empty &&
          customer.Name == CUSTOMER_NAME &&
          customer.BirthDate.GetValueOrDefault().Date == DateTime.UtcNow.AddYears(-CUSTOMER_YEARS_OLD).Date &&
          TenantInfoValueObjectTest.IsValid(customer.TenantInfo) &&
          AuditableInfoValueObjectTest.IsValidForCreation(customer.AuditableInfo) &&
          ActivationInfoValueObjectTest.IsValidForActivation(customer.ActivationInfo)
         );
 }
Ejemplo n.º 3
0
 private bool ValidateOrderShipping(Order order)
 {
     return
         (order.OrderShipping.Address.ZipCode == ADDRESS_ZIP_CODE &&
          order.OrderShipping.Address.Street == ADDRESS_STREET &&
          order.OrderShipping.Address.Number == ADDRESS_NUMBER &&
          order.OrderShipping.Address.Complement == ADDRESS_COMPLEMENT &&
          order.OrderShipping.Address.State == ADDRESS_STATE &&
          order.OrderShipping.Address.City == ADDRESS_CITY &&
          order.OrderShipping.Observation == ORDER_SHIPPING_OBSERVATION &&
          order.OrderShipping.Order == order &&
          AuditableInfoValueObjectTest.IsValidForCreation(order.OrderShipping.AuditableInfo)
         );
 }
Ejemplo n.º 4
0
        public async Task Order_ImportOrder_Success()
        {
            _ = await RunWithTelemetryAsync(
                totalOfExecutions : 1,
                runInParallel : false,
                handler : async execution =>
            {
                #region Arrange
                var order = default(Order);



                #endregion

                #region Act
                order = CreateDefaultImportOrder();



                #endregion

                #region Assert
                return(await Task.FromResult(
                           order.Code == ORDER_CODE &&
                           order.OrderDate >= DateTime.UtcNow.AddSeconds(-10) &&
                           order.OrderStatus.Status == OrderStatusEnum.Open &&
                           TenantInfoValueObjectTest.IsValid(order.TenantInfo) &&
                           AuditableInfoValueObjectTest.IsValidForCreation(order.AuditableInfo) &&
                           ValidateOrderCustomer(order) &&
                           ValidateOrderShipping(order) &&
                           ValidateOrderItemCollection(order)
                           ).ConfigureAwait(false));


                #endregion
            }
                ).ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        public async Task Product_ImportProduct_Inactive_Success()
        {
            _ = await RunWithTelemetryAsync(
                totalOfExecutions : 1,
                runInParallel : false,
                handler : async execution =>
            {
                #region Arrange
                var product = default(Product);



                #endregion

                #region Act
                product = CreateDefaultImportProduct(false);



                #endregion

                #region Assert
                return(await Task.FromResult(
                           product.Id != Guid.Empty &&
                           product.Code == PRODUCT_CODE &&
                           product.Name == PRODUCT_NAME &&
                           product.Description == PRODUCT_DESCRIPTION &&
                           TenantInfoValueObjectTest.IsValid(product.TenantInfo) &&
                           AuditableInfoValueObjectTest.IsValidForCreation(product.AuditableInfo) &&
                           ActivationInfoValueObjectTest.IsValidForInactivation(product.ActivationInfo)
                           ).ConfigureAwait(false));


                #endregion
            }
                ).ConfigureAwait(false);
        }