Example #1
0
        public void TestDrink_1()
        {
            Vasya vasyok = new Vasya();

            vasyok.amountOfLitersWater = 100;
            List <Friend> friendList = new List <Friend>();

            for (int i = 0; i < amountOfFriends; i++)
            {
                friendList.Add(new Friend()
                {
                    _name = "Friend_" + (i + 1)
                });
                Console.WriteLine(friendList[i]._name);
            }

            double totalDrunked = 0;

            for (int i = 0; i < amountOfDay; i++)
            {
                vasyok.VasyaDrink(3);
                for (int j = 0; j < friendList.Count; j++)
                {
                    friendList[j].Drink(4);
                    totalDrunked += 4;
                }
            }
            double litersLeft       = vasyok.amountOfLitersWater - totalDrunked;
            double _expected_result = -33;

            Assert.AreEqual(_expected_result, litersLeft);
        }
Example #2
0
        public void VasyaVSFriends(

            double whaterHasVacya,
            double litPerDayByVacya,
            double litPerDayByFriend,
            int friendsAmount,
            int days,
            double drunk
            )
        {
            vasyok.water = whaterHasVacya;
            double friendsDrinkWater = 0;

            for (int i = 0; i < days; i++)
            {
                vasyok.VasyaDrink(litPerDayByVacya);
                fr1.Drink(litPerDayByFriend);
                friendsDrinkWater += litPerDayByFriend;
                fr2.Drink(litPerDayByFriend);
                friendsDrinkWater += litPerDayByFriend;
                fr3.Drink(litPerDayByFriend);
                friendsDrinkWater += litPerDayByFriend;
                fr4.Drink(litPerDayByFriend);
                friendsDrinkWater += litPerDayByFriend;
            }
            vasyok.water = vasyok.water - friendsDrinkWater;

            Assert.AreEqual(drunk, vasyok.water);
            //Assert.AreEqual(new Exception("Friends drink too much!"), vasyok.IsWaterFinished());
        }
Example #3
0
        public void VasyaVSFriendsEatDrink()
        {
            Vasya  vasyok = new Vasya();
            Friend fr1    = new Friend();
            Friend fr2    = new Friend();
            Friend fr3    = new Friend();
            Friend fr4    = new Friend();

            vasyok.apples = 27;
            vasyok.water  = 100;

            for (int i = 0; i < 7; i++)
            {
                vasyok.VasyaEat(3);
            }

            double applesForFriends = vasyok.apples;

            applesForFriends = new CalcCore().DivideMethod(applesForFriends, 4);

            double friendsDrinkWater = 0;

            for (int i = 0; i < 7; i++)
            {
                vasyok.VasyaDrink(3);
                fr1.Drink(4);
                friendsDrinkWater += 4;
                fr2.Drink(4);
                friendsDrinkWater += 4;
                fr3.Drink(4);
                friendsDrinkWater += 4;
                fr4.Drink(4);
                friendsDrinkWater += 4;
            }

            double friendsEatApples = 0;

            fr1.Eat(applesForFriends);
            friendsEatApples += applesForFriends;
            fr2.Eat(applesForFriends);
            friendsEatApples += applesForFriends;
            fr3.Eat(applesForFriends);
            friendsEatApples += applesForFriends;
            fr4.Eat(applesForFriends);
            friendsEatApples += applesForFriends;

            vasyok.apples -= friendsEatApples;
            vasyok.water  -= friendsDrinkWater;

            Assert.AreEqual(0, vasyok.apples);
            Assert.AreEqual(-33, vasyok.water);
        }
Example #4
0
        public void TestDrink_2()
        {
            Vasya vasyok = new Vasya();

            vasyok.apples = 27;
            vasyok.amountOfLitersWater = 100;
            for (int i = 0; i < amountOfDay; i++)
            {
                vasyok.VasyaEat(3);
                vasyok.VasyaDrink(3);
            }
            double _expected_result_Apples = 6;
            double _expected_result_Water  = 79;

            Assert.AreEqual(_expected_result_Apples, vasyok.apples);
            Assert.AreEqual(_expected_result_Water, vasyok.amountOfLitersWater);
        }
Example #5
0
        public void TestDrink_3()
        {
            Vasya         vasyok     = new Vasya();
            List <Friend> friendList = new List <Friend>();

            for (int i = 0; i < amountOfFriends; i++)
            {
                friendList.Add(new Friend()
                {
                    _name = "Friend_" + (i + 1)
                });
                Console.WriteLine(friendList[i]._name);
            }
            vasyok.apples = 27;
            vasyok.amountOfLitersWater = 100;
            double totalDrunked = 0;

            for (int i = 0; i < amountOfDay; i++)
            {
                vasyok.VasyaEat(3);
                vasyok.VasyaDrink(3);
                for (int j = 0; j < friendList.Count; j++)
                {
                    friendList[j].Drink(4);
                    totalDrunked += 4;
                }
            }
            vasyok.amountOfLitersWater -= totalDrunked;

            double applesForEachFriend = new CalcCore().DivideMethod(vasyok.apples, amountOfFriends);
            double eatenApples         = 0;

            for (int i = 0; i < amountOfFriends; i++)
            {
                friendList[i].Eat(applesForEachFriend);
                eatenApples += friendList[i].hasEat;
            }
            vasyok.apples -= eatenApples;

            double _expected_result_Water  = -33;
            double _expected_result_Apples = 0;

            Assert.AreEqual(_expected_result_Water, vasyok.amountOfLitersWater);
            Assert.AreEqual(_expected_result_Apples, vasyok.apples);
        }
Example #6
0
        public void VasyaEatDrink()
        {
            Vasya vasyok = new Vasya();

            vasyok.apples = 27;
            vasyok.water  = 100;

            for (int i = 0; i < 7; i++)
            {
                vasyok.VasyaEat(3);
                vasyok.VasyaDrink(3);
            }

            double expect_apples = 6;
            double expect_waters = 79;

            Assert.AreEqual(expect_apples, vasyok.apples);
            Assert.AreEqual(expect_waters, vasyok.water);
        }