public void GetBidsForItemReturnBidsSuccessfully() { 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", 3)); BidTracker tracker = new BidTracker(repo); List <Bid> bids = tracker.GetBids("item1").ToList(); Assert.Equal(2, bids.Count()); Bid bid1 = bids.SingleOrDefault(b => b.Id == "bid1"); Assert.NotNull(bid1); Assert.Equal(2, bid1.Amount); Assert.Equal("item1", bid1.ItemId); Assert.Equal("user1", bid1.UserId); Bid bid2 = bids.SingleOrDefault(b => b.Id == "bid2"); Assert.NotNull(bid2); Assert.Equal(3, bid2.Amount); Assert.Equal("item1", bid2.ItemId); Assert.Equal("user2", bid2.UserId); }
public void GetBidsForItemWithoutItemIdThrowsException(string itemId) { BidRepository repo = new BidRepository(); BidTracker tracker = new BidTracker(repo); var ex = Assert.Throws <ArgumentNullException>(() => tracker.GetBids(itemId)); Assert.Contains("An item id must be specified.", ex.Message); }
public void GetBidsForNonExistingItemThrowsException() { BidRepository repo = new BidRepository(); BidTracker tracker = new BidTracker(repo); InvalidBidException exception = Assert.Throws <InvalidBidException>(() => tracker.GetBids("item1")); Assert.Equal("An item with id 'item1' does not exist.", exception.Message); }