Esempio n. 1
0
        public void OneItemInBasket()
        {
            FruitBasket theBasket = new FruitBasket
            {
                hasApple = true,
                hasOrange = false,
                hasBanana = false,
                hasPear = false
            };

            var stringToTest = theBasket.DisplayBasket();
            Assert.AreEqual(stringToTest, "There is an apple in the basket.");

            theBasket.hasApple = false;
            theBasket.hasOrange = true;

            stringToTest = theBasket.DisplayBasket();
            Assert.AreEqual(stringToTest, "There is an orange in the basket.");

            theBasket.hasOrange = false;
            theBasket.hasBanana = true;

            stringToTest = theBasket.DisplayBasket();
            Assert.AreEqual(stringToTest, "There is a banana in the basket.");

            theBasket.hasBanana = false;
            theBasket.hasPear = true;

            stringToTest = theBasket.DisplayBasket();
            Assert.AreEqual(stringToTest, "There is a pear in the basket.");
        }
Esempio n. 2
0
        public static FruitBasket getFruitBasket()
        {
            FruitBasket result = new FruitBasket();

            Random rand = new Random();

            result.hasApple = rand.Next(2) == 0;
            result.hasOrange = rand.Next(2) == 0;
            result.hasBanana = rand.Next(2) == 0;
            result.hasPear = rand.Next(2) == 0;

            return result;
        }