示例#1
0
        private static PurchaseTransaction CreatePurchaseTransaction()
        {
            var purchaseTransactionId = new PurchaseTransactionId(SequentialGuid.NewSequentialGuid());
            var storeId = new StoreId(SequentialGuid.NewSequentialGuid());
            var store   = Store.Create(storeId, "Kwik-E-Mart");

            return(PurchaseTransaction
                   .CreateFull(purchaseTransactionId, store, new List <LineItemStripped>(), DateTime.Now));
        }
示例#2
0
        public void PurchaseTransaction_created()
        {
            var purchaseTransactionId = new PurchaseTransactionId(SequentialGuid.NewSequentialGuid());
            var storeId = new StoreId(SequentialGuid.NewSequentialGuid());
            var store   = Store.Create(storeId, "Kwik-E-Mart");
            var sut     = PurchaseTransaction.CreateFull(purchaseTransactionId, store, new List <LineItemStripped>(), DateTime.Now);

            Assert.NotNull(sut);
            Assert.Contains("Kwik-E-Mart", sut.Store.Name);
            Assert.NotNull(sut.LineItems);
        }
示例#3
0
        public async Task Valid_Id_Returns_PurchaseTransaction()
        {
            var          id                  = Guid.NewGuid();
            var          store               = Store.Create(new StoreId(SequentialGuid.NewSequentialGuid()), "Kwik-E-Mart");
            var          lineItem            = new List <LineItemStripped>();
            PurchaseDate transactionDate     = new PurchaseDate(DateTime.Now);
            var          purchaseTransaction = PurchaseTransaction.CreateFull(id, store, lineItem, transactionDate);

            var mockPurchaseTransactionService = new Mock <IPurchaseTransactionService>();

            mockPurchaseTransactionService.Setup(s => s.GetDetailedPurchaseTransaction(id))
            .Returns(() => Task.FromResult(purchaseTransaction));

            var purchaseTransactionController = new PurchaseTransactionController(mockPurchaseTransactionService.Object);
            var result = await purchaseTransactionController.GetPurchaseTransaction(id);

            mockPurchaseTransactionService.Verify(mock => mock.GetDetailedPurchaseTransaction(id), Times.Once());
            Assert.NotNull(result);
        }
示例#4
0
        public void PurchaseTransaction_not_created(PurchaseTransactionId purchaseTransactionId, Store store, ICollection <LineItemStripped> lineItems)
        {
            Action sut = () => PurchaseTransaction.CreateFull(purchaseTransactionId, store, lineItems, DateTime.Now);

            Assert.Throws <ArgumentNullException>(sut.Invoke);
        }