public async Task GetAll_Retorna_BadRequest() { var serviceMock = new Mock <IChurrasService>(); List <ChurrasEntity> listaChurras = new List <ChurrasEntity>(); for (int i = 0; i < 5; i++) { var churras = new ChurrasEntity(i, "thomaz", DateTime.Now, "churras", 10, 10); listaChurras.Add(churras); } serviceMock.Setup(x => x.GetAll()).ReturnsAsync(listaChurras); var controller = new ChurrasController(serviceMock.Object, _serviceProvide.GetService <DataContext>()); controller.ModelState.AddModelError("Date", "Ja existe churras marcado neste dia"); var result = await controller.GetAll(); Assert.True(result is BadRequestObjectResult); }
public async Task GetAll_Retorna_Ok() { var serviceMock = new Mock <IChurrasService>(); List <ChurrasEntity> listaChurras = new List <ChurrasEntity>(); for (int i = 0; i < 5; i++) { var churras = new ChurrasEntity(i, "thomaz", DateTime.Now, "churras", 10, 10); listaChurras.Add(churras); } serviceMock.Setup(x => x.GetAll()).ReturnsAsync(listaChurras); var controller = new ChurrasController(serviceMock.Object, _serviceProvide.GetService <DataContext>()); var result = await controller.GetAll(); Assert.True(result is OkObjectResult); Assert.True(listaChurras.Count() == 5); }