public void GetItemsBidOnByUserWhenUserHasBidReturnsAllItems() { BidRepository repo = new BidRepository(); repo.Items.Add(new Item("item1", "name1")); repo.Items.Add(new Item("item2", "name2")); repo.Bids.Add(new Bid("bid1", "item1", "user1", 2)); repo.Bids.Add(new Bid("bid2", "item1", "user2", 3)); repo.Bids.Add(new Bid("bid3", "item1", "user3", 4)); repo.Bids.Add(new Bid("bid4", "item2", "user3", 3)); BidTracker tracker = new BidTracker(repo); IEnumerable <Item> items = tracker.GetItemsBidOn("user3"); Assert.NotEmpty(items); Assert.Equal(2, items.Count()); Item item1 = items.SingleOrDefault(i => i.Id == "item1"); Assert.NotNull(item1); Assert.Equal("name1", item1.Name); Item item2 = items.SingleOrDefault(i => i.Id == "item2"); Assert.NotNull(item2); Assert.Equal("name2", item2.Name); }
public void GetItemsBidOnByUserWithoutUserIdThrowsException(string userId) { BidRepository repo = new BidRepository(); BidTracker tracker = new BidTracker(repo); var ex = Assert.Throws <ArgumentNullException>(() => tracker.GetItemsBidOn(userId)); Assert.Contains("A user id must be specified.", ex.Message); }
public void GetItemsBidOnByUserWhenUserHasNotBidReturnsNoItems() { 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); IEnumerable <Item> items = tracker.GetItemsBidOn("user3"); Assert.Empty(items); }