public void GetAreaCalculatesCorrectArea() { object subject = SafeReflection.CreateInstance(typeSquare, new object[] { "TEST", "TESTCOLOR", 3 }); object area = SafeReflection.InvokeMethod(subject, "GetArea", null); Assert.AreEqual(9, area); }
public void GetAreaRoundsDown() { object subject = SafeReflection.CreateInstance(typeTriangle, new object[] { "TEST", "TESTCOLOR", 3, 3 }); object area = SafeReflection.InvokeMethod(subject, "GetArea", null); Assert.AreEqual(4, area); }
public void BidIsIgnoredIfLessThanReserve() { object theAuction = SafeReflection.CreateInstance(typeReserveAuction, new object[] { 100 }); Assert.IsNotNull(theAuction); SafeReflection.InvokeMethod(theAuction, "PlaceBid", new object[] { new Bid("Cheapskate", 99) }); object allBids = SafeReflection.GetPropertyValue(theAuction, "AllBids"); Assert.AreEqual(0, ((Bid[])allBids).Length); }
public void BidsGreaterThanBuyoutPriceAreReducedToBuyoutPrice() { object theAuction = SafeReflection.CreateInstance(typeBuyoutAuction, new object[] { 100 }); Assert.IsNotNull(theAuction); SafeReflection.InvokeMethod(theAuction, "PlaceBid", new object[] { new Bid("Big Spender", 200) }); object currentHighBid = SafeReflection.GetPropertyValue(theAuction, "CurrentHighBid"); Assert.AreEqual("Big Spender", ((Bid)currentHighBid).Bidder); Assert.AreEqual(100, ((Bid)currentHighBid).BidAmount); }
public void BidIsAcceptedIfBidIsEqualToReserve() { object theAuction = SafeReflection.CreateInstance(typeReserveAuction, new object[] { 100 }); Assert.IsNotNull(theAuction); SafeReflection.InvokeMethod(theAuction, "PlaceBid", new object[] { new Bid("Bidder Bob", 100) }); object currentHighBid = SafeReflection.GetPropertyValue(theAuction, "CurrentHighBid"); Assert.IsTrue(currentHighBid.GetType() == typeof(Bid)); Assert.AreEqual("Bidder Bob", ((Bid)currentHighBid).Bidder); Assert.AreEqual(100, ((Bid)currentHighBid).BidAmount); }
public void ConstructorSetsTheValues() { object subject = SafeReflection.CreateInstance(typeTriangle, new object[] { "TEST", "TESTCOLOR", 1, 2 }); object subjectName = SafeReflection.GetPropertyValue(subject, "Name"); object subjectColor = SafeReflection.GetPropertyValue(subject, "Color"); object subjectBase = SafeReflection.GetPropertyValue(subject, "Base"); object subjectHeight = SafeReflection.GetPropertyValue(subject, "Height"); Assert.IsNotNull(subject); Assert.AreEqual("TEST", subjectName); Assert.AreEqual("TESTCOLOR", subjectColor); Assert.AreEqual(1, subjectBase); Assert.AreEqual(2, subjectHeight); }
public void ConstructorSetsTheProperties() { object subject = SafeReflection.CreateInstance(typeSquare, new object[] { "TEST", "TESTCOLOR", 23 }); Assert.IsNotNull(subject); object subjectName = SafeReflection.GetPropertyValue(subject, "Name"); object subjectColor = SafeReflection.GetPropertyValue(subject, "Color"); object subjectLength = SafeReflection.GetPropertyValue(subject, "Length"); object subjectHeight = SafeReflection.GetPropertyValue(subject, "Height"); Assert.AreEqual("TEST", subjectName); Assert.AreEqual("TESTCOLOR", subjectColor); Assert.AreEqual(23, subjectLength); Assert.AreEqual(23, subjectHeight); }
public void BidsMadeAfterBuyoutPriceMetAreIgnored() { object theAuction = SafeReflection.CreateInstance(typeBuyoutAuction, new object[] { 100 }); Assert.IsNotNull(theAuction); SafeReflection.InvokeMethod(theAuction, "PlaceBid", new object[] { new Bid("Buyout Bob", 100) }); SafeReflection.InvokeMethod(theAuction, "PlaceBid", new object[] { new Bid("Too Late Tom", 101) }); object allBids = SafeReflection.GetPropertyValue(theAuction, "AllBids"); object currentHighBid = SafeReflection.GetPropertyValue(theAuction, "CurrentHighBid"); Assert.AreEqual(1, ((Bid[])allBids).Length); Assert.AreEqual("Buyout Bob", ((Bid)currentHighBid).Bidder); Assert.AreEqual(100, ((Bid)currentHighBid).BidAmount); }
public void ToStringReturnsTheFormattedString() { object subject = SafeReflection.CreateInstance(typeTriangle, new object[] { "TEST", "TESTCOLOR", 1, 3 }); Assert.AreEqual("TEST (1x3) triangle", subject.ToString()); }
public void ItIsAWall() { object subject = SafeReflection.CreateInstance(typeTriangle, new object[] { "TEST", "TESTCOLOR", 1, 2 }); Assert.IsInstanceOfType(subject, typeWall); }
public void ItIsARectangleWall() { object subject = SafeReflection.CreateInstance(typeSquare, new object[] { "TEST", "TESTCOLOR", 1 }); Assert.IsInstanceOfType(subject, typeRectangle); }