public void WriteReports_OneOrMoreReportItemNullName() { ReportItem report = new ReportItem() { Name = null, Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; List <ReportItem> items = new List <ReportItem>() { report }; items.AddRange(reportItems); ArgumentException ex = Assert.Throws <ArgumentException>( delegate { writer.WriteReports(items.ToArray()); }); Assert.That(ex.Message, Is.EqualTo("item.Name")); }
public void WriteReports_OneOrMoreReportItemEmptyPath() { ReportItem report = new ReportItem() { Name = "Company Sales", Path = "", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; List <ReportItem> items = new List <ReportItem>() { report }; items.AddRange(reportItems); InvalidPathException ex = Assert.Throws <InvalidPathException>( delegate { writer.WriteReports(items.ToArray()); }); Assert.That(ex.Message, Is.EqualTo(string.Format("Invalid path '{0}'.", report.Path))); }
public void TestFixtureSetUp() { EnvironmentSetup(); var settings = new NinjectSettings() { LoadExtensions = false }; kernel = new StandardKernel( settings, new Log4NetModule(), new DependencyModule()); exporter = kernel.Get <ReportItemExporter>(); reportItem_CompanySales = new ReportItem() { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = "Adventure Works sales by quarter and product category. This report illustrates the use of a tablix data region with nested row groups and column groups. You can drilldown from summary data into detail data by showing and hiding rows. This report also illustrates the use of a logo image and a background image.", ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[0]))) }; reportItem_StoreContacts = new ReportItem() { Name = "Store Contacts", Path = "/SSRSMigrate_AW_Tests/Reports/Store Contacts", Description = "AdventureWorks store contacts. This report is a subreport used in Sales Order Detail to show all contacts for a store. Borderstyle is None so lines do not display in main report.", ID = "18fc782e-dd5f-4c65-95ff-957e1bdc98de", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[2]))), }; reportItem_SalesOrderDetail = new ReportItem() { Name = "Sales Order Detail", Path = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail", Description = "Detail of an individual Adventure Works order. This report can be accessed as a drillthrough report from the Employee Sales Summary and Territory Sales drilldown report. This report illustrates the use of a free form layout, a table, parameters, a subreport that shows multiple store contacts, and expressions.", ID = "70650568-7dd4-4ef4-aeaa-67502de11b4f", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[1]))), SubReports = new List <ReportItem>() { reportItem_StoreContacts } }; // Setup GetReports - Expected ReportItems reportItems = new List <ReportItem>() { reportItem_CompanySales, reportItem_SalesOrderDetail, reportItem_StoreContacts }; outputPath = GetOutPutPath(); }
private void SetupExpectedResults() { // Setup expected ReportItems expectedReportItem_CompanySales = new ReportItem() { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = "Adventure Works sales by quarter and product category. This report illustrates the use of a tablix data region with nested row groups and column groups. You can drilldown from summary data into detail data by showing and hiding rows. This report also illustrates the use of a logo image and a background image.", ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Company Sales.rdl"))) }; expectedReportItem_StoreContacts = new ReportItem() { Name = "Store Contacts", Path = "/SSRSMigrate_AW_Tests/Reports/Store Contacts", Description = "AdventureWorks store contacts. This report is a subreport used in Sales Order Detail to show all contacts for a store. Borderstyle is None so lines do not display in main report.", ID = "18fc782e-dd5f-4c65-95ff-957e1bdc98de", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Store Contacts.rdl"))), }; expectedReportItem_SalesOrderDetail = new ReportItem() { Name = "Sales Order Detail", Path = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail", Description = "Detail of an individual Adventure Works order. This report can be accessed as a drillthrough report from the Employee Sales Summary and Territory Sales drilldown report. This report illustrates the use of a free form layout, a table, parameters, a subreport that shows multiple store contacts, and expressions.", ID = "70650568-7dd4-4ef4-aeaa-67502de11b4f", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Sales Order Detail.rdl"))), SubReports = new List <ReportItem>() { expectedReportItem_StoreContacts } }; // Setup GetReports - Expected ReportItems expectedReportItems = new List <ReportItem>() { expectedReportItem_CompanySales, expectedReportItem_SalesOrderDetail, expectedReportItem_StoreContacts }; }
public void WriteReport_ReportItemEmptyName() { ReportItem report = new ReportItem() { Name = "", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Company Sales.rdl"))) }; ArgumentException ex = Assert.Throws <ArgumentException>( delegate { writer.WriteReport(report); }); Assert.That(ex.Message, Is.EqualTo("item.Name")); }
public void TestFixtureSetUp() { reportItem = new ReportItem() { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = null, ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportPath))) }; exportWriterMock = new Mock <IExportWriter>(); var logger = new MockLogger(); exportWriterMock.Setup(e => e.Save(It.IsAny <string>(), It.IsAny <byte[]>(), true)); // Mock IExporter.Save where the filename exists but overwrite = false exportWriterMock.Setup(e => e.Save(expectedReportItemFileName, It.IsAny <byte[]>(), false)) .Throws(new IOException(string.Format("File '{0}' already exists.", expectedReportItemFileName))); exporter = new ReportItemExporter(exportWriterMock.Object, logger); }
private void SetupReportItems() { reportItem_CompanySales = new ReportItem() { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; reportItem_StoreContacts = new ReportItem() { Name = "Store Contacts", Path = "/SSRSMigrate_AW_Tests/Reports/Store Contacts", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "18fc782e-dd5f-4c65-95ff-957e1bdc98de", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Store Contacts.rdl"))), }; reportItem_SalesOrderDetail = new ReportItem() { Name = "Sales Order Detail", Path = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "70650568-7dd4-4ef4-aeaa-67502de11b4f", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Sales Order Detail.rdl"))), SubReports = new List <ReportItem>() { reportItem_StoreContacts } }; reportItem_AlreadyExists = new ReportItem() { Name = "Already Exists", Path = "/SSRSMigrate_AW_Tests/Reports/Already Exists", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; reportItem_InvalidPath = new ReportItem() { Name = "Invalid.Path", Path = "/SSRSMigrate_AW_Tests/Reports/Invalid.Path", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; reportItem_NullDefinition = new ReportItem() { Name = "Null Definition", Path = "/SSRSMigrate_AW_Tests/Reports/Null Definition", Description = null, ID = "5921480a-1b24-4a6e-abbc-f8db116cd24e", VirtualPath = null, Definition = null }; reportItem_Error = new ReportItem() { Name = "ERROR", Path = "/SSRSMigrate_AW_Tests/Reports/ERROR", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; reportItems = new List <ReportItem>() { reportItem_CompanySales, reportItem_SalesOrderDetail, reportItem_StoreContacts }; }
private void SetupExpectedValues() { // ReportItem expectedReportItem_CompanySales = new ReportItem() { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", Description = "Adventure Works sales by quarter and product category. This report illustrates the use of a tablix data region with nested row groups and column groups. You can drilldown from summary data into detail data by showing and hiding rows. This report also illustrates the use of a logo image and a background image.", ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[0]))) }; expectedReportItem_StoreContacts = new ReportItem() { Name = "Store Contacts", Path = "/SSRSMigrate_AW_Tests/Reports/Store Contacts", Description = "AdventureWorks store contacts. This report is a subreport used in Sales Order Detail to show all contacts for a store. Borderstyle is None so lines do not display in main report.", ID = "18fc782e-dd5f-4c65-95ff-957e1bdc98de", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[2]))), }; expectedReportItem_SalesOrderDetail = new ReportItem() { Name = "Sales Order Detail", Path = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail", Description = "Detail of an individual Adventure Works order. This report can be accessed as a drillthrough report from the Employee Sales Summary and Territory Sales drilldown report. This report illustrates the use of a free form layout, a table, parameters, a subreport that shows multiple store contacts, and expressions.", ID = "70650568-7dd4-4ef4-aeaa-67502de11b4f", VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[1]))), SubReports = new List <ReportItem>() { expectedReportItem_StoreContacts } }; expectedReportItems = new List <ReportItem>() { expectedReportItem_CompanySales, expectedReportItem_SalesOrderDetail, expectedReportItem_StoreContacts }; // DataSourceItem expectedDataSourceItems = new List <DataSourceItem>() { new DataSourceItem() { Description = null, VirtualPath = null, Name = "AWDataSource", Path = "/SSRSMigrate_AW_Tests/Data Sources/AWDataSource", ConnectString = "Data Source=(local)\\SQL2008;Initial Catalog=AdventureWorks2008", CredentialsRetrieval = "Integrated", Enabled = true, EnabledSpecified = true, Extension = "SQL", ImpersonateUser = false, ImpersonateUserSpecified = true, OriginalConnectStringExpressionBased = false, Password = null, Prompt = "Enter a user name and password to access the data source:", UseOriginalConnectString = false, UserName = null, WindowsCredentials = false }, new DataSourceItem() { Description = null, VirtualPath = null, Name = "Test Data Source", Path = "/SSRSMigrate_AW_Tests/Data Sources/Test Data Source", ConnectString = "Data Source=(local)\\SQL2008;Initial Catalog=AdventureWorks2008", CredentialsRetrieval = "Integrated", Enabled = true, EnabledSpecified = true, Extension = "SQL", ImpersonateUser = false, ImpersonateUserSpecified = true, OriginalConnectStringExpressionBased = false, Password = null, Prompt = "Enter a user name and password to access the data source:", UseOriginalConnectString = false, UserName = null, WindowsCredentials = false }, }; expectedDataSource1Json = JsonConvert.SerializeObject(expectedDataSourceItems[0], Formatting.Indented); expectedDataSource2Json = JsonConvert.SerializeObject(expectedDataSourceItems[1], Formatting.Indented); // FolderItem expectedFolderItems = new List <FolderItem>() { new FolderItem() { Name = "Reports", Path = "/SSRSMigrate_AW_Tests/Reports", }, new FolderItem() { Name = "Sub Folder", Path = "/SSRSMigrate_AW_Tests/Reports/Sub Folder", }, new FolderItem() { Name = "Data Sources", Path = "/SSRSMigrate_AW_Tests/Data Sources", } }; }
public void TestFixtureSetUp() { // Setup IReportServerRepository mock var reportServerRepositoryMock = new Mock <IReportServerRepository>(); // Setup GetReport - Expected ReportItem expectedReportItem = new ReportItemProxy(reportServerRepositoryMock.Object) { Name = "Company Sales", Path = "/SSRSMigrate_AW_Tests/Reports/Company Sales", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "16d599e6-9c87-4ebc-b45b-5a47e3c73746", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2010\\Company Sales.rdl"))) }; // Setup GetReports - Expected ReportItems expectedReportItems = new List <ReportItem>() { expectedReportItem, new ReportItemProxy(reportServerRepositoryMock.Object) { Name = "Sales Order Detail", Path = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "70650568-7dd4-4ef4-aeaa-67502de11b4f", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Sales Order Detail.rdl"))), SubReports = new List <ReportItem>() { new ReportItem() { Name = "Store Contacts", Path = "/SSRSMigrate_AW_Tests/Reports/Store Contacts", CreatedBy = "DOMAIN\\user", CreationDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Description = null, ID = "18fc782e-dd5f-4c65-95ff-957e1bdc98de", ModifiedBy = "DOMAIN\\user", ModifiedDate = DateTime.Parse("7/28/2014 12:06:43 PM"), Size = 10, VirtualPath = null, Definition = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Test AW Reports\\2005\\Store Contacts.rdl"))), } } } }; // Setup IReportServerRepository.GetReportDefinition Mocks reportServerRepositoryMock.Setup(r => r.GetReportDefinition(null)) .Throws(new ArgumentException("reportPath")); reportServerRepositoryMock.Setup(r => r.GetReportDefinition("")) .Throws(new ArgumentException("reportPath")); reportServerRepositoryMock.Setup(r => r.GetReportDefinition("/SSRSMigrate_AW_Tests/Reports/Company Sales")) .Returns(() => expectedReportItem.Definition); reportServerRepositoryMock.Setup(r => r.GetReportDefinition("/SSRSMigrate_AW_Tests/Reports/Sales Order Detail")) .Returns(() => expectedReportItems[1].Definition); reportServerRepositoryMock.Setup(r => r.GetReportDefinition("/SSRSMigrate_AW_Tests/Reports/Store Contacts")) .Returns(() => expectedReportItems[1].SubReports[0].Definition); // Setup IReportServerRepository.GetReport Mocks reportServerRepositoryMock.Setup(r => r.GetReport(null)) .Throws(new ArgumentException("reportPath")); reportServerRepositoryMock.Setup(r => r.GetReport("")) .Throws(new ArgumentException("reportPath")); reportServerRepositoryMock.Setup(r => r.GetReport("/SSRSMigrate_AW_Tests/Reports/Company Sales")) .Returns(() => expectedReportItem); reportServerRepositoryMock.Setup(r => r.GetReport("/SSRSMigrate_AW_Tests/Reports/Sales Order Detail")) .Returns(() => expectedReportItems[1]); reportServerRepositoryMock.Setup(r => r.GetReport("/SSRSMigrate_AW_Tests/Reports/Report Doesnt Exist")) .Returns(() => null); // Setup IReportServerRepository.GetReports Mocks reportServerRepositoryMock.Setup(r => r.GetReports(null)) .Throws(new ArgumentException("path")); reportServerRepositoryMock.Setup(r => r.GetReports("")) .Throws(new ArgumentException("path")); reportServerRepositoryMock.Setup(r => r.GetReports("/SSRSMigrate_AW_Tests")) .Returns(() => expectedReportItems); reportServerRepositoryMock.Setup(r => r.GetReports("/SSRSMigrate_AW_Tests Doesnt Exist")) .Returns(() => new List <ReportItem>()); // Setup IReportServerRepository.GetReportsLazy Mocks reportServerRepositoryMock.Setup(r => r.GetReportsLazy(null)) .Throws(new ArgumentException("path")); reportServerRepositoryMock.Setup(r => r.GetReportsLazy("")) .Throws(new ArgumentException("path")); reportServerRepositoryMock.Setup(r => r.GetReportsLazy("/SSRSMigrate_AW_Tests")) .Returns(() => expectedReportItems); reportServerRepositoryMock.Setup(r => r.GetReportsLazy("/SSRSMigrate_AW_Tests Doesnt Exist")) .Returns(() => new List <ReportItemProxy>()); // Setup IReportServerRepository.ValidatePath Mocks reportServerRepositoryMock.Setup(r => r.ValidatePath("/SSRSMigrate_AW_Tests")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidatePath("/SSRSMigrate_AW_Tests Doesnt Exist")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidatePath(null)) .Returns(() => false); reportServerRepositoryMock.Setup(r => r.ValidatePath("")) .Returns(() => false); reportServerRepositoryMock.Setup(r => r.ValidatePath(It.Is <string>(s => Regex.IsMatch(s ?? "", "[:?;@&=+$,\\*><|.\"]+") == true))) .Returns(() => false); // Setup IReportServerRepository.ValidateItemPath Mocks reportServerRepositoryMock.Setup(r => r.ValidateItemPath("/SSRSMigrate_AW_Tests")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidateItemPath("/SSRSMigrate_AW_Tests Doesnt Exist")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidateItemPath("/SSRSMigrate_AW_Tests/Reports/Report Doesnt Exist")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidateItemPath(expectedReportItem.Path)) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidateItemPath("/SSRSMigrate_AW_Tests/Reports/Sales Order Detail")) .Returns(() => true); reportServerRepositoryMock.Setup(r => r.ValidateItemPath("/SSRSMigrate_AW_Tests/Reports/Store Contacts")) .Returns(() => true); MockLogger logger = new MockLogger(); reader = new ReportServerReader(reportServerRepositoryMock.Object, logger); }