12 static readonly String PROPERTIES_FILE =
"test.properties";
13 static String workingDir;
16 static Logger logger = LogManager.GetCurrentClassLogger();
20 public static void OneTimeSetup()
22 logger.Debug(
"TestGAMSWorkspaceInfo | OneTimeSetup");
25 logger.Debug(
"TestGAMSWorkspaceInfo | oneTimeSetup");
36 void testExpectedWorkspaceInfoResult(String workdir, String sysdir,
DebugLevel debug)
44 Assert.IsNotNull(wsInfo.
WorkingDirectory,
"does not expect a NULL wsInfo.getWorkingDirectory().");
45 Assert.AreEqual(workdir, wsInfo.
WorkingDirectory,
"expect as [" + workdir +
"] as wsInfo.getWorkingDirectory().");
51 Assert.IsNull(wsInfo.
SystemDirectory,
"expect a NULL system directory.");
55 Assert.IsNotNull(wsInfo.
SystemDirectory,
"does not expect a NULL wsInfo.getSystemDirectory().");
56 Assert.AreEqual(sysdir, wsInfo.
SystemDirectory,
"expect as [" + sysdir +
"] as wsInfo.getWorkingDirectory().");
73 public void testDefaultGAMSWorkspaceInfo()
75 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
79 testExpectedWorkspaceInfoResult(
null,
null,
DebugLevel.Off);
80 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
84 public void testGAMSWorkspaceInfo_systemDirectory()
86 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
89 wsInfo.SystemDirectory =
HouseKeeper.gamsAbsoluteSystemDir;
92 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
97 public void testGAMSWorkspaceInfo_workingDirectory()
99 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
101 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
104 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
109 public void testGAMSWorkspaceInfo_specifyWorkingDirectory()
111 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
113 string workingDir = Path.Combine(
HouseKeeper.gamsAbsoluteWorkingDir,
"testGAMSWorkspaceInfo_specifyWorkingDirectory");
114 Assert.False(Directory.Exists(workingDir),
"does not expect existence of [" + Path.GetFullPath(workingDir) +
"]");
115 wsInfo.WorkingDirectory = Path.GetFullPath(workingDir);
117 testExpectedWorkspaceInfoResult(Path.GetFullPath(workingDir),
null,
DebugLevel.Off);
118 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
122 public void testGAMSWorkspaceInfo_emptyStringWorkingDirectory1()
124 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
126 var workingDir = String.Empty;
127 var parentDir = Path.GetDirectoryName(
HouseKeeper.gamsWorkingDir);
130 Assert.AreEqual(workingDir, parentDir,
"expect an empty string refers to current (in this case parent) directory. ");
131 wsInfo.WorkingDirectory = workingDir;
133 testExpectedWorkspaceInfoResult(workingDir,
null,
DebugLevel.Off);
134 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
138 public void testGAMSWorkspaceInfo_emptyStringWorkingDirectory2()
140 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
142 wsInfo.WorkingDirectory = String.Empty;
144 testExpectedWorkspaceInfoResult(String.Empty,
null,
DebugLevel.Off);
145 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
150 public void testGAMSWorkspaceInfo_userWorkingDirectory()
152 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
154 wsInfo.WorkingDirectory = Environment.CurrentDirectory;
156 string workingDir = Environment.CurrentDirectory;
157 testExpectedWorkspaceInfoResult(Path.GetFullPath(
new DirectoryInfo(workingDir).FullName),
null,
DebugLevel.Off);
158 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
162 public void testGAMSWorkspaceInfo_emptyStringSystemDirectory()
164 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
166 wsInfo.SystemDirectory = String.Empty;
168 testExpectedWorkspaceInfoResult(
null, String.Empty,
DebugLevel.Off);
169 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
173 public void testGAMSWorkspaceInfo_keepFiles()
175 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
179 testExpectedWorkspaceInfoResult(
null,
null,
DebugLevel.KeepFiles);
180 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
184 public void testGAMSWorkspaceInfo()
186 logger.Debug(
"Entering TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
192 testExpectedWorkspaceInfoResult(
HouseKeeper.gamsWorkingDir,
195 logger.Debug(
"Exiting TestGAMSWorkspaceInfo | testDefaultGAMSWorkspaceInfo");
static void initializeTestFrom(String filename, String subdir)
initialize class properties from fileName and prepare directory subdir