public void CreateBidsByService(IList <Bid> bids) { foreach (var bid in bids) { LinkBidToScenarioAuction(bid); BidsService.PlaceBid(bid); } }
public void PlaceBid_WithNullBid_WillThrowException() { TestDelegate act = () => BidsService.PlaceBid(null); var ex = Assert.Throws <ArgumentNullException>(act); StringAssert.Contains("Value cannot be null.\r\nParameter name: bid", ex.Message); }
private Bid CreateBid(int auctionId, string username, double price) { Bid bid = new Bid() { Username = username, Price = price, AuctionId = auctionId }; BidsService.PlaceBid(bid); return(bid); }
public void PlaceBid_WithoutAuctionId_WillThrowException() { Bid bid = new Bid() { Username = "******", Price = 11 }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("AuctionId can't be null", ex.Message); }
public void PlaceBid_WithInvalidPrice_WillThrowException(double price) { Bid bid = new Bid() { Username = "******", Price = price }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("Invalid price, price should be greater than 0", ex.Message); }
public void PlaceBid_WithInvalidUsername_WillThrowException(string username) { Bid bid = new Bid() { Price = 10, Username = username }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("Username can't be null", ex.Message); }
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 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); }
public IHttpActionResult PlaceBid(Bid bid) { if (bid == null) { return(BadRequest("Bid cannot be empty!")); } if (!bid.Price.HasValue) { return(BadRequest("Price cannot be empty!")); } if (string.IsNullOrEmpty(bid.Username)) { return(BadRequest("Username cannot be empty!")); } if (bid.Price <= 0) { return(BadRequest("Price must be greater than 0")); } BidsService.PlaceBid(bid); return(Ok()); }