public void PlaceBid_WithValidUsernameAndPrice_WillBeSaved(double price, string username)
        {
            var newBid = new Bid()
            {
                Price     = price,
                Username  = username,
                AuctionId = 1
            };

            BidsService.PlaceBid(newBid);

            var bids      = BidsService.GetAllBids(1);
            var actualBid = bids.First();

            actualBid.ShouldCompare(newBid);
        }
        public void GetAllBids_WhenThereAreBids_WillReturnAllBidsSortedByPrice()
        {
            var bid11 = CreateBid(1, "User1", 11);
            var bid14 = CreateBid(1, "User2", 14);
            var bid05 = CreateBid(1, "User3", 0.5);
            var bid12 = CreateBid(1, "User4", 12);

            var allBids = BidsService.GetAllBids(1);

            var expected = new List <Bid>()
            {
                bid14, bid12, bid11, bid05
            }.AsReadOnly();

            expected.ShouldCompare(allBids);
        }
        public void PlaceBid_UpdatePrice_WillUpdateTheLastBid()
        {
            var firstBid = new Bid()
            {
                AuctionId = 1, Price = 10, Username = "******"
            };

            BidsService.PlaceBid(firstBid);

            var secondBid = new Bid()
            {
                AuctionId = 1, Price = 12, Username = "******"
            };

            BidsService.PlaceBid(secondBid);

            var allBids = BidsService.GetAllBids(1);

            Assert.AreEqual(1, allBids.Count);
            allBids[0].ShouldCompare(secondBid);
        }
Esempio n. 4
0
 public IList <Bid> GetAllBidsFromService()
 {
     return(BidsService.GetAllBids(LastAuctionId));
 }
Esempio n. 5
0
        public IHttpActionResult GetAllBids(int auctionId)
        {
            var allBids = BidsService.GetAllBids(auctionId);

            return(Ok(allBids));
        }