public void ShouldReturnExceptionWhenErrorOcurrs() { //Arrage IEnumerable <StarShip> starShip = new List <StarShip>(); AllStarShipsResponse result = new AllStarShipsResponse() { next = "", Result = starShip }; _starWarsRepositoryHelper.Setup(x => x.GetAllStarShipsAsync("1")).Throws(new Exception()); StarWarsRepository repository = new StarWarsRepository(_starWarsRepositoryHelper.Object); //Act AsyncTestDelegate act = () => repository.GetAllStarShips(); //Assert Assert.That(act, Throws.TypeOf <Exception>()); }
public async Task ShouldReturnStarShipListObject() { //Arrage IEnumerable <StarShip> starShip = new List <StarShip>(); AllStarShipsResponse result = new AllStarShipsResponse() { next = "", Result = starShip }; _starWarsRepositoryHelper.Setup(x => x.GetAllStarShipsAsync("1")).Returns(Task.FromResult(result)); StarWarsRepository repository = new StarWarsRepository(_starWarsRepositoryHelper.Object); //Act var starShips = await repository.GetAllStarShips(); //Assert Assert.IsInstanceOf <IEnumerable <StarShip> >(starShips); }