public void DoesntAllowNewBidsAfterAuctionIsFinished(int quantityExpected, double[] offers) { //Arranje IEvaluationType evaluationType = new HigherValue(); var auction = new Auction("Van Gogh", evaluationType); var john = new Interested("Jhon", auction); var mike = new Interested("Mike", auction); auction.StartAuction(); for (int i = 0; i < offers.Length; i++) { var value = offers[i]; if ((i % 2) == 0) { auction.ReceiveBid(john, value); } else { auction.ReceiveBid(mike, value); } } auction.FinishAuction(); //Act auction.ReceiveBid(john, 1000); //Assert var quantityGot = auction.Bids.Count(); Assert.Equal(quantityExpected, quantityGot); }
public void ReturnHigherValueForAuctionWithAtLeastOneAuction( double expectedValue, double[] offers) { //Arranje IEvaluationType evaluationType = new HigherValue(); var auction = new Auction("Van Gogh", evaluationType); var john = new Interested("Jhon", auction); var mike = new Interested("Mike", auction); auction.StartAuction(); for (int i = 0; i < offers.Length; i++) { var valor = offers[i]; if ((i % 2) == 0) { auction.ReceiveBid(john, valor); } else { auction.ReceiveBid(mike, valor); } } //Act auction.FinishAuction(); //Assert var valueGot = auction.BidWinner.Value; Assert.Equal(expectedValue, valueGot); }
public override string ToString() { LowerValue.UpdateWhenValueChanged(); HigherValue.UpdateWhenValueChanged(); var value = GetShownValue(); return($"{value} {this.Unit}"); }
public void ReturnInvalidOperationExceptionForAuctionNotStarted() { //Arranje IEvaluationType evaluationType = new HigherValue(); var auction = new Auction("Van Gogh", evaluationType); //Act Action act = () => auction.FinishAuction(); //assert Assert.Equal("Is not possible to finish the auction before it has started.", Assert.Throws <InvalidOperationException>(act).Message); }
public void ReturnZeroForAuctionsWithoutBids() { //Arranje IEvaluationType evaluationType = new HigherValue(); var auction = new Auction("Van Gogh", evaluationType); auction.StartAuction(); //Act auction.FinishAuction(); //Assert var expectedValue = 0; var valueGot = auction.BidWinner.Value; Assert.Equal(expectedValue, valueGot); }
public void DoesntAcceptBidFromTheLastClientWhoMadeBid() { //Arranje IEvaluationType evaluationType = new HigherValue(); var auction = new Auction("Van Gogh", evaluationType); var john = new Interested("John", auction); auction.StartAuction(); auction.ReceiveBid(john, 800); //Act auction.ReceiveBid(john, 1000); //Assert var quantityExpected = 1; var quantityGot = auction.Bids.Count(); Assert.Equal(quantityExpected, quantityGot); }