public void TestPostAnimal()
        {
            _context    = DbContextMocker.GetAnimalsGameContext(Guid.NewGuid().ToString());
            _service    = new AnimalsGameService(_context, null);
            _controller = new AnimalController(_context, _service);

            Animal newAnimal = new Animal
            {
                AnimalId  = 123,
                Type      = AnimalType.SMALL,
                Name      = "Penguin",
                Happiness = Constants.NEUTRAL,
                Hunger    = Constants.NEUTRAL,
                UserId    = 0 // No user assigned
            };

            _controller.AddAnimal(newAnimal);

            List <Animal> animals = _controller.GetAnimals();

            Assert.NotNull(animals);
            Assert.Equal(4, animals.Count);

            _context.Database.EnsureDeleted();
        }
        public void TestGetAllAnimals()
        {
            _context    = DbContextMocker.GetAnimalsGameContext(Guid.NewGuid().ToString());
            _service    = new AnimalsGameService(_context, null);
            _controller = new AnimalController(_context, _service);

            List <Animal> animals = _controller.GetAnimals();

            Assert.NotNull(animals);
            Assert.Equal(3, animals.Count);

            _context.Database.EnsureDeleted();
        }
        public void TestGetAnimal()
        {
            _context    = DbContextMocker.GetAnimalsGameContext(Guid.NewGuid().ToString());
            _service    = new AnimalsGameService(_context, null);
            _controller = new AnimalController(_context, _service);

            var result = _controller.GetAnimal(1);

            Assert.NotNull(result);
            Assert.Equal("Bear", result.Value.Name);

            _context.Database.EnsureDeleted();
        }
        public void TestFeedAnimal()
        {
            _context    = DbContextMocker.GetAnimalsGameContext(Guid.NewGuid().ToString());
            _service    = new AnimalsGameService(_context, null);
            _controller = new AnimalController(_context, _service);

            _controller.FeedAnimal(1);
            var firstResult = _controller.GetAnimal(1);

            Console.Write(firstResult.Value.Hunger);
            Assert.Equal(5, firstResult.Value.Hunger);

            _controller.FeedAnimal(1);
            var secondResult = _controller.GetAnimal(1);

            Assert.Equal(0, secondResult.Value.Hunger);

            _context.Database.EnsureDeleted();
        }
 public AnimalController(AnimalsGameContext context, IAnimalsGameService service)
 {
     _context = context;
     _service = service;
 }