public void CallConstructionAndPropertyAccess() { Bid bid1 = new Bid(3, Suit.Hearts); Bid bid2 = new Bid(3, Suit.NoTrump); Call call1 = new Call(Seat.West, CallType.Pass, null); Call call2 = new Call(Seat.East, CallType.Pass); Call call3 = new Call(Seat.East, CallType.Double); Call call4 = new Call(Seat.East, CallType.Redouble, null); Call call5 = new Call(Seat.East, CallType.Bid, bid1); Call call6 = new Call(Seat.East, CallType.Pass, bid2); Call call7 = new Call(Seat.North, CallType.Pass, bid2); Assert.AreEqual(Seat.West, call1.Bidder); Assert.AreNotEqual(call1.Bidder, call2.Bidder); Assert.AreEqual(call2.Bidder, call3.Bidder); Assert.AreEqual(CallType.Pass, call1.CallType); Assert.AreEqual(call1.CallType, call2.CallType); Assert.AreNotEqual(call2.CallType, call3.CallType); Assert.AreNotEqual(call3.CallType, call4.CallType); Assert.AreNotEqual(call4.CallType, call5.CallType); Assert.AreNotEqual(call5.CallType, call6.CallType); Assert.AreEqual(call6.CallType, call2.CallType); Assert.AreEqual(null, call4.Bid); Assert.AreEqual(call3.Bid, call4.Bid); Assert.AreNotEqual(call5.Bid, call6.Bid); Assert.AreEqual(call6.Bid, call7.Bid); Assert.AreNotEqual(call7.Bid, call1.Bid); }
//FIXME implement Iequality and Icompare public bool IsSufficient(Bid other) { if (other == null) return true; return ((other.Tricks < this.Tricks) || (other.Tricks == this.Tricks && other.Suit < this.Suit)); }
/// <summary> /// Initializes a new instance of the <see cref="BridgeIt.Core.Contract"/> class. /// </summary> /// <param name='bid'> /// Bid. /// </param> /// <param name='doubles'> /// Doubles. /// </param> /// <exception cref='ArgumentNullException'> /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> . /// </exception> /// <exception cref='ArgumentOutOfRangeException'> /// Is thrown when an argument passed to a method is invalid because it is outside the allowable range of values /// as specified by the method. /// </exception> public Contract(Bid bid, int doubles) { if (bid == null) throw new ArgumentNullException("bid"); if (doubles < 0 || 2 < doubles) throw new ArgumentOutOfRangeException("doubles", "The number of doubles can only be 0, 1, or 2"); Bid = bid; Doubles = doubles; }
public Call(Seat bidder, CallType type, Bid bid = null) { if (bidder == Seat.None) throw new ArgumentException("Bidder must not be none."); if (type == CallType.None) throw new ArgumentException("Call type must not be none."); if (type == CallType.Bid && bid == null) throw new ArgumentException("Bid must not be null when call type is bid."); Bidder = bidder; CallType = type; Bid = bid; }
public void StringConstructionTest() { Call call1 = new Call(Seat.West, CallType.Pass); Call call2 = Call.FromString(Seat.West, "P"); Assert.AreNotEqual(call1, call2); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "PASS"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "pA"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "pas"); Assert.AreEqual(call1.CallType, call2.CallType); call1 = new Call(Seat.West, CallType.Double); call2 = Call.FromString(Seat.West, "D"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "DouBLe"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "d"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "do"); Assert.AreEqual(call1.CallType, call2.CallType); call1 = new Call(Seat.West, CallType.Redouble); call2 = Call.FromString(Seat.West, "R"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "ReDoublE"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "r"); Assert.AreEqual(call1.CallType, call2.CallType); call2 = Call.FromString(Seat.West, "redo"); Assert.AreEqual(call1.CallType, call2.CallType); Bid bid1 = new Bid(3, Suit.Hearts); call1 = new Call(Seat.West, CallType.Bid, bid1); call2 = Call.FromString(Seat.West, "3H"); Assert.AreEqual(call1.CallType, call2.CallType); Assert.AreEqual(call1.Bid.Suit, Suit.Hearts); Assert.AreEqual(call1.Bid.Tricks, 3); //Other bid strings are in the bid tests try { Call.FromString(Seat.West, "dbl"); Assert.Fail(); } catch { } try { Call.FromString(Seat.West, "passer"); Assert.Fail(); } catch { } try { Call.FromString(Seat.West, "12H"); Assert.Fail(); } catch { } }