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);
        }
Exemple #2
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #6
0
        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);
        }