public void Should_Return_All_The_Registered_AreaCodes() { var rnd = new Random(); var cities = AreaCodeFaker.GenerateAreaCodes(rnd.Next(0, 11)); var citiesViewModel = AreaCodeViewModelFaker.GenerateAreaCodesViewModel(cities); citiesRepository.Setup(x => x.FindAll()).Returns(cities); mapper.Setup(x => x.Map <IEnumerable <AreaCodeViewModel> >(cities)) .Returns(citiesViewModel); var response = cityServices.ListAllAreaCodes(); Assert.NotNull(response); Assert.IsType <List <AreaCodeViewModel> >(response); }
public void Should_Return_200_Status_Code_When_Listing_All_Cities() { var rnd = new Random(); var areaCodes = AreaCodeFaker.GenerateAreaCodes(rnd.Next(1, 11)); var areaCodesViewModel = AreaCodeViewModelFaker.GenerateAreaCodesViewModel(areaCodes); areaCodeServices.Setup(x => x.ListAllAreaCodes()).Returns(areaCodesViewModel); var response = areaCodesController.Index(areaCodeServices.Object); var actionResult = Assert.IsType <OkObjectResult>(response.Result); var actionValue = Assert.IsType <List <AreaCodeViewModel> >(actionResult.Value); Assert.NotNull(actionResult); Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode); }