Esempio n. 1
0
        public void GivenADocumentId_WhenIRequestTheDocumentToBeAddedToTheCartItem_ItIsAddedToTheCart()
        {
            _cartItemRepository.Setup(c => c.GetCart(It.IsAny <string>()))
            .Returns(
                new List <CartItem>());

            _checkOutEngine.Setup(c => c.IsDocumentCheckedOut(It.IsAny <string>())).Returns(false);
            _checkOutEngine.Setup(c => c.CheckOutDocument(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new CheckOut()
            {
                DocumentId = 1
            });
            _documentRepository.Setup(d => d.GetDocument(It.IsAny <string>())).Returns(new Document()
            {
                Id = 1
            });

            _cartItemEngine.AddItem(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>());

            _cartItemRepository.Verify(s => s.Create(It.IsAny <CartItem>()), Times.Once());
        }
Esempio n. 2
0
 public void AddItem(string userName, string documentId, string cartId, string manCo, string docType, string subDocType)
 {
     try
     {
         _cartItemEngine.AddItem(documentId, cartId, userName, manCo, docType, subDocType);
     }
     catch (BasketContainsDifferentManCoException e)
     {
         throw new BasketContainsDifferentManCoException("Basket contains documents from a different manco");
     }
     catch (DocumentCurrentlyCheckedOutException e)
     {
         throw new DocumentCurrentlyCheckedOutException(
                   string.Format("Unable to add document guid {0} to baset", documentId), e);
     }
     catch (UnableToCheckOutDocumentException e)
     {
         throw new UnableToCheckOutDocumentException(string.Format("Unable to check out document {0}", documentId));
     }
     catch (Exception e)
     {
         throw new UnityException(string.Format("Unable to add document guid {0} to basket", documentId), e);
     }
 }