public void GetExistingItemsWithSubFolder() { Mock<IRSCommunicator> communicator = new Mock<IRSCommunicator>(); CatalogItem item = new CatalogItem() { Path = "/Folder/report", Type = ItemTypeEnum.Report, Name = "report" }; CatalogItem subfolder = new CatalogItem() { Path = "/Folder/subfolder", Type = ItemTypeEnum.Folder, Name = "subfolder" }; CatalogItem subItem = new CatalogItem() { Path = "/Folder/subfolder/subreport", Type = ItemTypeEnum.Report, Name = "subreport" }; communicator.Setup(c => c.GetExistingReports("Folder")).Returns(new[] { item, subfolder, subItem }); RSRepository repo = new RSRepository(communicator.Object, null); Folder rootFolder = repo.GetExistingItems("Folder"); Assert.AreEqual("Folder", rootFolder.Name); Assert.AreEqual("report", rootFolder.Reports.First().Name); Folder subFolder = rootFolder.SubFolders.First(); Assert.AreEqual("subfolder", subFolder.Name); Assert.AreEqual("subreport", subFolder.Reports.First().Name); }
public void MoveReports() { try { RSRepository repo = new RSRepository(new RSCommunicator(SourceUrl, SourceUserName, SourcePassword), new RSCommunicator(DestUrl)); repo.UploadReports(SourceRootFolder, DestRootFolderName, DestDataSourceName); } catch (Exception e) { MessageBox.Show(e.Message, "Error"); } }
public void GetSourceData() { try { _communicator = new RSCommunicator(SourceUrl, SourceUserName, SourcePassword); RSRepository repo = new RSRepository(_communicator, null); SourceRootFolder = repo.GetExistingItems(SourceRootFolderName); } catch (Exception e) { MessageBox.Show(e.Message, "Error"); } }
public void UploadReports_SubfolderWithReport_IgnoresUnselected() { Folder rootFolder = new Folder() {Name = "RootFolder", Path = "/RootFolder"}; Report report = new Report(){Name="Report", ParentFolder = rootFolder, Path = "/RootFolder/Report"}; rootFolder.Reports.Add(report); Folder subFolder = new Folder(){Name="SubFolder", Path="/RootFolder/SubFolder", Selected =false}; Report subReport = new Report() { Name = "SubReport", ParentFolder = subFolder, Path = "/RootFolder/SubFolder/SubReport", Selected = false}; subFolder.Reports.Add(subReport); rootFolder.SubFolders.Add(subFolder); Mock<IRSCommunicator> sourceComm = new Mock<IRSCommunicator>(); sourceComm.Setup(s => s.GetReportDefinition("/RootFolder/Report")).Returns(new byte[0]); Mock<IRSCommunicator> destComm = new Mock<IRSCommunicator>(); RSRepository repo = new RSRepository(sourceComm.Object, destComm.Object); repo.UploadReports(rootFolder, "NewRootFolder", "dsPath"); sourceComm.Verify(s=>s.GetReportDefinition("/RootFolder/Report"), Times.Once()); sourceComm.Verify(s=>s.GetReportDefinition("/RootFolder/SubFolder/SubReport"), Times.Never()); destComm.Verify(d=>d.CreateFolder("NewRootFolder", "/"), Times.Once()); destComm.Verify(d => d.CreateReport("Report", "/NewRootFolder", It.IsAny<byte[]>(), "dsPath"), Times.Once()); destComm.Verify(d => d.CreateFolder("SubFolder", "/NewRootFolder"), Times.Never()); destComm.Verify(d => d.CreateReport("SubReport", "/NewRootFolder/SubFolder", It.IsAny<byte[]>(), "dsPath"), Times.Never()); }
public void UploadReports_SingleReport() { Folder rootFolder = new Folder() {Name = "RootFolder", Path = "/RootFolder"}; Report report = new Report(){Name="Report", ParentFolder = rootFolder, Path = "/RootFolder/Report"}; rootFolder.Reports.Add(report); Mock<IRSCommunicator> sourceComm = new Mock<IRSCommunicator>(); sourceComm.Setup(s => s.GetReportDefinition("/RootFolder/Report")).Returns(new byte[0]); Mock<IRSCommunicator> destComm = new Mock<IRSCommunicator>(); RSRepository repo = new RSRepository(sourceComm.Object, destComm.Object); repo.UploadReports(rootFolder, "NewRootFolder", "dsPath"); sourceComm.Verify(s=>s.GetReportDefinition("/RootFolder/Report"), Times.Once()); destComm.Verify(d=>d.CreateFolder("NewRootFolder", "/"), Times.Once()); destComm.Verify(d => d.CreateReport("Report", "/NewRootFolder", It.IsAny<byte[]>(), "dsPath"), Times.Once()); }