How to use DiskOnFile class of NBi.Testing package

Best NBi code snippet using NBi.Testing.DiskOnFile

ProjectTest.cs

Source:ProjectTest.cs Github

copy

Full Screen

...15 //Called only at instance creation16 [TestFixtureSetUp]17 public void SetupMethods()18 {19 ProjectFilename = DiskOnFile.CreatePhysicalFile("MyProject.nbi", "NBi.Testing.Unit.UI.Configuration.Resources.MyProject.nbi");20 }2122 //Called only at instance destruction23 [TestFixtureTearDown]24 public void TearDownMethods()25 {26 if (File.Exists(DiskOnFile.GetDirectoryPath() + @"\MyProject.nbi"))27 File.Delete(DiskOnFile.GetDirectoryPath() + @"\MyProject.nbi");28 }2930 //Called before each test31 [SetUp]32 public void SetupTest()33 {34 }3536 //Called after each test37 [TearDown]38 public void TearDownTest()39 {4041 }42 #endregion4344 [Test]45 public void Load_CorrectFile_DirectoriesLoaded()46 {47 //Call the method to test48 Project.Load(ProjectFilename);4950 //Assertion51 Assert.That(Project.Directories.Root, Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\"));52 }5354 [Test]55 public void Load_CorrectFile_DirectoryLoaded()56 {57 //Call the method to test58 Project.Load(ProjectFilename);5960 //Assertion61 Assert.That(Project.Directories[DirectoryCollection.DirectoryType.Metadata].FullFileName,62 Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\Metadata\metadata.xls"));63 Assert.That(Project.Directories[DirectoryCollection.DirectoryType.Query].FullFileName,64 Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\Query\"));65 Assert.That(Project.Directories[DirectoryCollection.DirectoryType.Expect].FullFileName,66 Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\Expect\"));67 Assert.That(Project.Directories[DirectoryCollection.DirectoryType.Actual].FullFileName,68 Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\Actual\"));69 Assert.That(Project.Directories[DirectoryCollection.DirectoryType.TestSuite].FullFileName,70 Is.EqualTo(@"C:\Users\Seddryck\Documents\TestCCH\TestSuite\"));71 }7273 [Test]74 public void Load_CorrectFile_ConnectionStringLoaded()75 {76 //Call the method to test77 Project.Load(ProjectFilename);7879 //Assertion80 Assert.That(Project.ConnectionStrings[81 ConnectionStringCollection.ConnectionClass.Adomd,82 ConnectionStringCollection.ConnectionType.Expect83 ].Value,84 Is.EqualTo("Data Source=localhost;Catalog=\"Finances Analysis\";"));8586 Assert.That(Project.ConnectionStrings[87 ConnectionStringCollection.ConnectionClass.Oledb,88 ConnectionStringCollection.ConnectionType.Expect89 ].Value,90 Is.EqualTo("Provider=MSOLAP.4;Data Source=localhost;Catalog=\"Finances Analysis\";"));9192 Assert.That(Project.ConnectionStrings[93 ConnectionStringCollection.ConnectionClass.Oledb,94 ConnectionStringCollection.ConnectionType.Actual95 ].Value,96 Is.EqualTo("Provider=MSOLAP.4;Data Source=localhost;Catalog=\"Finances Analysis\";"));97 }9899 [Test]100 public void Save_Root_CorrectFileContent()101 {102 //Buiding object used during test103 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";104105 Project.Directories.Root = @"C:\Root\Root\";106 Project.Directories[DirectoryCollection.DirectoryType.Metadata].Path = @"C:\MetadataPath\";107108 //Call the method to test109 Project.Save(filename);110111 //Assertion112 string content = null;113 using (var sr = File.OpenText(filename))114 {115 content = sr.ReadToEnd();116 }117 Assert.That(content, Is.StringContaining("<directories root=\"C:\\Root\\Root\\\">"));118 Assert.That(content, Is.StringContaining("</directories>"));119 }120121 [Test]122 public void Save_DirectoryPathAndFile_CorrectFileContent()123 {124 //Buiding object used during test125 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";126127 Project.Directories[DirectoryCollection.DirectoryType.Metadata].Path = @"C:\MetadataPath\";128 Project.Directories[DirectoryCollection.DirectoryType.Metadata].File = @"MetadataFile.xls";129130131 //Call the method to test132 Project.Save(filename);133134 //Assertion135 string content = null;136 using (var sr = File.OpenText(filename))137 {138 content = sr.ReadToEnd();139 }140 Assert.That(content, Is.StringContaining("<directory key=\"Metadata\" path=\"C:\\MetadataPath\\\" file=\"MetadataFile.xls\" />"));141 }142143 [Test]144 public void Save_DirectoryPath_CorrectFileContent()145 {146 //Buiding object used during test147 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";148149 Project.Directories[DirectoryCollection.DirectoryType.Metadata].Path = @"C:\MetadataPath\";150 Project.Directories[DirectoryCollection.DirectoryType.Metadata].File = @"";151152 //Call the method to test153 Project.Save(filename);154155 //Assertion156 string content = null;157 using (var sr = File.OpenText(filename))158 {159 content = sr.ReadToEnd();160 }161 Assert.That(content, Is.StringContaining("<directory key=\"Metadata\" path=\"C:\\MetadataPath\\\" />"));162 }163164 [Test]165 public void Save_ConnectionStringOledbExpect_CorrectFileContent()166 {167 //Buiding object used during test168 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";169170 Project.ConnectionStrings[171 ConnectionStringCollection.ConnectionClass.Oledb,172 ConnectionStringCollection.ConnectionType.Expect173 ].Value = "Oledb+Expect";174175176 //Call the method to test177 Project.Save(filename);178179 //Assertion180 string content = null;181 using (var sr = File.OpenText(filename))182 {183 content = sr.ReadToEnd();184 }185 Assert.That(content, Is.StringContaining("<oledb key=\"Expect\">Oledb+Expect</oledb>"));186 }187188 [Test]189 public void Save_ConnectionStringAdomdExpect_CorrectFileContent()190 {191 //Buiding object used during test192 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";193194 Project.ConnectionStrings[195 ConnectionStringCollection.ConnectionClass.Adomd,196 ConnectionStringCollection.ConnectionType.Expect197 ].Value = "Adomd+Expect";198199 //Call the method to test200 Project.Save(filename);201202 //Assertion203 string content = null;204 using (var sr = File.OpenText(filename))205 {206 content = sr.ReadToEnd();207 }208 Assert.That(content, Is.StringContaining("<adomd key=\"Expect\">Adomd+Expect</adomd>"));209 }210211 [Test]212 public void Save_ConnectionStringOledbActual_CorrectFileContent()213 {214 //Buiding object used during test215 var filename = DiskOnFile.GetDirectoryPath() + @"\MyProject-" + MethodBase.GetCurrentMethod().Name + ".nbi";216217 Project.ConnectionStrings[218 ConnectionStringCollection.ConnectionClass.Oledb,219 ConnectionStringCollection.ConnectionType.Actual220 ].Value = "Oledb+Actual";221222 //Call the method to test223 Project.Save(filename);224225 //Assertion226 string content = null;227 using (var sr = File.OpenText(filename))228 {229 content = sr.ReadToEnd(); ...

Full Screen

Full Screen

ExecutionXmlTest.cs

Source:ExecutionXmlTest.cs Github

copy

Full Screen

...28 [Test]29 public void GetQuery_FilenameSpecified_RetrieveContentOfFile()30 {31 //create a text file on disk32 var filename = DiskOnFile.CreatePhysicalFile("QueryFile.sql", "NBi.Testing.Unit.Xml.Resources.QueryFile.sql");33 34 //Instantiate a Test Case and specify to find the sql in the file created above35 var testCase = new ExecutionXml()36 {37 Item = new QueryXml() { File = filename }38 };3940 // A Stream is needed to read the text file from the assembly.41 string expectedContent;42 using (Stream stream = Assembly.GetExecutingAssembly()43 .GetManifestResourceStream("NBi.Testing.Unit.Xml.Resources.QueryFile.sql"))44 using (StreamReader reader = new StreamReader(stream))45 expectedContent = reader.ReadToEnd();46 47 Assert.AreEqual(expectedContent, (testCase.Item as QueryableXml).GetQuery());48 }4950 [Test]51 public void GetQuery_FilenameNotSpecified_RetrieveContentOfInlineQuery()52 {53 //Instantiate a System Under Test54 var systemUnderTest = new ExecutionXml() 55 {56 Item = new QueryXml() { InlineQuery = "SELECT * FROM Product" }57 };5859 Assert.That(((QueryXml)systemUnderTest.Item).GetQuery(), Is.EqualTo("SELECT * FROM Product"));60 Assert.That(((QueryXml)systemUnderTest.Item).InlineQuery, Is.Not.Null.And.Not.Empty.And.ContainsSubstring("SELECT"));61 Assert.That(((QueryXml)systemUnderTest.Item).File, Is.Null);62 }6364 [Test]65 public void GetQuery_FileNameSpecified_RetrieveContentOfFile()66 {67 //Create the queryfile to read68 var filename = "Select all products.sql";69 DiskOnFile.CreatePhysicalFile(filename, "NBi.Testing.Unit.Xml.Resources.SelectAllProducts.sql");7071 var systemUnderTest = new ExecutionXml()72 {73 Item = new QueryXml() { 74 File = filename, 75 Settings = new NBi.Xml.Settings.SettingsXml() { BasePath=DiskOnFile.GetDirectoryPath() }76 }77 };7879 // Check the properties of the object.80 Assert.That(((QueryXml)systemUnderTest.Item).File, Is.Not.Null.And.Not.Empty);81 Assert.That(((QueryXml)systemUnderTest.Item).InlineQuery, Is.Null);82 Assert.That(((QueryXml)systemUnderTest.Item).GetQuery(), Is.Not.Null.And.Not.Empty.And.ContainsSubstring("SELECT"));83 84 }858687 [Test]88 public void GetQuery_FilenameSpecified_RetrieveContentWithEuroSymbol()89 {90 //create a text file on disk91 var filename = DiskOnFile.CreatePhysicalFile("QueryFile€.mdx", "NBi.Testing.Unit.Xml.Resources.QueryFileEuro.mdx");9293 //Instantiate a Test Case and specify to find the sql in the file created above94 var testCase = new ExecutionXml()95 {96 Item = new QueryXml() { File = filename }97 };9899 // A Stream is needed to read the text file from the assembly.100 string expectedContent = "select [measure].[price €/Kg] on 0;";101102 Assert.AreEqual(expectedContent, ((QueryableXml)testCase.Item).GetQuery());103 }104 105 } ...

Full Screen

Full Screen

XmlManagerTest.cs

Source:XmlManagerTest.cs Github

copy

Full Screen

...9 {10 [Test]11 public void Load_ValidFile_Success()12 {13 var filename = DiskOnFile.CreatePhysicalFile("TestSuite.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerSample.xml");14 15 var manager = new XmlManager();16 manager.Load(filename);1718 Assert.That(manager.TestSuite, Is.Not.Null);19 }2021 [Test]22 public void Load_ValidFile_TestContentIsCorrect()23 {24 var filename = DiskOnFile.CreatePhysicalFile("TestContentIsCorrect.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerSample.xml");2526 var manager = new XmlManager();27 manager.Load(filename);2829 Assert.That(manager.TestSuite.Tests[0].Content, Is.Not.Null);30 }3132 [Test]33 public void Load_InvalidFile_Successfully()34 {35 var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntax.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntax.xml");3637 var manager = new XmlManager();38 Assert.Throws<ArgumentException>(delegate { manager.Load(filename); });39 }40 }41} ...

Full Screen

Full Screen

DiskOnFile

Using AI Code Generation

copy

Full Screen

1using NBi.Testing;2using System;3{4 {5 static void Main(string[] args)6 {7 DiskOnFile disk = new DiskOnFile();8 Console.WriteLine("Disk Size: " + disk.GetDiskSize(@"C:\temp\test.txt"));9 Console.ReadLine();10 }11 }12}13I am getting an error, the type or namespace name 'NBi' could not be found (are you missing a using directive or an assembly reference?)

Full Screen

Full Screen

DiskOnFile

Using AI Code Generation

copy

Full Screen

1using NBi.Testing;2using System.IO;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8using System.Reflection;9{10 {11 static void Main(string[] args)12 {13 DiskOnFile disk = new DiskOnFile();14 disk.Path = @"C:\Test.txt";15 disk.Content = "This is a test";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in DiskOnFile

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful