Example #1
0
        public static void ReturnedItemReceived(Engine.Container container, string rmaFriendlyId, string orderId, string lineId)
        {
            var result = Proxy.DoCommand(container.ReturnedItemReceived(rmaFriendlyId));

            result.Should().NotBeNull();
            result.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

            var rma = GetRma(container, rmaFriendlyId);

            rma.Status.Should().Be("RefundPending");
            rma.ItemsReturnedDate.Should().BeCloseTo(DateTimeOffset.UtcNow, 2000);

            var order = Orders.GetOrder(container, orderId);

            order.Should().NotBeNull();
            order.Components.OfType <OrderRmasComponent>().FirstOrDefault().Should().NotBeNull();
            order.Components.OfType <OrderRmasComponent>().FirstOrDefault()?.Returns.Should().NotBeEmpty();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId)).Should().NotBeNull();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().Any().Should().BeTrue();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().FirstOrDefault()?.Returns.Should().NotBeEmpty();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().FirstOrDefault()?.Returns.Count.Should().Be(order.Components.OfType <OrderRmasComponent>().FirstOrDefault()?.Returns.Count);
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().FirstOrDefault()?.Returns.OrderByDescending(r => r.ReturnedDate).FirstOrDefault().Should().NotBeNull();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().FirstOrDefault()?.Returns.OrderByDescending(r => r.ReturnedDate).FirstOrDefault()?.Quantity.Should().Be(rma.Lines.FirstOrDefault()?.Quantity);
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))?.CartLineComponents.OfType <ItemReturnedComponent>().FirstOrDefault()?.Returns.OrderByDescending(r => r.ReturnedDate).FirstOrDefault()?.ReturnedDate.Should().BeCloseTo(DateTimeOffset.UtcNow, 2000);

            WriteListCounts(container);
        }
        public static void ReturnedItemReceived(
            Engine.Container container,
            string rmaFriendlyId,
            string orderId,
            string lineId)
        {
            var result = Proxy.DoCommand(container.ReturnedItemReceived(rmaFriendlyId));

            result.Should().NotBeNull();
            result.Messages.Should().NotContainErrors();
            var rmaId = result.Models.OfType <Sitecore.Commerce.Core.PersistedEntityModel>().FirstOrDefault(m => m.Name.Equals(typeof(ReturnMerchandiseAuthorization).FullName))?.EntityId;

            rmaId.Should().NotBeNullOrEmpty();

            var rma = GetRma(container, rmaId);

            rma.Status.Should().Be("RefundPending");
            rma.ItemsReturnedDate.Should().BeCloseTo(DateTimeOffset.UtcNow, 5000);

            var order = Orders.GetOrder(container, orderId);

            order.Should().NotBeNull();
            order.Components.OfType <OrderRmasComponent>().FirstOrDefault().Should().NotBeNull();
            order.Components.OfType <OrderRmasComponent>().FirstOrDefault()?.Returns.Should().NotBeEmpty();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId)).Should().NotBeNull();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .Any()
            .Should()
            .BeTrue();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .FirstOrDefault()
            ?.Returns.Should()
            .NotBeEmpty();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .FirstOrDefault()
            ?.Returns.Count.Should()
            .Be(order.Components.OfType <OrderRmasComponent>().FirstOrDefault()?.Returns.Count);
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .FirstOrDefault()
            ?.Returns.OrderByDescending(r => r.ReturnedDate)
            .FirstOrDefault()
            .Should()
            .NotBeNull();
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .FirstOrDefault()
            ?.Returns.OrderByDescending(r => r.ReturnedDate)
            .FirstOrDefault()
            ?.Quantity.Should()
            .Be(rma.Lines.FirstOrDefault()?.Quantity);
            order.Lines.FirstOrDefault(l => l.Id.Equals(lineId))
            ?.CartLineComponents.OfType <ItemReturnedComponent>()
            .FirstOrDefault()
            ?.Returns.OrderByDescending(r => r.ReturnedDate)
            .FirstOrDefault()
            ?.ReturnedDate.Should()
            .BeCloseTo(DateTimeOffset.UtcNow, 5000);
        }