コード例 #1
0
        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);
        }
コード例 #2
0
 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");
     }
 }
コード例 #3
0
        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");

            }
        }
コード例 #4
0
 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");
     }
 }
コード例 #5
0
        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");

            }
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }