Avinash Venkat

Avinash Venkat

  • 1.9k
  • 36
  • 1k

UNit test cases for importing project

Oct 3 2019 12:54 AM
 
 What i need exactly is - i want to import a project of type .hpl from a folder in to my application.
 
what i did: 
i have  written a unit test cases for that where if we run unit test cases , it gets a file from the folder ,if it success it shows tick mark if not X mark.(till this i completed)
 
what i need:
 
if a folder contains say 5 files, it should test all 5 files one by one , if all files import sucess it should show tick mark if not X mark, 
 
 
 NOte: please go throught the code below
 
 
public void ImportHpl30Project()
{
InitAppForTests();
try
{
string targetDirectory = @"..\..\..\TestResources\Hpl30Import\";
string[] fileEntries = Directory.GetFiles(targetDirectory, "*.hpl30");
string rootfolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string path = Hercules.Properties.Settings.Default.RootFolder = rootfolder + HerculesConstants.BackslashSeparator + HerculesConstants.HerculesFolderName + HerculesConstants.BackslashSeparator + HerculesConstants.HerculesRootFolderName;
string fileName = Path.GetFileNameWithoutExtension(fileEntries[0]);
if(Directory.Exists(@path + "\\" + fileName))
{
Directory.Delete(@path + "\\" + fileName,true);
}
Util.OsSettingsCultureInfo = new CultureInfo("en");
HerculesWindow window = new HerculesWindow();
IWinFormOverlay overlay = window.GetOverlay();
overlay.GetSpreadSheetPointName(PointRepMode.LayoutPoint);
Hpl30ImportProjectManager pr = new Hpl30ImportProjectManager(window);
bool result = pr.Hpl30_ImportProject(@fileEntries[0]);
Assert.IsTrue(result);
}
catch (Exception)
{
Assert.IsFalse(true);
}
}

Brought to you by: