public void GetNews() { var fakeSiteUrl = "http://www.telerik.com"; var fakeSharepointSite = Mock.Create <SPSite>(); var fakeSharePointList = Mock.Create <SPList>(); Mock.Arrange(() => SPContext.Current.Site).Returns(fakeSharepointSite); Mock.Arrange(() => fakeSharepointSite.RootWeb.Lists.TryGetList("demo")).Returns(fakeSharePointList); var service = new ImageGaleryService(fakeSharePointList, 10); Mock.Arrange(() => service.GetNews()).Returns(new List <ImageGallery> { new ImageGallery { Title = "Imagen", Description = "Image", UrlNew = new UrlField { Description = string.Empty, Url = "http://google.es" }, Image = new UrlField { Description = string.Empty, Url = "http://google.es" }, Visible = true, ID = "1", OpenWindows = true } }); }
private void LoadData() { try { var listSharePoint = SPContext.Current.Web.Lists.TryGetList(Constants.List.ImageGallery); var imageGaleryService = new ImageGaleryService(listSharePoint, 5); var imageGaleryCollection = imageGaleryService.GetNews(); listViewImageGalery.DataSource = imageGaleryCollection; listViewImageGalery.DataBind(); } catch (Exception exception) { Logger.Error(string.Concat("Error Concat LoadData", exception.Message)); } }