public Tiger(Pasture pasture, int timeToMove, int timeUntilStarves, int timeUntilReproduce)
     : base(typeof(Tiger), pasture, timeToMove, timeUntilStarves, timeUntilReproduce)
 {
     canEat = new HashSet <Type>();
     canEat.Add(typeof(Cow));
     this.alive = true;
 }
Ejemplo n.º 2
0
        public void CallByNameTest()
        {
            //expected
            Horse   horse   = new Horse("Шептало", "ч");
            Deer    deer    = new Deer("Олень", "ч");
            Deer    deer1   = new Deer("Олень", "ч");
            Pasture pasture = new Pasture();

            pasture.Add(horse);
            pasture.Add(deer);
            pasture.Add(deer1);
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            string        expexted     = "expexted";
            List <string> expectedList = new List <string>()
            {
                "expectedList"
            };

            Mock.Arrange(() => deer.Voice()).Returns(expexted);
            Mock.Arrange(() => deer1.Voice()).Returns(expexted);
            Mock.Arrange(() => pastureStub.Call(Arg.IsAny <string>())).Returns(expectedList);

            // actual
            List <string> list = pasture.Call("Олень");

            Assert.AreEqual(expexted, list[0]);
            Assert.AreEqual(expexted, list[1]);
            Assert.AreEqual(expectedList[0], list[2]);
            Assert.AreEqual(3, list.Count);
        }
Ejemplo n.º 3
0
 public Cow(Pasture pasture, int timeToMove, int timeUntilStarves, int timeUntilReproduce)
     : base(typeof(Cow), pasture, timeToMove, timeUntilStarves, timeUntilReproduce)
 {
     this.canEat = new HashSet <Type>();
     this.canEat.Add(typeof(Grass));
     this.alive = true;
 }
Ejemplo n.º 4
0
        public JsonResult AddPasture(string pastureName, string farmAdminAccount, string farmAdminName)
        {
            string msg = "";

            if (pastureName.Equals(string.Empty) || farmAdminAccount.Equals(string.Empty))
            {
                msg = "页面传入牧场名或牧场管理员账号不能为空。";
            }
            else
            {
                int i1 = pastureBLL.AddPasture(pastureName);

                if (i1 == 1)
                {
                    Pasture myPasture = pastureBLL.GetPasture(pastureName);
                    //copy pasture parameters
                    DairyParameterBLL.CopyPlatformParameters(myPasture.ID);
                    userBLL.InsertUser(farmAdminName, farmAdminAccount, "123", "8", myPasture.ID.ToString());
                    msg = "创建牧场成功!";
                }
                else
                {
                    msg = "牧场未能创建!";
                }
            }
            var Result = new
            {
                Msg = msg
            };

            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public void CallTest()
        {
            //expected
            Horse   horse   = new Horse("Шептало", "ч");
            Pasture pasture = new Pasture();

            pasture.Add(horse);
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            string        expexted     = "expexted";
            List <string> expectedList = new List <string>()
            {
                "expectedList"
            };

            Mock.Arrange(() => horse.Voice()).Returns(expexted);
            Mock.Arrange(() => pastureStub.Call()).Returns(expectedList);

            // actual
            List <string> list = pasture.Call();

            Assert.AreEqual(expexted, list[0]);
            Assert.AreEqual(expectedList[0], list[1]);
        }
 public Animal(Type animalType, Pasture pasture, int timeToMove, int timeUntilStarves, int timeUntilReproduce)
     : base(animalType, timeUntilReproduce)
 {
     this.pasture          = pasture;
     this.timeToMove       = timeToMove;
     this.timeSinceMoved   = 0;
     this.timeUntilStarves = timeUntilStarves;
     this.timeSinceEaten   = 0;
 }
Ejemplo n.º 7
0
 public Cow(Pasture pasture, int ttl, int ttm, int ttr)
 {
     this.pasture  = pasture;
     this.ttl      = ttl;
     this.ttm      = ttm;
     this.ttr      = ttr;
     this.curr_ttl = ttl;
     this.curr_ttm = ttm;
     this.curr_ttr = ttr;
 }
Ejemplo n.º 8
0
 public Task SavePastureAsyncExtensions(Pasture pasture)
 {
     if (pasture.ID != 0)
     {
         return(_connection.UpdateWithChildrenAsync(pasture));
     }
     else
     {
         return(_connection.InsertWithChildrenAsync(pasture));
     }
 }
Ejemplo n.º 9
0
 public Task <int> SavePastureAsync(Pasture pasture)
 {
     if (pasture.ID != 0)
     {
         return(_connection.UpdateAsync(pasture));
     }
     else
     {
         return(_connection.InsertAsync(pasture));
     }
 }
Ejemplo n.º 10
0
        private void InitRoot()
        {
            root = new HabitationsGroup();

            Pasture pasture = new Pasture(CommonTestData.bowtruckle);
            Room    room    = new Room(CommonTestData.demiguise);
            Aviary  aviary  = new Aviary(CommonTestData.occamy);

            root.AddContainer(pasture);
            root.AddContainer(room);
            root.AddContainer(aviary);
        }
Ejemplo n.º 11
0
        public void CountAnimalsTest()
        {
            //expected
            Pasture     pasture     = new Pasture();
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            int expexted = 1;

            Mock.Arrange(() => pastureStub.CountAnimals()).Returns(1);

            // actual
            int actual = pasture.CountAnimals();

            Assert.AreEqual(expexted, actual);
        }
Ejemplo n.º 12
0
        public ActionResult Post([FromBody] Pasture pasture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _repository.Save(pasture);
                return(Ok(pasture));
            }
            catch
            {
                return(BadRequest(new { message = "Não foi possível salvar o pasto." }));
            }
        }
Ejemplo n.º 13
0
        public Pasture WrapPastureItem(DataRow row)
        {
            Pasture p = new Pasture();

            p.ID   = Convert.ToInt32(row["ID"].ToString());
            p.Name = row["Name"].ToString();
            int temp = Convert.ToInt32(row["IsActive"]);

            if (temp > 0)
            {
                p.IsActive = true;
            }
            else
            {
                p.IsActive = false;
            }
            return(p);
        }
Ejemplo n.º 14
0
        public void PastureBuildTest()
        {
            //expected
            bool called     = false;
            bool redirected = false;

            Pasture pasture = new Pasture();

            Mock.Arrange(() => new Pasture()).DoInstead(() => called = true);
            pasture.BuildPasture();
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            Mock.Arrange(() => pastureStub.BuildPasture()).DoInstead(() => redirected = true);
            pasture.BuildPasture();

            Assert.IsTrue(called);
            Assert.IsTrue(redirected);
        }
Ejemplo n.º 15
0
        public void GetFoodTest()
        {
            //expected
            Horse   horse   = new Horse("Шептало", "ч");
            Pasture pasture = new Pasture();

            pasture.Add(horse);
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            double expexted = 11.0;

            Mock.Arrange(() => horse.dailyFood).Returns(1.0);
            Mock.Arrange(() => pastureStub.GetFood()).Returns(10.0);

            // actual
            double actual = pasture.GetFood();

            Assert.AreEqual(expexted, actual);
        }
Ejemplo n.º 16
0
        public ActionResult Put(int id, [FromBody] Pasture pasture)
        {
            if (id != pasture.Id)
            {
                return(NotFound(new { message = "Pasto não encontrado." }));
            }

            try
            {
                _repository.Update(pasture);
                return(Ok(pasture));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(BadRequest(new { message = "Este pasto já foi atualizado." }));
            }
            catch
            {
                return(BadRequest(new { message = "Não foi possível atualizar o pasto." }));
            }
        }
Ejemplo n.º 17
0
        public void PastureAddTest()
        {
            //expected
            string expextedAdded = "Тварину заселено.";
            string expextedPastureOvercrowded = "Неможливо заселити тварину! Немає вiльних пасовиськ!";
            // Хочемо отримати відповідь від повністю забитого пасовища
            Horse   horse       = new Horse("Знайда", "ч");
            Pasture overcrowded = new Pasture();

            for (int i = 0; i < 20; i++)
            {
                Horse crowd = new Horse("Табун", "ч");
                overcrowded.animals.Add(crowd);
            }
            Mock.Arrange(() => overcrowded.Add(horse)).Returns(expextedPastureOvercrowded);
            // Хочемо отримати підтвердження від пасовища, що передало тварину іншому пасовищу
            Deer    lostDeer             = new Deer("Приблуда", "ч");
            Pasture overcrowdedWithDeers = new Pasture();

            for (int i = 0; i < 20; i++)
            {
                Deer crowd = new Deer("Стадо", "ч");
                overcrowdedWithDeers.animals.Add(crowd);
            }
            Mock.Arrange(() => overcrowdedWithDeers.Add(lostDeer)).Returns(expextedAdded);

            //actual
            string  actualOvercrowded = overcrowded.Add(horse);
            Deer    deer        = new Deer("Олень", "ч");
            Pasture pasture     = new Pasture();
            string  actualAdded = pasture.Add(deer);
            string  redirected  = overcrowdedWithDeers.Add(lostDeer);

            Assert.AreEqual(expextedAdded, actualAdded);
            Assert.AreEqual(expextedPastureOvercrowded, actualOvercrowded);
            Assert.AreEqual(expextedAdded, redirected);
        }
Ejemplo n.º 18
0
 public Task <Pasture> GetPastureByIdAsyncExtensions(Pasture pasture)
 {
     return(_connection.GetWithChildrenAsync <Pasture>(pasture.ID));
 }
Ejemplo n.º 19
0
 public Engine(Pasture pasture)
 {
     this.pasture = pasture;
 }
Ejemplo n.º 20
0
 /*
  * Creates a new instance of this class, with the given pasture as
  * its pasture, and its status as a moving entity.
  */
 public Dummy(Pasture pasture, bool alive)
 {
     this.pasture = pasture;
     this.alive   = alive;
     moveDelay    = 10;
 }
Ejemplo n.º 21
0
 /*
  * Creates a new instance of this class, with the given pasture as
  * its pasture.
  */
 public Dummy(Pasture pasture)
 {
     this.pasture = pasture;
     moveDelay    = 10;
 }
Ejemplo n.º 22
0
 public void Update(Pasture pasture)
 {
     _context.Entry <Pasture>(pasture).State = EntityState.Modified;
     _context.SaveChanges();
 }
Ejemplo n.º 23
0
 public void Save(Pasture pasture)
 {
     _context.Pastures.Add(pasture);
     _context.SaveChanges();
 }
 public Grass(Pasture pasture, int timeUntilReproduce)
     : base(typeof(Grass), timeUntilReproduce)
 {
     this.pasture = pasture;
     this.alive   = true;
 }
Ejemplo n.º 25
0
 /** The method for C# to run. */
 public static void Main(String[] args)
 {
     Pasture p = new Pasture();
 }
Ejemplo n.º 26
0
 public Task <int> DeletePastureAsyncExtensions(Pasture pasture)
 {
     return(_connection.DeleteAsync(pasture));
 }
Ejemplo n.º 27
0
 public Grass(Pasture pasture)
 {
     this.pasture = pasture;
 }
Ejemplo n.º 28
0
 public Fence(Pasture pasture)
 {
     this.pasture = pasture;
 }