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)); }
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); }
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); }
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); }