public void GetByDiaOk() { int dia = 4; var pronostico = new Pronostico { Clima = ClimaConstants.Sequia, Dia = dia, Fecha = DateTime.Today, NivelDeLluvia = 0 }; pronosticoServiceMock.Setup(service => service.GetByDia(dia)).Returns(pronostico); var controller = new PronosticoController(logger, pronosticoServiceMock.Object, jobServiceMock.Object, memoryCache); var actionResult = controller.Get(dia); // Assert Assert.NotNull(actionResult); var result = actionResult as OkObjectResult; Assert.NotNull(result); var p = result.Value as Pronostico; Assert.AreEqual(p.Dia, dia); }
public void GetByDiaNotFound() { int dia = -1; pronosticoServiceMock.Setup(service => service.GetByDia(dia)).Returns((Pronostico)null); var controller = new PronosticoController(logger, pronosticoServiceMock.Object, jobServiceMock.Object, memoryCache); var actionResult = controller.Get(dia); // Assert Assert.NotNull(actionResult); var result = actionResult as NotFoundObjectResult; Assert.NotNull(result); }
public void GetAll() { var list = new List <Pronostico>(); var pronostico = new Pronostico { Clima = ClimaConstants.Sequia, Dia = 2, Fecha = DateTime.Today, NivelDeLluvia = 0 }; list.Add(pronostico); pronostico = new Pronostico { Clima = ClimaConstants.Sequia, Dia = 4, Fecha = DateTime.Today, NivelDeLluvia = 0 }; list.Add(pronostico); pronostico = new Pronostico { Clima = ClimaConstants.Sequia, Dia = 5, Fecha = DateTime.Today, NivelDeLluvia = 0 }; list.Add(pronostico); pronosticoServiceMock.Setup(service => service.GetAll()).Returns(list); var controller = new PronosticoController(logger, pronosticoServiceMock.Object, jobServiceMock.Object, memoryCache); var actionResult = controller.Get(); // Assert Assert.NotNull(actionResult); var result = actionResult as OkObjectResult; Assert.NotNull(result); var pronosticos = result.Value as List <Pronostico>; Assert.AreEqual(pronosticos.Count, 3); }