public void ReturnsHighestValueGivenAuctionWithAtOneBid( double expectedAmount, double[] offers) { //Arranje var modality = new HighestValue(); var auction = new Auction("Corvette CR7", modality); var buyer = new Client("Marcio", auction); var buyer2 = new Client("Maria", auction); auction.StartsPreaching(); for (int i = 0; i < offers.Length; i++) { var value = offers[i]; if ((i % 2) == 0) { auction.ReceiveBid(buyer, value); } else { auction.ReceiveBid(buyer2, value); } } //Act auction.EndsPreaching(); //Assert var obtainedAmount = auction.Winner.Value; Assert.Equal(expectedAmount, obtainedAmount); }
public void DoesNotAllowNewBidsGivenAuctionEnded( int expectedAmount, double[] offers) { //Arranje var modality = new HighestValue(); var auction = new Auction("Corvette CR7", modality); var buyer = new Client("Marcio", auction); var buyer2 = new Client("Maria", auction); auction.StartsPreaching(); for (int i = 0; i < offers.Length; i++) { var value = offers[i]; if ((i % 2) == 0) { auction.ReceiveBid(buyer, value); } else { auction.ReceiveBid(buyer2, value); } } auction.EndsPreaching(); //Act auction.ReceiveBid(buyer, 1000); //Assert var obtainedAmount = auction.Binds.Count(); Assert.Equal(expectedAmount, obtainedAmount); }
public override string ToString() { string ls = LowestValue.Equals(minValue) ? "-Inf" : LowestValue.ToString(); string hs = HighestValue.Equals(maxValue) ? "Inf" : HighestValue.ToString(); return(Value.ToString() + " [" + ls + ", " + hs + "]"); }
/// <summary> /// gets the current info and places it in an info array the will be saved /// </summary> /// <returns>the info array</returns> public string[] GetInfo() { string[] info = new string[4]; info[0] = LastValue.ToString(); info[1] = HighestValue.ToString(); info[2] = Key.ToString(); info[3] = Name; return(info); }
public override int GetHashCode() { unchecked { var hashCode = Id.GetHashCode(); hashCode = (hashCode * 397) ^ TimeStamp.GetHashCode(); hashCode = (hashCode * 397) ^ (RealmSlug?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MeanValue.GetHashCode(); hashCode = (hashCode * 397) ^ AdjustedMeanValue.GetHashCode(); hashCode = (hashCode * 397) ^ LowestValue.GetHashCode(); hashCode = (hashCode * 397) ^ HighestValue.GetHashCode(); hashCode = (hashCode * 397) ^ Quantity; return(hashCode); } }
public void InvalidOperationExceptionWhenPreachingNotStarted() { //Arranje var modality = new HighestValue(); var auction = new Auction("Corvette CR7", modality); //Assert var exceptionObtained = Assert.Throws <System.InvalidOperationException>( //Act () => auction.EndsPreaching() ); var expectedMessage = "It is not possible to finish the trading session without it having started."; Assert.Equal(expectedMessage, exceptionObtained.Message); }
public void ReturnsZeroGivenAuctionWithoutBids() { //Arranje var modality = new HighestValue(); var auction = new Auction("Corvette CR7", modality); auction.StartsPreaching(); //Act auction.EndsPreaching(); //Assert var expectedAmount = 0; var obtainedAmount = auction.Winner.Value; Assert.Equal(expectedAmount, obtainedAmount); }
public override dynamic GetObjectToSerialize(bool is_explicit) { IsExplicit = is_explicit; if (IsExplicit) { Dictionary <string, object> dict = base.GetObjectToSerialize(is_explicit) as Dictionary <string, object>; if (HighestValue.CompareTo(maxValue) < 0) { dict["higher_bound"] = HighestValue; } if (LowestValue.CompareTo(minValue) > 0) { dict["lower_bound"] = LowestValue; } return(dict); } return(Value); }
public void DontAcceptNextBidWhenSameClientPerformedLastBid() { //Arranje var modality = new HighestValue(); var auction = new Auction("Corvette CR7", modality); var buyer = new Client("Marcio", auction); auction.StartsPreaching(); auction.ReceiveBid(buyer, 800); //Act auction.ReceiveBid(buyer, 1000); //Assert var expectedAmount = 1; var obtainedAmount = auction.Binds.Count(); Assert.Equal(expectedAmount, obtainedAmount); }
protected bool Equals(ItemData other) { return(Id == other.Id && TimeStamp.Equals(other.TimeStamp) && string.Equals(RealmSlug, other.RealmSlug) && MeanValue.Equals(other.MeanValue) && AdjustedMeanValue.Equals(other.AdjustedMeanValue) && LowestValue.Equals(other.LowestValue) && HighestValue.Equals(other.HighestValue) && Quantity == other.Quantity); }