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;
 }
Пример #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);
        }
 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;
 }
Пример #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));
        }
Пример #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;
 }
Пример #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;
 }
Пример #8
0
 public Task SavePastureAsyncExtensions(Pasture pasture)
 {
     if (pasture.ID != 0)
     {
         return(_connection.UpdateWithChildrenAsync(pasture));
     }
     else
     {
         return(_connection.InsertWithChildrenAsync(pasture));
     }
 }
Пример #9
0
 public Task <int> SavePastureAsync(Pasture pasture)
 {
     if (pasture.ID != 0)
     {
         return(_connection.UpdateAsync(pasture));
     }
     else
     {
         return(_connection.InsertAsync(pasture));
     }
 }
Пример #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);
        }
Пример #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);
        }
Пример #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." }));
            }
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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." }));
            }
        }
Пример #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);
        }
Пример #18
0
 public Task <Pasture> GetPastureByIdAsyncExtensions(Pasture pasture)
 {
     return(_connection.GetWithChildrenAsync <Pasture>(pasture.ID));
 }
Пример #19
0
 public Engine(Pasture pasture)
 {
     this.pasture = pasture;
 }
Пример #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;
 }
Пример #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;
 }
Пример #22
0
 public void Update(Pasture pasture)
 {
     _context.Entry <Pasture>(pasture).State = EntityState.Modified;
     _context.SaveChanges();
 }
Пример #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;
 }
Пример #25
0
 /** The method for C# to run. */
 public static void Main(String[] args)
 {
     Pasture p = new Pasture();
 }
Пример #26
0
 public Task <int> DeletePastureAsyncExtensions(Pasture pasture)
 {
     return(_connection.DeleteAsync(pasture));
 }
Пример #27
0
 public Grass(Pasture pasture)
 {
     this.pasture = pasture;
 }
Пример #28
0
 public Fence(Pasture pasture)
 {
     this.pasture = pasture;
 }