示例#1
0
        public void Can_Create_Omnium_OrderForm()
        {
            var purchaseOrder = FakePurchaseOrder.CreatePurchaseOrder();
            var orderForm     = purchaseOrder.Forms.FirstOrDefault();

            var omniumOrderForm = DefaultOmniumOrderFactorySubject.MapOrderForm(purchaseOrder, orderForm);

            var result =
                orderForm.Shipments.Count == omniumOrderForm.Shipments.Count &&
                orderForm.Payments.Count == omniumOrderForm.Payments.Count;

            Assert.True(result);
        }
示例#2
0
        public void CreateOrderOnMultipleThreads_OnlyTwoShouldBeCreated()
        {
            var cart1 = new FakeCart(new Mock <IMarket>().Object, Currency.NOK);
            var cart2 = new FakeCart(new Mock <IMarket>().Object, Currency.NOK);

            var purchaseOrder1 = new FakePurchaseOrder(new Mock <IMarket>().Object, Currency.NOK);
            var purchaseOrder2 = new FakePurchaseOrder(new Mock <IMarket>().Object, Currency.NOK);

            var orderReference1 = new OrderReference(1, "", Guid.Empty, null);
            var orderReference2 = new OrderReference(2, "", Guid.Empty, null);

            _orderRepositoryMock.Setup(x => x.SaveAsPurchaseOrder(cart1))
            .Returns(() => orderReference1);

            _orderRepositoryMock.Setup(x => x.SaveAsPurchaseOrder(cart2))
            .Returns(() => orderReference2);

            _vippsServiceMock.SetupSequence(x => x.GetPurchaseOrderByOrderId("1"))
            .Returns(null)
            .Returns(purchaseOrder1)
            .Returns(purchaseOrder1)
            .Returns(purchaseOrder1)
            .Returns(purchaseOrder1)
            .Returns(purchaseOrder1)
            .Returns(purchaseOrder1);

            _vippsServiceMock.SetupSequence(x => x.GetPurchaseOrderByOrderId("2"))
            .Returns(null)
            .Returns(purchaseOrder2);

            var responseList = new List <LoadOrCreatePurchaseOrderResponse>();

            Parallel.Invoke(async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart2, "2")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart2, "2")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1")),
                            async() => responseList.Add(await _subject.LoadOrCreatePurchaseOrder(cart1, "1"))
                            );

            var createdOrders = responseList.Where(x => x.PurchaseOrderCreated);

            Assert.Equal(2, createdOrders.Count());
        }
示例#3
0
        public void Can_Create_Omnium_Order()
        {
            var purchaseOrder = FakePurchaseOrder.CreatePurchaseOrder();

            var omniumOrder = DefaultOmniumOrderFactorySubject.MapOrder(purchaseOrder);

            var orderStatus = DefaultOmniumOrderFactorySubject.GetOrderStatus(purchaseOrder.OrderStatus);

            var result =
                purchaseOrder.Currency == omniumOrder.BillingCurrency &&
                purchaseOrder.OrderNumber.Equals(omniumOrder.OrderNumber) &&
                purchaseOrder.CustomerId.ToString().Equals(omniumOrder.CustomerId) &&
                purchaseOrder.MarketId.Value.Equals(omniumOrder.MarketId) &&
                orderStatus.Equals(omniumOrder.Status);

            Assert.True(result);
        }