Ejemplo n.º 1
0
        public void GetElephants_ReturnsList()
        {
            var elephants = new List <Elephant>()
            {
                new Elephant()
                {
                    Name = "Sam",
                    Dob  = 100,
                    Dod  = 101
                }
            };


            // arrange
            _elephantService.Setup(x => x.GetElephants(It.IsAny <string>())).ReturnsAsync(elephants);
            var controller = new ElephantController(_elephantService.Object);


            // act
            var result = controller.GetElephants(true);

            // assert
            Assert.NotNull(result);
            Assert.Equal(elephants, result);
        }
Ejemplo n.º 2
0
        public void GetProduct_ShouldReturnCorrectElephant()
        {
            // Act
            var testProducts = GetTestElephants();
            var controller   = new ElephantController();
            //Assert
            var result = controller.Get(4) as OkObjectResult;
            var data   = result.Value as Elephants;

            Assert.NotNull(result);
            Assert.Equal(testProducts[3].Name, data.Name);
        }
Ejemplo n.º 3
0
        public void GetAllProducts_ShouldReturnAllElephants()
        {
            // Act
            var testProducts = GetTestElephants();
            var controller   = new ElephantController();

            var result = controller.Get() as List <Elephants>;

            Assert.NotNull(result);
            // Assert
            Assert.Equal(testProducts.Count, result.Count);
        }
Ejemplo n.º 4
0
        public void GetElephant_ReturnsOne()
        {
            //arrange
            var searchedGuid    = Guid.NewGuid();
            var correctElephant = new Elephant()
            {
                Name = "Sam",
                Id   = searchedGuid,
                Note = "This is the elephant we want to get"
            };
            var incorrectElephant1 = new Elephant()
            {
                Name = "Barry",
                Id   = Guid.NewGuid(),
                Note = "This is NOT the elephant we want to get"
            };
            var incorrectElephant2 = new Elephant()
            {
                Name = "Steve",
                Id   = Guid.NewGuid(),
                Note = "This is NOT the elephant we want to get"
            };

            var elephantList = new List <Elephant>();

            elephantList.Add(correctElephant);
            elephantList.Add(incorrectElephant1);
            elephantList.Add(incorrectElephant2);
            var controller = new ElephantController(_elephantService.Object);

            _elephantService.Setup(x => x.GetElephants(It.IsAny <string>())).ReturnsAsync(elephantList);

            //act
            var response = controller.GetElephant(searchedGuid);
            var result   = (OkObjectResult)response.Result;

            //assert
            Assert.NotNull(result.Value);
            Assert.Equal(correctElephant, result.Value);
            Assert.True(result is OkObjectResult);
            Assert.IsType <Elephant>(result.Value);
            Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
        }
Ejemplo n.º 5
0
        public void GetElephant_OnEmptyList()
        {
            //arrange
            var elephantList = new List <Elephant>();
            var controller   = new ElephantController(_elephantService.Object);

            _elephantService.Setup(x => x.GetElephants(It.IsAny <string>())).ReturnsAsync(elephantList);

            //act
            var response = controller.GetElephant(Guid.NewGuid());
            var result   = (NotFoundResult)response.Result;

            //assert
            Assert.Equal(404, result.StatusCode);

            Assert.NotNull(result);
            Assert.True(result is NotFoundResult);
            Assert.Equal(StatusCodes.Status404NotFound, result.StatusCode);
        }
Ejemplo n.º 6
0
 void OnGameInitialized()
 {
     if (GameManager.Instance.getCurrentGameState() + 1 >= GameManager.GameSate.ELEPHANT_HUB && Application.loadedLevelName == "ElephantHub")
     {
         //MainUIManager.Instance.hudController.gameObject.SetActive
         MainUIManager.Instance.hudController.mapIcon.SetActive(true);
         MainUIManager.Instance.hudController.EnableUIMapGlow();
         MainUIManager.Instance.hudController.inventoryIcon.SetActive(true);
         Player   = GameObject.FindObjectOfType <KatkootiController> ();
         Elephant = GameObject.FindObjectOfType <ElephantController> ();
         PlayCurrentState();
     }
     else if (Application.loadedLevelName == "ElephantHub")
     {
         MainUIManager.Instance.hudController.mapIcon.SetActive(true);
         MainUIManager.Instance.hudController.EnableUIMapGlow();
         MainUIManager.Instance.hudController.inventoryIcon.SetActive(true);
         Player   = GameObject.FindObjectOfType <KatkootiController> ();
         Elephant = GameObject.FindObjectOfType <ElephantController> ();
         GameManager.Instance.StartCoroutine(GameManager.Instance.elephantcontroller.NotAvailable());
     }
 }