public void ExportDataSources()
        {
            reader.GetDataSources("/SSRSMigrate_AW_Tests", GetDataSources_Reporter);

            foreach (DataSourceItem actualDataSourceItem in actualDataSourceItems)
            {
                string saveFilePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(actualDataSourceItem.Path, "json");

                ExportStatus actualStatus = dataSourceExporter.SaveItem(
                    actualDataSourceItem,
                    saveFilePath,
                    true);

                // Export was successful
                Assert.True(actualStatus.Success, string.Format("Success; {0}", actualDataSourceItem.Path));

                // Was exported to the expected location
                Assert.AreEqual(saveFilePath, actualStatus.ToPath, string.Format("ToPath; {0}", actualDataSourceItem.Path));

                // Was exported from the expected location
                Assert.AreEqual(actualDataSourceItem.Path, actualStatus.FromPath, string.Format("ToPath; {0}", actualDataSourceItem.Path));

                // The exported DataSourceItem exists on disk
                Assert.True(File.Exists(actualStatus.ToPath));
            }
        }
        public void ExportReports()
        {
            reader.GetReports("/SSRSMigrate_AW_Tests", GetReports_Reporter);

            foreach (ReportItem actualReportItem in actualReportItems)
            {
                string saveFilePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(actualReportItem.Path, "rdl");

                ExportStatus actualStatus = reportExporter.SaveItem(
                    actualReportItem,
                    saveFilePath,
                    true);

                // Export was successful
                Assert.True(actualStatus.Success, string.Format("Success; {0}", actualReportItem.Path));

                // Exported to the expected location
                Assert.AreEqual(saveFilePath, actualStatus.ToPath, string.Format("ToPath; {0}", actualReportItem.Path));

                // Was exported from the expected location
                Assert.AreEqual(actualReportItem.Path, actualStatus.FromPath, string.Format("ToPath; {0}", actualReportItem.Path));

                // The exported ReportItem exists on disk
                Assert.True(File.Exists(actualStatus.ToPath));
            }

            // The exported reports file matches the expected file
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[0], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Company Sales.rdl"));
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[1], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Sales Order Detail.rdl"));
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[2], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Store Contacts.rdl"));
        }
示例#3
0
        public string WriteDataSource(DataSourceItem dataSourceItem)
        {
            if (dataSourceItem == null)
            {
                throw new ArgumentNullException("dataSourceItem");
            }

            if (!this.mReportRepository.ValidatePath(dataSourceItem.Path))
            {
                throw new InvalidPathException(dataSourceItem.Path);
            }

            string name       = dataSourceItem.Name;
            string parentPath = SSRSUtil.GetParentPath(dataSourceItem);

            if (!this.mOverwrite)
            {
                if (this.mReportRepository.ItemExists(dataSourceItem.Path, "DataSource"))
                {
                    throw new ItemAlreadyExistsException(dataSourceItem.Path);
                }
            }

            return(this.mReportRepository.WriteDataSource(parentPath, dataSourceItem, this.mOverwrite));
        }
示例#4
0
        public string[] WriteReport(ReportItem reportItem)
        {
            if (reportItem == null)
            {
                throw new ArgumentNullException("reportItem");
            }

            // Verify that the report's path is valid
            if (!this.mReportRepository.ValidateItemPath(reportItem.Path))
            {
                throw new InvalidPathException(reportItem.Path);
            }

            // Get the report's name and path to its parent folder
            string name       = reportItem.Name;
            string parentPath = SSRSUtil.GetParentPath(reportItem);

            // Check if a report already exists at the specified path
            if (!this.mOverwrite)
            {
                if (this.mReportRepository.ItemExists(reportItem.Path, "Report"))
                {
                    throw new ItemAlreadyExistsException(reportItem.Path);
                }
            }

            // Create the report at parentPath and return any warnings
            return(this.mReportRepository.WriteReport(parentPath, reportItem, this.mOverwrite));
        }
示例#5
0
        public void GetSqlServerVersion_SQL2000()
        {
            SSRSVersion expected = SSRSVersion.SqlServer2000;

            SSRSVersion actual = SSRSUtil.GetSqlServerVersion("Microsoft SQL Server Reporting Services Version 8.00.194");

            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void GetSqlServerVersion_SQL7()
        {
            SSRSVersion expected = SSRSVersion.SqlServer7;

            SSRSVersion actual = SSRSUtil.GetSqlServerVersion("Microsoft SQL Server Reporting Services Version 7.00.623");

            Assert.AreEqual(expected, actual);
        }
示例#7
0
        public void GetSqlServerVersion_Unknown_BadVersionText()
        {
            SSRSVersion expected = SSRSVersion.Unknown;

            SSRSVersion actual = SSRSUtil.GetSqlServerVersion("Microsoft SQL Serverr Reporting Services Version 16.00.200.8");

            Assert.AreEqual(expected, actual);
        }
        public SSRSVersion GetSqlServerVersion()
        {
            this.mReportingService.ServerInfoHeaderValue = new ServerInfoHeader();

            // Make call to ReportingService2010 endpoint otherwise ServerInfoHeaderValue will be NULL.
            this.mReportingService.ListChildren("/", false);

            return(SSRSUtil.GetSqlServerVersion(this.mReportingService.ServerInfoHeaderValue.ReportServerVersion));
        }
示例#9
0
        public void GetFullDestinationPathForItem_DoesntStartWithSlashAndDoesntContainSlash()
        {
            string expected = "Test Report";
            string actual   = SSRSUtil.GetFullDestinationPathForItem(
                "/Folder",
                "/Folder2",
                "Test Report");

            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public void GetServerPathToPhysicalPath_Folder_NullExtension()
        {
            string ssrsPath = "/SSRSMigrate/Reports/Sub Folder";

            string expected = "\\SSRSMigrate\\Reports\\Sub Folder";

            string actual = SSRSUtil.GetServerPathToPhysicalPath(ssrsPath, null);

            Assert.AreEqual(expected, actual);
        }
示例#11
0
        public void GetParentPath_NullItem()
        {
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(
                delegate
            {
                SSRSUtil.GetParentPath(null);
            });

            Assert.That(ex.Message, Is.EqualTo("Value cannot be null.\r\nParameter name: item"));
        }
示例#12
0
        public void GetServerPathToPhysicalPath_Folder_PathEndsWithSlash()
        {
            string ssrsPath = "/SSRSMigrate/Reports/Sub Folder/";

            string expected = "\\SSRSMigrate\\Reports\\Sub Folder";

            string actual = SSRSUtil.GetServerPathToPhysicalPath(ssrsPath);

            Assert.AreEqual(expected, actual);
        }
示例#13
0
        public void GetFullDestinationPathForItem_InstanceAndFolderChange()
        {
            string expected = "http://localhost/ReportServer_NEWSERVER/SSRSMigrate_NewFolder/Reports/Test Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "http://localhost/ReportServer/SSRSMigrate_AW_Tests",
                "http://localhost/ReportServer_NEWSERVER/SSRSMigrate_NewFolder",
                "http://localhost/ReportServer/SSRSMigrate_AW_Tests/Reports/Test Report");

            Assert.AreEqual(expected, actual);
        }
示例#14
0
        public void GetServerPathToPhysicalPath_Report_PathEndsWithSlash()
        {
            string ssrsPath  = "/SSRSMigrate/Reports/Inquiry/";
            string extension = "rdl";

            string expected = "\\SSRSMigrate\\Reports\\Inquiry.rdl";

            string actual = SSRSUtil.GetServerPathToPhysicalPath(ssrsPath, extension);

            Assert.AreEqual(expected, actual);
        }
示例#15
0
        public void GetFullDestinationPathForItem_RootFolderToRootFolder()
        {
            string expected = "/Test_Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "/",
                "/",
                "/Test_Report");

            Assert.AreEqual(expected, actual);
        }
示例#16
0
        public void GetFullDestinationPathForItem_RootFoldertoNonRootFolder_WithSubItem()
        {
            string expected = "/TEST/Test_Folder/Test_Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "/",
                "/TEST",
                "/Test_Folder/Test_Report");

            Assert.AreEqual(expected, actual);
        }
        public void ExportFolderItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(folderItems[0].Path);

            ExportStatus actualStatus = exporter.SaveItem(folderItems[0], filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.Null(actualStatus.Errors);
            Assert.True(Directory.Exists(actualStatus.ToPath));
        }
示例#18
0
        public void GetFullDestinationPathForItem_DestinationPathEndsWithSlash()
        {
            string expected = "http://localhost/ReportServer/SSRSMigrate_NewFolder/Reports/Test Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "http://localhost/ReportServer/SSRSMigrate_AW_Tests",
                "http://localhost/ReportServer/SSRSMigrate_NewFolder/",
                "http://localhost/ReportServer/SSRSMigrate_AW_Tests/Reports/Test Report");

            Assert.AreEqual(expected, actual);
        }
示例#19
0
        public void GetFullDestinationPathForItem_FolderChange_CaseInsensitive()
        {
            string expected = "http://localhost/ReportServer/SSRSMigrate_NewFolder/Reports/Test Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "http://localhost/ReportServer/ssrsmigrate_aw_tests",
                "http://localhost/ReportServer/SSRSMigrate_NewFolder",
                "http://localhost/ReportServer/SSRSMigrate_AW_Tests/Reports/Test Report");

            Assert.AreEqual(expected, actual);
        }
示例#20
0
        public void GetFullDestinationPathForItem_SoucePathIsInItemName()
        {
            string expected = "/SSRSMigrate_AW_Destination/Data Sources/SSRSMigrate_AW_Tests";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "/SSRSMigrate_AW_Tests",                                  // The source root folder
                "/SSRSMigrate_AW_Destination",                            // The destination root folder
                "/SSRSMigrate_AW_Tests/Data Sources/SSRSMigrate_AW_Tests" // Complete path to source item
                );

            Assert.AreEqual(expected, actual);
        }
示例#21
0
        public void GetFullDestinationPathForItem_SourceItemPathToDestinationItemPath()
        {
            string expected = "/SSRSMigrate_AW_Destination/Reports/Test Report";

            string actual = SSRSUtil.GetFullDestinationPathForItem(
                "/SSRSMigrate_AW_Tests",                    // The source root folder
                "/SSRSMigrate_AW_Destination",              // The destination root folder
                "/SSRSMigrate_AW_Tests/Reports/Test Report" // Complete path to source item
                );

            Assert.AreEqual(expected, actual);
        }
示例#22
0
        public void ExportReportItem_NullItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(reportItem_CompanySales.Path, "rdl");

            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(
                delegate
            {
                exporter.SaveItem(null, filePath);
            });

            Assert.That(ex.Message, Is.EqualTo("Value cannot be null.\r\nParameter name: item"));
        }
示例#23
0
        public void GetServerPathToPhysicalPath_EmptyPath()
        {
            string extension = "rdl";

            ArgumentException ex = Assert.Throws <ArgumentException>(
                delegate
            {
                string actual = SSRSUtil.GetServerPathToPhysicalPath("", extension);
            });

            Assert.That(ex.Message, Is.EqualTo("serverPath"));
        }
示例#24
0
        public void ExportDataSourceItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(dataSourceItem.Path, "json");

            ExportStatus actualStatus = exporter.SaveItem(dataSourceItem, filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.Null(actualStatus.Errors);
            Assert.True(File.Exists(filePath));
            Assert.AreEqual(expectedDataSourceJson, File.ReadAllText(filePath));
        }
示例#25
0
        public void ExportReportItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(reportItem_CompanySales.Path, "rdl");

            ExportStatus actualStatus = exporter.SaveItem(reportItem_CompanySales, filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.True(File.Exists(actualStatus.ToPath));
            Assert.Null(actualStatus.Errors);
            Assert.True(TesterUtility.CompareTextFiles(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[0]), actualStatus.ToPath));
        }
示例#26
0
        public void GetFullDestinationPathForItem_EmptyItemPath()
        {
            ArgumentException ex = Assert.Throws <ArgumentException>(
                delegate
            {
                SSRSUtil.GetFullDestinationPathForItem(
                    "http://localhost/ReportServer/SSRSMigrate_AW_Tests",
                    "http://localhost/ReportServer/SSRSMigrate_NewFolder",
                    "");
            });

            Assert.That(ex.Message, Is.EqualTo("itemPath"));
        }
示例#27
0
        public void GetParentPath_PathMissingFirstSlash()
        {
            ReportServerItem item = new ReportServerItem()
            {
                Name = "Sub Folder",
                Path = "SSRSMigrate/Reports/Sub Folder"
            };

            string expected = "/SSRSMigrate/Reports";

            string actual = SSRSUtil.GetParentPath(item);

            Assert.AreEqual(expected, actual);
        }
示例#28
0
        public void GetParentPath_PathIsSlash()
        {
            ReportServerItem item = new ReportServerItem()
            {
                Name = "Sub Folder",
                Path = "/"
            };

            string expected = "/";

            string actual = SSRSUtil.GetParentPath(item);

            Assert.AreEqual(expected, actual);
        }
示例#29
0
        public void GetParentPath_ParentContainsName()
        {
            ReportServerItem item = new ReportServerItem()
            {
                Name = "Reports",
                Path = "/SSRSMigrate/Reports/Reports"
            };

            string expected = "/SSRSMigrate/Reports";

            string actual = SSRSUtil.GetParentPath(item);

            Assert.AreEqual(expected, actual);
        }
示例#30
0
        public void UpdateReportDefinition_NullDefinition()
        {
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(
                delegate
            {
                SSRSUtil.UpdateReportDefinition(
                    "http://localhost/ReportServer_NEWSERVER",
                    "/SSRSMigrate_AW_Tests",
                    "/SSRSMigrate_AW_Tests",
                    null);
            });

            Assert.That(ex.Message, Is.EqualTo("Value cannot be null.\r\nParameter name: reportDefinition"));
        }