public void Read_Format20Levels_CorrectlyLoaded() { //Build the fullpath for the file to read var filename = DiskOnFile.CreatePhysicalFile("MetadataFormat20.xls", "NBi.Testing.Unit.Core.Analysis.Metadata.Resources.MetadataExcelSample.xls"); //set the object to test var mer = new MetadataExcelOleDbReader(filename); mer.SheetName = "Format20"; var metadata = mer.Read(); Perspective perspective = metadata.Perspectives["Perspective"]; //Assertions Assert.AreEqual(1, perspective.Dimensions["[Dimension 1]"].Hierarchies["[Hierarchy 1.1]"].Levels.Count); Assert.AreEqual(1, perspective.Dimensions["[Dimension 2]"].Hierarchies["[Hierarchy 2.1]"].Levels.Count); Assert.AreEqual(1, perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.1]"].Levels.Count); Assert.AreEqual(2, perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels.Count); Assert.That(perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels.ContainsKey("[Level 3.2.1]")); Assert.That(perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels.ContainsKey("[Level 3.2.2]")); Assert.AreEqual("[Level 3.2.2]", perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels["[Level 3.2.2]"].UniqueName); Assert.AreEqual("Level 3.2.2", perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels["[Level 3.2.2]"].Caption); Assert.AreEqual(0, perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels["[Level 3.2.1]"].Number); Assert.AreEqual(1, perspective.Dimensions["[Dimension 3]"].Hierarchies["[Hierarchy 3.2]"].Levels["[Level 3.2.2]"].Number); }
public void Write_TwoDimensionsSameMeasureGroup_FileIsCorrectlyBuilt() { var header = GetHeader(); var expectedContent = header + "\"p\";\"mg\";\"m1\";\"[m1]\";\"d1\";\"[d1]\";\"h1\";\"[h1]\";\"l1\";\"[l1]\";\"0\";\"p1\";\"[p1]\"\r\n" + "\"p\";\"mg\";\"m1\";\"[m1]\";\"d2\";\"[d2]\";\"h2\";\"[h2]\";\"l2\";\"[l2]\";\"1\";\"p2\";\"[p2]\"\r\n" ; var expectedFilename = Path.Combine(DiskOnFile.GetDirectoryPath(), "ExpectedCSV-" + MethodBase.GetCurrentMethod() + ".csv"); if (File.Exists(expectedFilename)) { File.Delete(expectedFilename); } File.AppendAllText(expectedFilename, expectedContent, Encoding.UTF8); var filename = Path.Combine(DiskOnFile.GetDirectoryPath(), @"ActualCSV-" + MethodBase.GetCurrentMethod() + ".csv"); var metadata = new CubeMetadata(); var p = new Perspective("p"); metadata.Perspectives.Add(p); var mg = new MeasureGroup("mg"); p.MeasureGroups.Add(mg); var m1 = new Measure("[m1]", "m1", "df"); mg.Measures.Add(m1); var d1 = new Dimension("[d1]", "d1"); mg.LinkedDimensions.Add(d1); var h1 = new Hierarchy("[h1]", "h1", "df"); d1.Hierarchies.Add(h1); var l1 = new Level("[l1]", "l1", 0); h1.Levels.Add(l1); var p1 = new Property("[p1]", "p1"); l1.Properties.Add(p1); var d2 = new Dimension("[d2]", "d2"); mg.LinkedDimensions.Add(d2); var h2 = new Hierarchy("[h2]", "h2", "df"); d2.Hierarchies.Add(h2); var l2 = new Level("[l2]", "l2", 1); h2.Levels.Add(l2); var p2 = new Property("[p2]", "p2"); l2.Properties.Add(p2); //set the object to test var mcw = new MetadataCsvWriter(filename); mcw.Write(metadata); //Assertion FileAssert.AreEqual(expectedFilename, filename); }
public void Execute_ExistingSamplePackageWithParameter_SuccessAndParameterUsed() { var destPath = DiskOnFile.GetDirectoryPath() + "SampleFile.txt"; if (File.Exists(destPath)) { File.Delete(destPath); } var etl = new EtlXml(); etl.Path = @"Etl\"; etl.Name = "Sample.dtsx"; etl.Password = "******"; var param = new EtlParameterXml(); param.Name = "DestinationPath"; param.StringValue = destPath; etl.InternalParameters.Add(param); var runner = new EtlFileRunner(etl); var result = runner.Run(); Assert.That(result.IsSuccess, Is.True); Assert.That(File.Exists(destPath), Is.True); }
public void GetConnectionString_InvalidFile_FileNotFoundException() { var fullPath = DiskOnFile.CreatePhysicalFile(ODC_FILE, "NBi.Testing.Integration.Core.Resources." + ODC_FILE); var parser = new OfficeDataConnectionFileParser(Path.GetDirectoryName(fullPath) + Path.DirectorySeparatorChar); Assert.Throws <FileNotFoundException>(delegate { parser.GetConnectionString("NonExisting.odc"); }); }
public void Read_TwoDimensionsSameMeasureGroup_DimensionsAreCorrectlyRead() { var header = GetHeader(); var testContent = header + "\"p\";\"mg\";\"m1\";\"[m1]\";\"df\";\"d1\";\"[d1]\";\"h1\";\"[h1]\";\"l1\";\"[l1]\";\"0\";\"p1\";\"[p1]\"\r\n" + "\"p\";\"mg\";\"m1\";\"[m1]\";\"df\";\"d2\";\"[d2]\";\"h2\";\"[h2]\";\"l2\";\"[l2]\";\"1\";\"p2\";\"[p2]\"\r\n" ; var testFilename = Path.Combine(DiskOnFile.GetDirectoryPath(), string.Format("ReadCSV-{0}.csv", MethodInfo.GetCurrentMethod())); if (File.Exists(testFilename)) { File.Delete(testFilename); } File.AppendAllText(testFilename, testContent, Encoding.UTF8); //set the object to test var mcr = new MetadataCsvReader(testFilename); var metadata = mcr.Read(); //Assertion Assert.That(metadata.Perspectives["p"].MeasureGroups["mg"].LinkedDimensions.Count, Is.EqualTo(2)); Assert.That(metadata.Perspectives["p"].MeasureGroups["mg"].LinkedDimensions["[d1]"].Caption, Is.EqualTo("d1")); Assert.That(metadata.Perspectives["p"].MeasureGroups["mg"].LinkedDimensions["[d2]"].Caption, Is.EqualTo("d2")); Assert.That(metadata.Perspectives["p"].MeasureGroups["mg"].LinkedDimensions["[d1]"].UniqueName, Is.EqualTo("[d1]")); Assert.That(metadata.Perspectives["p"].MeasureGroups["mg"].LinkedDimensions["[d2]"].UniqueName, Is.EqualTo("[d2]")); }
public void Execute_ExistingSamplePackageWithParameterWithInvalidValue_FailureWithMessage() { var destPath = DiskOnFile.GetDirectoryPath() + @"\/.txt"; if (File.Exists(destPath)) { File.Delete(destPath); } var etl = new EtlXml(); etl.Path = @"Etl\"; etl.Name = "Sample.dtsx"; etl.Password = "******"; var param = new EtlParameterXml(); param.Name = "DestinationPath"; param.StringValue = destPath; etl.InternalParameters.Add(param); var runner = new EtlFileRunner(etl); var result = runner.Run(); Assert.That(result.IsSuccess, Is.False); Assert.That(result.Message, Is.StringContaining("invalid characters")); }
public void Setup() { if (File.Exists(BATCH_FILE)) { File.Delete(BATCH_FILE); } FullPath = DiskOnFile.CreatePhysicalFile(BATCH_FILE, "NBi.Testing.Integration.Core.Resources." + BATCH_FILE); if (File.Exists(INVALID_BATCH_FILE)) { File.Delete(INVALID_BATCH_FILE); } FullPathInvalid = DiskOnFile.CreatePhysicalFile(INVALID_BATCH_FILE, "NBi.Testing.Integration.Core.Resources." + INVALID_BATCH_FILE); if (!File.Exists(FullPath)) { throw new FileNotFoundException("OUps"); } else { Console.WriteLine("BATCH: " + Path.GetFullPath(BATCH_FILE)); } if (File.Exists(TARGET_FILE)) { File.Delete(TARGET_FILE); } }
public void TearDownMethods() { if (File.Exists(DiskOnFile.GetDirectoryPath() + @"\MyProject.nbi")) { File.Delete(DiskOnFile.GetDirectoryPath() + @"\MyProject.nbi"); } }
public void SetupMethods() { isIntegrationServiceStarted = CheckIfIntegrationServiceStarted(); if (!isIntegrationServiceStarted) { return; } //Build the fullpath for the file to read Directory.CreateDirectory("ETL"); var pkg = DiskOnFile.CreatePhysicalFile(@"Etl\Sample.dtsx", "NBi.Testing.Integration.Core.Etl.IntegrationService.Resources.Sample.dtsx"); try { //Move the Etl to SQL Server Integration Services Application app = new Application(); Package p = app.LoadPackage(pkg, null); // Save the package to the SQL Server msdb folder, which is // also the MSDB folder in the Integration Services service, or as a row in the //sysssispackages table. app.SaveToSqlServerAs(p, null, "nbi\\nbi-sample", ConnectionStringReader.GetIntegrationServerDatabase(), null, null); } catch (Exception ex) { isIntegrationServiceStarted = false; IgnoreMessage = string.Format("Test fixture 'EtlDtsWindowsRunnerTest' is skipped: {0}", ex.Message); } }
public void Execute_Batch_TablesAreCreated() { //Create table CleanTemporaryTable("TablexxxOne", ConnectionStringReader.GetLocalSqlClient()); CleanTemporaryTable("TablexxxTwo", ConnectionStringReader.GetLocalSqlClient()); //Build the fullpath for the file to read FileName = DiskOnFile.CreatePhysicalFile(BATCH_FILE, "NBi.Testing.Integration.Core.Batch." + BATCH_FILE); //Mock the commandXml var info = Mock.Of <IBatchRunCommand> ( c => c.FullPath == BATCH_FILE && c.ConnectionString == ConnectionStringReader.GetLocalSqlClient() && c.Version == "SqlServer2014" ); //Apply the test var runCommand = new BatchRunCommand(info, new SqlConnection(ConnectionStringReader.GetLocalSqlClient())); runCommand.Execute(); var countTable = 0; using (var conn = new SqlConnection(ConnectionStringReader.GetLocalSqlClient())) { var cmd = new SqlCommand(); cmd.Connection = conn; conn.Open(); cmd.CommandText = "select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'dbo' and TABLE_NAME like 'Tablexxx%'"; countTable = (int)cmd.ExecuteScalar(); } Assert.That(countTable, Is.EqualTo(2)); }
public void Setup() { includedFilename = DiskOnFile.CreatePhysicalFile("TestSuiteIncludedTestSuite.xml", "NBi.Testing.Unit.Xml.Resources.TestSuiteIncludedTestSuite.xml"); Console.WriteLine("Included file created at '{0}'", includedFilename); filename = DiskOnFile.CreatePhysicalFile("TestSuiteWithIncludeTestSuite.nbits", "NBi.Testing.Unit.Xml.Resources.TestSuiteWithIncludeTestSuite.xml"); Console.WriteLine("Main file created at '{0}'", filename); }
public void GetConnectionString_ValidAbsoluteFile_CorrectConnectionString() { var fullPath = DiskOnFile.CreatePhysicalFile(ODC_FILE, "NBi.Testing.Integration.Core.Resources." + ODC_FILE); var parser = new OfficeDataConnectionFileParser(Path.GetDirectoryName(fullPath)); var connectionString = parser.GetConnectionString(fullPath); Assert.That(connectionString, Is.EqualTo("Provider=MSOLAP.7;Integrated Security=ClaimsToken;Identity Provider=AAD;Data Source=https://analysis.windows.net/powerbi/api;;Initial Catalog=sobe_wowvirtualserver-ccdf3d76-59d9-4e10-83e8-82eb0d27d1e9;Location=https://wabi-north-europe-redirect.analysis.windows.net/xmla?vs=sobe_wowvirtualserver&db=ccdf3d76-59d9-4e10-83e8-82eb0d27d1e9;MDX Compatibility= 1; MDX Missing Member Mode= Error; Safety Options= 2; Update Isolation Level= 2")); }
public void SetupMethods() { isIntegrationServiceStarted = CheckIfIntegrationServiceStarted(); //Build the fullpath for the file to read Directory.CreateDirectory("ETL"); DiskOnFile.CreatePhysicalFile(@"Etl\Sample.dtsx", "NBi.Testing.Integration.SqlServer.IntegrationService.Resources.Sample.dtsx"); }
protected void CreateReportFile(string filename) { string file = @"\Temp\" + filename + ".rdl"; var resource = "NBi.Testing.Unit.Core.Report.Resources." + filename + ".rdl"; var physicalFilename = DiskOnFile.CreatePhysicalFile(file, resource); ReportFileDirectory = Path.GetDirectoryName(physicalFilename) + Path.DirectorySeparatorChar.ToString(); }
public void Load_InvalidMultipleFile_ThrowException() { var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntaxMultiple.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntaxMultiple.xml"); var manager = new XmlManager(); Assert.Throws <ArgumentException>(delegate { manager.Load(filename); }); }
public void Load_InvalidFormat_ThrowException() { var filename = DiskOnFile.CreatePhysicalFile("InvalidFormat.nbits", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidFormat.xml"); var manager = new XmlManager(); var ex = Assert.Throws <ArgumentException>(delegate { manager.Load(filename); }); Assert.That(ex.Message, Is.StringContaining("At line 14")); }
public void Load_FileWithEuro_EuroCorrectlyRead() { var filename = DiskOnFile.CreatePhysicalFile("Simple.genbil", "NBi.Testing.Integration.GenbiL.Resources.Simple.genbil"); var generator = new TestSuiteGenerator(); generator.Load(filename); Assert.That(generator.Text, Does.Contain("€")); }
private void CreateFlatFiles() { var filenames = new[] { "Calendar", "Geography", "Scientist" }; foreach (var filename in filenames) { DiskOnFile.CreatePhysicalFile($@"data\Dim{filename}.csv", $"{GetType().Namespace}.Resources.Dim{filename}.csv"); } }
public void SetupMethods() { //Build the fullpath for the file to read Directory.CreateDirectory("Etl"); DiskOnFile.CreatePhysicalFile(@"Etl\Sample.dtsx", "NBi.Testing.Integration.SqlServer.IntegrationService.Resources.Sample.dtsx"); //Set environment variable Environment.SetEnvironmentVariable("FirstJanuary2015", "2015-01-01", EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable("ConnStrAdvWorksCloud", ConnectionStringReader.GetSqlClient(), EnvironmentVariableTarget.User); }
public void Load_ValidFile_Success() { var filename = DiskOnFile.CreatePhysicalFile("TestSuite.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerSample.xml"); var manager = new XmlManager(); manager.Load(filename); Assert.That(manager.TestSuite, Is.Not.Null); }
public void Load_ValidFileImplicitLanguage_LanguageSetToCSharp() { var filename = DiskOnFile.CreatePhysicalFile("TestContentIsCorrect.xml", "NBi.Testing.Unit.Xml.Resources.TestSuiteWithVariablesTestSuite.xml"); var manager = new XmlManager(); manager.Load(filename); Assert.That(manager.TestSuite.Variables[1].Script.Language, Is.EqualTo(LanguageType.CSharp)); }
public void Load_InvalidFile_ExceptionHasCorrectInformation() { var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntax.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntax.xml"); var manager = new XmlManager(); var exception = Assert.Throws <ArgumentException>(delegate { manager.Load(filename); }); Assert.That(exception.Message, Is.StringContaining("1 error has been found during the validation of the test-suite")); Assert.That(exception.Message, Is.StringContaining("\tAt line 4: The element 'test' in namespace 'http://NBi/TestSuite' has invalid child element 'syntacticallyCorrect' in namespace 'http://NBi/TestSuite'.")); }
public void Execute_ExistingType_GetTypeForStaticUsage() { //Build the SUT var am = new AssemblyManager(); //Call the method to test var actual = am.GetStatic(DiskOnFile.GetDirectoryPath() + "NBi.Testing.dll", "NBi.Testing.Unit.Core.Assemblies.Resource.StaticKlass"); //Assertion Assert.That(actual.FullName, Is.EqualTo("NBi.Testing.Unit.Core.Assemblies.Resource.StaticKlass")); }
public void Load_ValidFile_Success() { var filename = DiskOnFile.CreatePhysicalFile("TestSuite.xml", "NBi.Testing.Unit.Xml.Resources.TestSuiteWithVariablesTestSuite.xml"); var manager = new XmlManager(); manager.Load(filename); Assert.That(manager.TestSuite, Is.Not.Null); Assert.That(manager.TestSuite.Tests, Has.Count.EqualTo(1)); }
public void TearDownTest() { if (Directory.Exists(DiskOnFile.GetDirectoryPath() + @"\Queries")) { Directory.Delete(DiskOnFile.GetDirectoryPath() + @"\Queries", true); } if (Directory.Exists(DiskOnFile.GetDirectoryPath() + @"\Expect")) { Directory.Delete(DiskOnFile.GetDirectoryPath() + @"\Expect", true); } }
public void Load_ValidFile_TestContentIsCorrect() { var filename = DiskOnFile.CreatePhysicalFile("TestContentIsCorrect.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerSample.xml"); var manager = new XmlManager(); manager.Load(filename); Assert.That(manager.TestSuite.Tests[0].Content, Is.Not.Null); Assert.That(manager.TestSuite.Tests[0].Content, Is.StringEnding("</test>")); }
public void Load_InvalidMultipleFile_ExceptionHasCorrectInformation() { var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntaxMultiple.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntaxMultiple.xml"); var manager = new XmlManager(); var exception = Assert.Throws <ArgumentException>(delegate { manager.Load(filename); }); Assert.That(exception.Message, Is.StringContaining("2 errors have been found during the validation of the test-suite")); Assert.That(exception.Message, Is.StringContaining("At line 6: The element 'execution' in namespace 'http://NBi/TestSuite' has invalid child element 'sql' in namespace 'http://NBi/TestSuite'.")); Assert.That(exception.Message, Is.StringContaining("At line 11: The 'name' attribute is not declared.")); }
public void SetupTest() { var qualified = VariablesFilename.Replace("\\", "."); DiskOnFile.CreatePhysicalFile(VariablesFilename, $"NBi.Testing.{qualified}"); if (File.Exists(TargetFilename)) { File.Delete(TargetFilename); } }
public void GetInstance_ExistingTypeConstructoreWithZeroParam_InstantiatedAndNotNull() { //Build the SUT var am = new AssemblyManager(); //Call the method to test var actual = am.GetInstance(DiskOnFile.GetDirectoryPath() + "NBi.Testing.dll", "NBi.Testing.Unit.Core.Assemblies.Resource.Klass", null); //Assertion Assert.IsInstanceOf <NBi.Testing.Unit.Core.Assemblies.Resource.Klass>(actual); Assert.That(actual, Is.Not.Null); }
public void Load_ValidFile_VariablesLoaded() { var filename = DiskOnFile.CreatePhysicalFile("TestContentIsCorrect.xml", "NBi.Testing.Unit.Xml.Resources.TestSuiteWithVariablesTestSuite.xml"); var manager = new XmlManager(); manager.Load(filename); Assert.That(manager.TestSuite.Variables, Has.Count.EqualTo(2)); Assert.That(manager.TestSuite.Variables[0].Name, Is.EqualTo("year")); Assert.That(manager.TestSuite.Variables[0].Script.Language, Is.EqualTo(LanguageType.CSharp)); Assert.That(manager.TestSuite.Variables[0].Script.Code, Is.EqualTo("DateTime.Now.Year")); }