Changeset 37508
- Timestamp:
- 05/14/10 08:20:58 (3 years ago)
- Location:
- lang/csharp/DominionEngine
- Files:
-
- 2 modified
-
DominionEngine.CardInfo.Test/DDL/CardTest.cs (modified) (1 diff)
-
DominionEngine.CardInfo/DDL/Card.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/DDL/CardTest.cs
r37505 r37508 49 49 Assert.That(selectingArgs.From, Is.EqualTo(CardPosition.Supply)); 50 50 Assert.That(card, Is.SameAs(result)); 51 } 52 53 [Test] 54 public void Select_CardPositionError() 55 { 56 Card result = new Card<Copper>(CardPosition.Trash); 57 58 object selectingSender = null; 59 Card.SelectingEventArgs selectingArgs = null; 60 Card.Selecting += (sender, e) => 61 { 62 selectingSender = sender; 63 selectingArgs = e; 64 e.Result = result; 65 }; 66 67 Assert.That(() => { Card.Select<Copper>(CardPosition.Supply); }, Throws.InstanceOf<Card.SelectCardPositionException>().And.Property("Card").SameAs(result).And.Property("Position").EqualTo(CardPosition.Supply)); 51 68 } 52 69 -
lang/csharp/DominionEngine/DominionEngine.CardInfo/DDL/Card.cs
r37505 r37508 60 60 SelectingEventArgs args = new SelectingEventArgs(Card<T>.cardInfo, from); 61 61 Selecting(null, args); 62 return args.Result; 62 63 Card card = args.Result; 64 if (card.Position != from) throw new SelectCardPositionException(card, from); 65 66 return card; 63 67 } 64 68 … … 94 98 } 95 99 } 100 101 #region Exception 102 103 public class SelectException : Exception 104 { 105 } 106 107 public class SelectCardException : SelectException 108 { 109 public Card Card { get; internal set; } 110 111 public SelectCardException(Card card) 112 { 113 Card = card; 114 } 115 } 116 117 public class SelectCardPositionException : SelectCardException 118 { 119 public CardPosition Position { get; internal set; } 120 121 public SelectCardPositionException(Card card, CardPosition position) 122 : base(card) 123 { 124 Position = position; 125 } 126 } 127 128 #endregion 96 129 97 130 #endregion
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)