public void GetRegionesConElementoOk() { var logicMock = new Mock <IRegion>(MockBehavior.Strict); RegionesController controller = new RegionesController(logicMock.Object); RegionModel regionModel = new RegionModel() { Nombre = "Este", }; Region region = new Region() { Nombre = regionModel.Nombre, Puntos = new List <PuntoTuristico>(), Id = 0, }; List <Region> lista = new List <Region>(); lista.Add(region); logicMock.Setup(x => x.Region(regionModel.Nombre)).Returns(region); logicMock.Setup(x => x.AgregarRegion(region)); logicMock.Setup(x => x.ObtenerTodas()).Returns(lista); controller.Post(1, regionModel); var result = controller.Get(); var okResult = result as OkObjectResult; var retorno = okResult.Value as List <Region>; logicMock.VerifyAll(); Assert.AreEqual(1, retorno.Count); }
public void GetRegionesSinElementoOk() { var logicMock = new Mock <IRegion>(MockBehavior.Strict); RegionesController controller = new RegionesController(logicMock.Object); List <Region> lista = new List <Region>(); logicMock.Setup(x => x.ObtenerTodas()).Returns(lista); var result = controller.Get(); var okResult = result as OkObjectResult; var retorno = okResult.Value as List <Region>; logicMock.VerifyAll(); Assert.AreEqual(0, retorno.Count); }