Esempio n. 1
0
        public async Task WHEN_ShipmentFulfillmentStates_is_null_SHOULD_return_false_PendingCancel()
        {
            //Arrange
            var provider = _container.CreateInstance <EditingOrderProvider>();

            var orderId = Guid.NewGuid().ToString();
            var order   = new Order
            {
                OrderStatus = "New",
                Id          = orderId
            };

            var orderFulfillmentState = new OrderFulfillmentState()
            {
                IsCancelable = false,
                IsProcessing = true
            };

            _container.GetMock <IOrderRepository>()
            .Setup(r => r.GetOrderFulfillmentStateAsync(It.IsAny <GetOrderFulfillmentStateParam>()))
            .ReturnsAsync(orderFulfillmentState);

            //Act
            var result = await provider.GetCancellationStatus(order).ConfigureAwait(false);

            //Assert
            result.CancellationPending.Should().Be(false);
        }
Esempio n. 2
0
        private bool HasCancellationMessage(OrderFulfillmentState orderFulfillmentState)
        {
            if (orderFulfillmentState?.ShipmentFulfillmentStates == null)
            {
                return(false);
            }

            return(orderFulfillmentState.ShipmentFulfillmentStates.Any(item =>
                                                                       item.Messages?.Exists(el => Guid.Parse(el.MessageId) == Guid.Parse(orderFulfillmentState.OrderId.ToString()) &&
                                                                                             el.PropertyBag[Constants.RequestedOrderCancellationDatePropertyBagKey] is DateTime &&
                                                                                             (DateTime)el.PropertyBag[Constants.RequestedOrderCancellationDatePropertyBagKey] >
                                                                                             DateTime.UtcNow.AddMinutes(-10)) ?? false));
        }