public void Get_WhenCalled_ReturnsOkResult() { // Act var okResult = shopsController.GetShops(); // Assert Assert.IsType <OkObjectResult>(okResult.Result); }
public async Task GetShops_Positive() { //Arrange List <Shop> ShopObjList = new List <Shop>(); List <ShopDto> ShopList = new List <ShopDto>(); Shop ShopObj = new Shop() { ShopID = 1, ShopName = "Nike", ShopCity = "Halifax", ShopCountry = "Canada", ShopState = "NS", ShopStreet = "2001 Brunswick", ShopZip = "B3J3J7" }; ShopDto Shop = new ShopDto() { ShopID = 1, ShopName = "Nike", ShopCity = "Halifax", ShopCountry = "Canada", ShopState = "NS", ShopStreet = "2001 Brunswick", ShopZip = "B3J3J7" }; ShopList.Add(Shop); ShopObjList.Add(ShopObj); //Mock mockShopiMaxRepo.Setup(x => x.GetShops()).ReturnsAsync(ShopObjList); mockMapperRepo.Setup(mock => mock.Map <IEnumerable <ShopDto> >(It.IsAny <IEnumerable <Shop> >())).Returns(ShopList); //Result IActionResult result = await controllerObj.GetShops(); OkObjectResult Objresult = result as OkObjectResult; List <ShopDto> ShopDisplay = Objresult.Value as List <ShopDto>; //Assert Assert.IsTrue(ShopDisplay[0].ShopID == Shop.ShopID); }