public void GetWinningBidForItemWithoutItemIdThrowsException(string itemId) { BidRepository repo = new BidRepository(); BidTracker tracker = new BidTracker(repo); var ex = Assert.Throws <ArgumentNullException>(() => tracker.GetWinningBid(itemId)); Assert.Contains("An item id must be specified.", ex.Message); }
public void GetWinningBidWhenThereAreNoBidsReturnsNull() { BidRepository repo = new BidRepository(); repo.Items.Add(new Item("item1", "name1")); BidTracker tracker = new BidTracker(repo); Bid bid = tracker.GetWinningBid("item1"); Assert.Null(bid); }
public void GetWinningBidReturnsSuccessfully() { BidRepository repo = new BidRepository(); repo.Items.Add(new Item("item1", "name1")); repo.Bids.Add(new Bid("bid1", "item1", "user1", 2)); repo.Bids.Add(new Bid("bid2", "item1", "user2", 4)); repo.Bids.Add(new Bid("bid3", "item1", "user3", 3)); BidTracker tracker = new BidTracker(repo); Bid bid = tracker.GetWinningBid("item1"); Assert.NotNull(bid); Assert.Equal("item1", bid.ItemId); Assert.Equal(4, bid.Amount); Assert.Equal("user2", bid.UserId); Assert.Equal("bid2", bid.Id); }
public void GetWinnigBidForNonExistingItemThrowsException() { BidRepository repo = new BidRepository(); BidTracker tracker = new BidTracker(repo); InvalidBidException exception = Assert.Throws <InvalidBidException>(() => tracker.GetWinningBid("item1")); Assert.Equal("An item with id 'item1' does not exist.", exception.Message); }