Exemplo n.º 1
0
        public void Buy()
        {
            var test = new TestCase();

            test.Buyer.Bank = 10000;

            Auction auction = test.CreateAuction();
            Assert.AreEqual(1000, auction.Quantity);

            uint auctionQuantity = auction.Quantity;
            IItem item;
            while (auctionQuantity > 100)
            {
                item = test.Buyer.Buy(auction, 100);
                auctionQuantity -= 100;

                Assert.AreEqual(auctionQuantity, auction.Quantity);
                Assert.AreEqual(100, item.Quantity);
                Assert.AreEqual(test.Buyer, item.Owner);
                Assert.AreEqual(2, test.Buyer.Assets.Count);
            }

            item = test.Buyer.Buy(auction, 100);
            Assert.AreEqual(test.Buyer, item.Owner);

            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);
            Assert.AreEqual(2, test.Buyer.Assets.Count);
            Assert.AreEqual(1, test.Seller.Assets.Count);
        }
Exemplo n.º 2
0
        public void CreateAuction()
        {
            var test = new TestCase();
            Auction auction = test.CreateAuction();

            Assert.AreEqual(test.Seller, auction.Owner);
            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);
        }
Exemplo n.º 3
0
        public void ExpireAuction()
        {
            var test = new TestCase();
            Auction auction = test.CreateAuction();

            Assert.AreEqual(test.Seller, auction.Owner);
            CollectionAssert.DoesNotContain(test.Seller.Assets, auction.Item);

            while (auction.Expires > 0)
                test.Universe.Tick();

            CollectionAssert.Contains(test.Seller.Assets, auction.Item);
        }
Exemplo n.º 4
0
        public void BuyPartial()
        {
            var test = new TestCase();

            test.Buyer.Bank = 10000;

            Auction auction = test.CreateAuction();
            Assert.AreEqual(1000, auction.Quantity);

            IItem item = test.Buyer.Buy(auction, 100);

            Assert.AreEqual(100, item.Quantity);
            Assert.AreEqual(test.Buyer, item.Owner);
            CollectionAssert.Contains(test.Buyer.Assets, item);
        }