public void PurchaseServiceCanAffordProductWorksCorrectlyWhenInsufficientFundsAreIn() { //These could be mocked out, but since they are simple in memory //instaces there is no point. ISessionService sessionService = new InMemorySessionService(); IItemRepository itemRepository = new ItemRepository(); IPurchaseService purchaseService = new PurchaseService(itemRepository, sessionService); Guid sessionId = Guid.NewGuid(); double tallyValue = 0.5; sessionService.StoreCurrentTally(sessionId, tallyValue); //If sufficient money is in a session, the item price minus the session tally is returned. double checkResult = tallyValue - itemRepository.GetItem(0).Price; double result = purchaseService.CanAffordProduct(sessionId, 0); Assert.True(result < 0); Assert.True(checkResult == result); //Make sure the session hasn't been modified Assert.True(sessionService.GetStoredTally(sessionId) == tallyValue); }