public async Task Get_given_non_existing_returns_NotFound() { var repo = new Mock <IWineRepository>(); var controller = new WinesController(repo.Object); var get = await controller.Get(42); var res = get.Result; Assert.IsType <NotFoundResult>(res); }
public async Task Get_existing_id_returns_dto() { var dto = new WineDTO(); var repo = new Mock <IWineRepository>(); repo.Setup(s => s.FindAsync(42)).ReturnsAsync(dto); var controller = new WinesController(repo.Object); var get = await controller.Get(42); Assert.Equal(dto, get.Value); }
public async Task GetWines_returns_all() { IList <WineDTO> dtos = new List <WineDTO>() { new WineDTO() }; var repo = new Mock <IWineRepository>(); repo.Setup(s => s.ReadAsync()).ReturnsAsync(dtos); var controller = new WinesController(repo.Object); var get = await controller.Get(); }