Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }