public void MostLike_ReturnsListOfCatFoodsSortedByNumSharedIngredients_List()
        {
            List <string> testXRefIngredients1 = new List <string> {
                "Chicken", "Rice", "Salmon"
            };
            List <string> testXRefIngredients2 = new List <string> {
                "Menhaden", "Rice", "Chicken Liver"
            };
            List <string> testXRefIngredients3 = new List <string> {
                "Salmon, Menhaden, Chicken Liver"
            };

            CatFood.ClearAll();

            CatFood foodA = new CatFood("A", testBrand, testPrice, testKCalKG, testUnitMassG,
                                        testXRefIngredients1, testGuaranteedAnalysis);
            CatFood foodB = new CatFood("B", testBrand, testPrice, testKCalKG, testUnitMassG,
                                        testXRefIngredients2, testGuaranteedAnalysis);
            CatFood foodC = new CatFood("C", testBrand, testPrice, testKCalKG, testUnitMassG,
                                        testXRefIngredients3, testGuaranteedAnalysis);

            Assert.AreEqual(new List <CatFood> {
                foodB, foodA
            }, CatFood.MostLike(foodC));
        }
Exemplo n.º 2
0
 public Supplies()
 {
     catFood     = new CatFood();
     dogFood     = new DogFood();
     birdFood    = new BirdFood();
     reptileFood = new ReptileFood();
 }
Exemplo n.º 3
0
        public void Eat_SuppliedCatFood_ShouldStillBeHungry()
        {
            // Arrange
            var dog = new Dog("dawg");
            var catFood = new CatFood();

            // Act
            dog.Feed(catFood);

            // Assert
            Assert.IsTrue(dog.IsHungry);
        }
Exemplo n.º 4
0
        public void Eat_SuppliedCatFood_ShouldNotBeHungry()
        {
            // Arrange
            var cat = new Cat("Mr Meow");
            var catFood = new CatFood();

            // Act
            cat.Feed(catFood);

            // Assert
            Assert.IsFalse(cat.IsHungry);
        }
Exemplo n.º 5
0
        public void Eat_NotDogFoodShouldDecreaseEnergy()
        {
            //Arrange
            var dog = new Dog("Doggy");

            //Act
            var currentEnergy = dog.Energy;
            var catFood       = new CatFood();

            dog.Eat(catFood);

            //Assert
            Assert.Greater(dog.Energy, currentEnergy);
        }
        public void ComparePrice_ReturnsFormattedStringOfBrandNameAndKCalPrice_String()
        {
            List <CatFood> CatFoodList = new List <CatFood> {
                testFood, testFood2
            };
            string testFormattedCompare = "";

            foreach (CatFood food in CatFoodList)
            {
                testFormattedCompare += String.Format("{0} {1}: {2:0} calories/$\n",
                                                      food.Brand, food.Name, food.KCalPrice);
            }
            Assert.AreEqual(testFormattedCompare, CatFood.ComparePrice());
        }
Exemplo n.º 7
0
        public void Resolve_IntoRegistered_Singleton()
        {
            var container = Container.Create();
            var food      = new CatFood();
            var petshop   = new Petshop();

            container.Register <IPetFood>(Scope.Singleton, food);
            container.Register(Scope.Singleton, petshop);

            container.InjectIntoRegistered();

            var cached = container.GetCached <Petshop>();

            Assert.AreEqual(food, cached.Food);
        }
Exemplo n.º 8
0
        public void Resolve_IntoRegistered_Transient()
        {
            var container  = Container.Create();
            var food       = new CatFood();
            var petshopOne = new Petshop();
            var petshopTwo = new Petshop();

            container.Register <IPetFood>(Scope.Singleton, food);
            container.Register(Scope.Transient, petshopOne);
            container.Register(Scope.Transient, petshopTwo);

            container.InjectIntoRegistered();

            var cached = container.GetCachedMultiple <Petshop>();

            CollectionAssert.AllItemsAreNotNull(cached.Select(item => item.Food));
            CollectionAssert.AllItemsAreInstancesOfType(cached.Select(item => item.Food), typeof(IPetFood));
        }
Exemplo n.º 9
0
        private void feedCats(CatFood theCatFood)
        {
            // TODO: Add functionality to check if feeding is on schedule to prevent overfeeding
            if (theCatFood.level <= 0)
            {
                Console.Write("Sorry. Out of Cat Food. Press any key to continue");
                Console.ReadKey(true);
                //throw new System.NotImplementedException("Cat Food is empty");
                return;
            }
            if (Cats.Count <= 0)
            {
                Console.Write("Sorry. No Cats to Feed. Press any key to continue");
                Console.ReadKey(true);
                //throw new System.NotImplementedException("No Cats to Feed");
                return;
            }

            foreach (var cat in Cats)
            {
                cat.feedIt(cat.FeedingAmount);
                theCatFood.level -= cat.FeedingAmount;
            }
        }
Exemplo n.º 10
0
 public void eat(CatFood food)
 {
 }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        if (eating)
        {
            eatingTimer += Time.deltaTime;
            // Wait till it finishes eating
            if (eatingTimer < eatingTimeLength)
            {
                if (!catAnimator.GetBool("Eating"))
                {
                    catAnimator.SetBool("Eating", true);
                }
                return;
            }
            else
            {
                eating = false;
                catAnimator.SetBool("Eating", false);
                catAnimator.SetTrigger("BeHumble");
            }
        }

        if (!rest)
        {
            timer += Time.deltaTime;

            if (Vector3.Distance(this.transform.position, agent.destination) < 0.125f || timer > wanderTimer)
            {
                // Should do encapsulation
                stopMoving();
            }
            else
            {
                // Moving
                Collider[] foodList = Physics.OverlapBox(transform.position, new Vector3(0.25f, 0.25f, 0.25f), Quaternion.identity, layerToSearch);
                if (foodList.Length > 0 && cat.isHungry())
                {
                    // Move onto a food and is hungry...eat it
                    Debug.Log("in if");
                    eating      = true;
                    eatingTimer = 0f;
                    CatFood food = foodList[0].GetComponentInParent <CatFood>();
                    if (food != null)
                    {
                        food.getEaten(this.cat);
                    }
                    agent.SetDestination(this.transform.position);
                    return;
                }
            }
        }
        else
        {
            // Rest
            timer += Time.deltaTime;

            if (timer >= stopTimer)
            {
                NewTarget();
            }
            else
            {
            }
        }
    }
Exemplo n.º 12
0
 public void FeedTheCat()
 {
     Console.WriteLine($"{cat.Nickname}, кис, кис, кис кушать кодано! ");
     CatFood?.Invoke("Вкусняшка");
 }
Exemplo n.º 13
0
 // Pass the food GameObject in, instead of the ref to the food script attached
 public void Touch(GameObject obj)
 {
     // Player refill this food
     catFood = obj.GetComponent <CatFood>();
     catFood.Refill(refillPoint);
 }
Exemplo n.º 14
0
 public void Dispose()
 {
     CatFood.ClearAll();
 }