3using System.Reflection;
4using System.Text.RegularExpressions;
15 private static readonly String PROPERTIES_FILE =
"test.properties";
16 private static String gamsDefaultPath =
null;
17 private static String APIVersion;
18 private static int majorVersion;
19 private static int minorVersion;
20 private static int goldVersion;
21 private static String userDefinedSystemDir =
null;
22 private static String tempPath = Path.GetTempPath();
23 private static String workingDir;
24 private String prefix =
"_gams_net_gcp";
29 static Logger logger = LogManager.GetCurrentClassLogger();
32 public static void OneTimeSetup()
34 logger.Debug(
"TestGAMSWorkspace | OneTimeSetup");
38 if (gamsDefaultPath ==
null)
40 userDefinedSystemDir = InitializeGAMSDirectoryForUserDefinedConfiguration();
42 majorVersion = Int16.Parse(Regex.Split(APIVersion,
"\\.")[0]);
43 minorVersion = Int16.Parse(Regex.Split(APIVersion,
"\\.")[1]);
44 goldVersion = Int16.Parse(Regex.Split(APIVersion,
"\\.")[2]);
45 logger.Debug(
"TestGAMSWorkspace | oneTimeSetup");
49 public static void OneTimeTearDown()
51 logger.Debug(
"entering TestGAMSWorkspace | OneTimeTearDown");
54 logger.Debug(
"exiting TestGAMSWorkspace | OneTimeTearDown");
61 private static string InitializeGAMSDirectoryForUserDefinedConfiguration()
75 public void TearDown()
82 public void testAPIVersion()
84 logger.Debug(
"entering Test GAMSWorkspace | testAPIVersion");
87 APIVersion +
"] as API release number in GAMSWorkspace.");
89 APIVersion +
"] as API major release number in GAMSWorkspace.");
91 APIVersion +
"] as API minor release number in GAMSWorkspace.");
93 APIVersion +
"] as API gold release number in GAMSWorkspace.");
94 logger.Debug(
"exiting Test GAMSWorkspace | testAPIVersion");
98 public void testGAMSVersion()
100 logger.Debug(
"TestGAMSWorkspace | testGAMSVersion");
103 Assert.NotNull(ws,
"expect a successful creation of GAMSWorkspace.");
104 Assert.AreEqual(APIVersion, ws.
Version,
"expect [" + APIVersion +
"] as GAMS release number in GAMSWorkspace.");
105 Assert.AreEqual(majorVersion, ws.
MajorRelNumber,
"expect [" + majorVersion +
"] as GAMS major release number in GAMSWorkspace.");
106 Assert.AreEqual(minorVersion, ws.
MinorRelNumber,
"expect [" + minorVersion +
"] as GAMS minor release number in GAMSWorkspace.");
107 Assert.AreEqual(goldVersion, ws.
GoldRelNumber,
"expect [" + goldVersion +
"] as GAMS gold release number in GAMSWorkspace.");
109 logger.Debug(
"exiting TestGAMSWorkspace | testGAMSVersion");
113 public void testGAMSWorkspaceInfo1()
115 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo1");
120 logger.Debug(
"exiting TestGamsWorkspace | testGAMSVersion");
124 public void testGAMSWorkspaceInfo2()
126 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspace2");
128 wsInfo.SystemDirectory =
HouseKeeper.gamsAbsoluteSystemDir;
131 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspace2");
136 public void testGAMSWorkspaceInfo3()
138 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo3");
140 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
143 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspaceInfo3");
147 public void testGAMSWorkspaceInfo4()
149 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo4");
151 Assert.False(Directory.Exists(
"testGAMSWorkspaceInfo4"),
152 "does not expect existence of [" + workingDir +
155 wsInfo.WorkingDirectory = workingDir;
157 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspaceInfo4");
190 public void testGAMSWorkspaceInfo7()
192 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo7");
194 String userDir = Path.GetDirectoryName(
195 Assembly.GetExecutingAssembly().Location);
196 wsInfo.WorkingDirectory = userDir;
199 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspaceInfo7");
215 public void testGAMSWorkspaceInfo9()
217 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo9");
222 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspaceInfo9");
225 public void testGAMSWorkspaceInfo10()
227 logger.Debug(
"enterting TestGAMSWorkspace | testGAMSWorkspaceInfo10");
236 logger.Debug(
"exiting TestGamsWorkspace | testGAMSWorkspaceInfo10");
240 public void testDefaultConstructor()
242 logger.Debug(
"enterting TestGAMSWorkspace | testDefaultConstructor");
246 testExpectedWorkspaceResult(tempPath, gamsDefaultPath,
DebugLevel.KeepFilesOnError);
247 logger.Debug(
"exiting TestGamsWorkspace | testDefaultConstructor");
251 public void testGAMSWorkspaceConstructorWithNullGAMSWorkspaceInfo()
253 logger.Info(
"test exception");
260 public void testConstructorWithGAMSWorkspaceInfo1()
262 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo1");
264 testExpectedWorkspaceResult(tempPath, gamsDefaultPath,
DebugLevel.KeepFilesOnError);
265 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo1");
269 public void testConstructorWithGAMSWorkspaceInfo2()
271 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo2");
272 wsInfo.SystemDirectory =
null;
274 testExpectedWorkspaceResult(tempPath, gamsDefaultPath,
DebugLevel.KeepFilesOnError);
275 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo2");
279 public void testConstructorWithGAMSWorkspaceInfo3()
281 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo3");
282 wsInfo.WorkingDirectory =
null;
284 testExpectedWorkspaceResult(tempPath, gamsDefaultPath,
DebugLevel.KeepFilesOnError);
285 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo3");
302 public void testConstructorWithGAMSWorkspaceInfo5()
304 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo5");
309 testExpectedWorkspaceResult(tempPath, gamsDefaultPath,
DebugLevel.KeepFiles);
310 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo5");
327 public void testConstructorWithGAMSWorkspaceInfo7()
329 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo7");
330 wsInfo.SystemDirectory = userDefinedSystemDir;
331 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
335 testExpectedWorkspaceResult(
HouseKeeper.gamsWorkingDir, userDefinedSystemDir,
DebugLevel.KeepFilesOnError);
336 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo7");
340 public void testConstructorWithGAMSWorkspaceInfo8()
342 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo8");
343 wsInfo.SystemDirectory = userDefinedSystemDir;
348 testExpectedWorkspaceResult(tempPath, userDefinedSystemDir,
DebugLevel.KeepFiles);
349 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo8");
353 public void testConstructorWithGAMSWorkspaceInfo9()
355 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo9");
356 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
362 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo9");
366 public void testConstructorWithGAMSWorkspaceInfo10()
368 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo10");
369 wsInfo.SystemDirectory = userDefinedSystemDir;
370 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
376 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithGAMSWorkspaceInfo10");
380 public void testConstructorWithGAMSWorkspaceInfo11()
382 logger.Debug(
"test exception");
383 wsInfo.SystemDirectory =
"";
390 public void testConstructorWithGAMSWorkspaceInfo12()
392 logger.Debug(
"test exception");
393 wsInfo.WorkingDirectory =
"";
399 public void testConstructorWithGAMSWorkspaceInfoWhitespaces1()
401 logger.Debug(
"test exception");
403 wsInfo.WorkingDirectory =
" ";
408 public void testConstructorWithGAMSWorkspaceInfoWhitespaces2()
410 logger.Debug(
"test exception");
412 wsInfo.WorkingDirectory =
" ";
417 public void testCronstructorWithThreeParameters1()
419 logger.Debug(
"entering TestGAMSWorkspace | testCronstructorWithThreeParameters1");
422 testExpectedWorkspaceResult(tempPath, userDefinedSystemDir,
HouseKeeper.gamsDebugLevel);
423 logger.Debug(
"exiting TestGAMSWorkspace | testCronstructorWithThreeParameters1");
427 public void testCronstructorWithThreeParameters2()
429 logger.Debug(
"entering TestGAMSWorkspace | testCronstructorWithThreeParameters2");
434 logger.Debug(
"exiting TestGAMSWorkspace | testCronstructorWithThreeParameters2");
438 public void testCronstructorWithThreeParameters3()
440 logger.Debug(
"entering TestGAMSWorkspace | testCronstructorWithThreeParameters3");
444 testExpectedWorkspaceResult(
HouseKeeper.gamsWorkingDir, userDefinedSystemDir,
HouseKeeper.gamsDebugLevel);
445 logger.Debug(
"exiting TestGAMSWorkspace | testCronstructorWithThreeParameters3");
449 public void testCronstructorWithThreeParameters4()
451 logger.Debug(
"entering TestGAMSWorkspace | testCronstructorWithThreeParameters4");
452 String dirName =
"testConstructorWithThreeParameters4";
453 Assert.False(Directory.Exists(dirName));
457 testExpectedWorkspaceResult(
HouseKeeper.gamsWorkingDir, userDefinedSystemDir,
HouseKeeper.gamsDebugLevel);
458 logger.Debug(
"exiting TestGAMSWorkspace | testCronstructorWithThreeParameters4");
462 public void testConstructorWithThreeParameters5()
464 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParameters5");
468 testExpectedWorkspaceResult(Path.GetTempPath(), gamsDefaultPath,
DebugLevel.KeepFilesOnError);
470 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParameters5");
474 public void testConstructorWithThreeParameters6()
476 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParameters6");
480 testExpectedWorkspaceResult(
HouseKeeper.gamsWorkingDir, userDefinedSystemDir,
DebugLevel.KeepFilesOnError);
481 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParameters6");
485 public void testConstructorWithThreeParameters7()
487 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParameters7");
490 "./This/is/a/rediculous/gams/system/directory/ever@#$%^",
493 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParameters7");
497 public void testConstructorWithThreeParameters8()
499 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParameters8");
502 Assembly.GetExecutingAssembly().Location)),
"do not expect current directory as gams system directory");
506 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParameters8");
510 public void testConstructorWithThreeParametersWhitespaces1()
512 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParametersWhitespaces2");
516 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParametersWhitespaces2");
520 public void testConstructorWithThreeParametersWhitespaces2()
522 logger.Debug(
"entering TestGAMSWorkspace | testConstructorWithThreeParametersWhitespaces3");
526 logger.Debug(
"exiting TestGAMSWorkspace | testConstructorWithThreeParametersWhitespaces3");
530 public void testSetMyEPS()
533 logger.Debug(
"entering TestGAMSWorkspace | testSetMyEPS");
535 double oldValue = gamsglobals.sv_eps;
536 double newValue = 5E-300;
544 Assert.That(newValue != oldValue,
"do not expect same special value.");
547 logger.Debug(
"exiting TestGAMSWorkspace | testSetMyEPS");
551 public void testAddDefaultOption()
553 logger.Debug(
"entering TestGAMSWorkspace | testAddDefaultOption");
558 Assert.AreEqual(0, opt.
Defines.Count,
"expect 0 definitions in opt.");
559 opt.
Defines.Add(
"gdxincname",
"tdata");
560 opt.
Defines.Add(
"useBig",
"1");
561 opt.
Defines.Add(
"nrScen",
"100");
564 Assert.AreEqual(opt.
Defines.Count, newopt.
Defines.Count,
"expect [opt] and [newopt] with the same definition.");
565 Assert.AreEqual(3, opt.
Defines.Count,
"expect [opt] and [newopt] with the same number of definitions.");
568 opt.
Defines.TryGetValue(
"gdxincname", out nopt);
569 newopt.
Defines.TryGetValue(
"gdxincname", out oopt);
570 Assert.AreEqual(oopt, nopt,
"expect [opt] and [newopt] with the same definition of [gdxincname].");
571 Assert.AreEqual(opt.
Defines.Count, newopt.
Defines.Count,
"expect [opt] and [newopt] with the same number of definitions.");
573 foreach (String key
in opt.Defines.Keys)
575 Assert.NotNull(key,
"do not expect a NULL definition of [" + key +
"] in [opt].");
578 logger.Debug(
"exiting TestGAMSWorkspace | testAddDefaultOption");
582 public void testAddDefaultCheckpoint()
584 logger.Debug(
"entering TestGAMSWorkspace | testAddDefaultCheckpoint");
589 Assert.That(cp.
Name.StartsWith(prefix),
"expect checkpoint name [" + cp.
Name +
"] with prefix [" + prefix +
"].");
591 logger.Debug(
"exiting TestGAMSWorkspace | testAddDefaultCheckpoint");
595 public void testAddCheckpointNullName()
597 logger.Debug(
"entering TestGAMSWorkspace | testAddCheckpointNullName");
602 Assert.That(cp.
Name.StartsWith(prefix),
"expect checkpoint name [" + cp.
Name +
"] with prefix [" + prefix +
"].");
604 logger.Debug(
"exiting TestGAMSWorkspace | testAddCheckpointNullName");
608 public void testCheckpointEmptyName()
610 logger.Debug(
"entering TestGAMSWorkspace | testCheckpointEmptyName");
615 Assert.That(cp.
Name.StartsWith(prefix),
"expect checkpoint name [" + cp.
Name +
"] with prefix [" + prefix +
"].");
617 logger.Debug(
"exiting TestGAMSWorkspace | testCheckpointEmptyName");
621 public void testAddDefaultCheckpoint1()
623 logger.Debug(
"entering TestGAMSWorkspace | testAddDefaultCheckpoint1");
625 DirectoryInfo workingDir =
new DirectoryInfo(
HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testDefaultCheckpoint1");
626 Assert.False(workingDir.Exists,
"does not expect existence of [" + workingDir.FullName +
"]");
630 Assert.NotNull(job,
"does not expect a NULL GAMSJob");
631 String jobName =
"testAddDefaultCheckpoint1";
636 logger.Debug(
"exiting TestGAMSWorkspace | testAddDefaultCheckpoint1");
640 public void testAddDefaultCheckpoint2()
642 logger.Debug(
"entering TestGAMSWorkspace | testAddDefaultCheckpoint2");
644 DirectoryInfo workingDir =
new DirectoryInfo(
HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testAddDefaultCheckpoint2");
645 Assert.False(workingDir.Exists,
"does not expect existence of [" + workingDir.FullName +
"]");
649 Assert.NotNull(job,
"does not expect a NULL GAMSJob");
650 String jobName =
"testAddDefaultCheckpoint2";
653 FileInfo file =
new FileInfo(workingDir.FullName + Path.DirectorySeparatorChar + cp.
Name +
".g00");
655 Assert.False(file.Exists,
"do not expect GAMSCheckpoint file [" + file.Name +
"] under [" + ws.
WorkingDirectory +
"].");
658 logger.Info(
"job executed with checkpoint cp");
661 Assert.That(file.Exists,
"expect GAMSCheckpoint file [" + file.Name +
"] under [" + ws.
WorkingDirectory +
"].");
664 Assert.NotNull(job,
"do not expect a NUll job.");
666 logger.Debug(
"exiting TestGAMSWorkspace | testAddDefaultCheckpoint2");
670 public void testAddCheckpointString1()
672 logger.Debug(
"entering TestGAMSWorkspace | testAddCheckpointString1");
674 FileInfo workingDir =
new FileInfo(
HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testAddCheckpointDuplicateName");
675 Assert.False(workingDir.Exists,
"does not expect existence of [" + workingDir.FullName +
"]");
680 Assert.NotNull(job,
"does not expect a NULL GAMSJob");
681 String jobName =
"testAddCheckpointString1";
682 String cpName =
"testAddCheckpointString1";
688 logger.Debug(
"exiting TestGAMSWorkspace | testAddCheckpointString1");
692 public void testAddCheckpointDuplicateName()
694 logger.Debug(
"entering TestGAMSWorkspace | testAddCheckpointDuplicateName");
696 FileInfo workingDir =
new FileInfo(
HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testAddCheckpointDuplicateName");
697 Assert.False(workingDir.Exists,
"does not expect existence of [" + workingDir.FullName +
"]");
701 String cpFileName =
"testAddCheckpointDuplicateName";
707 logger.Debug(
"exiting TestGAMSWorkspace | testAddCheckpointDuplicateName");
711 public void testAddDefaultDatabase()
713 logger.Debug(
"entering TestGAMSWorkspace | testAddDefaultDatabase");
716 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
720 testAnEmptyDatabase();
722 logger.Debug(
"exiting TestGAMSWorkspace | testAddDefaultDatabase");
726 public void testAddDatabaseWithName()
728 logger.Debug(
"entering TestGAMSWorkspace | testAddDatabaseWithName");
731 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
733 String dbName =
"testAddDatabaseWithName";
736 testAnEmptyDatabase();
737 Assert.AreEqual(dbName, db.
Name,
"expect as [" + dbName +
"] as db.getName().");
739 logger.Debug(
"exiting TestGAMSWorkspace | testAddDatabaseWithName");
743 public void testAddDatabaseFromNullGDX()
745 logger.Debug(
"entering TestGAMSWorkspace | testAddDatabaseFromNullGDX");
748 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
753 logger.Debug(
"exiting TestGAMSWorkspace | testAddDatabaseFromNullGDX");
757 public void testAddDatabaseFromNonExistGDXFile()
759 logger.Debug(
"entering TestGAMSWorkspace | testAddDatabaseFromNonExistGDXFile");
762 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
767 logger.Debug(
"exiting TestGAMSWorkspace | testAddDatabaseFromNonExistGDXFile");
771 private void testAnEmptyDatabase()
773 Assert.AreEqual(0, db.
NrSymbols,
"does not expect a symbol in newly created database.");
776 Assert.Fail(
"does not expect a symbol in a newly created database.");
779 Assert.Null(sym,
"expect a NULL symbol");
807 Assert.NotNull(wsInfo.
WorkingDirectory,
"does not expect a NULL wsInfo.WorkingDirectory.");
808 StringAssert.AreEqualIgnoringCase(
new DirectoryInfo(workdir).FullName,
810 "expect as [" + workdir +
"] as wsInfo.WorkingDirectory."
816 Assert.Null(wsInfo.
SystemDirectory,
"expect a NULL system directory.");
820 Assert.NotNull(wsInfo.
SystemDirectory,
"does not expect a NULL wsInfo.getSystemDirectory().");
821 StringAssert.AreEqualIgnoringCase(
new DirectoryInfo(sysdir).FullName,
823 "expect as [" + sysdir +
"] as wsInfo.getSystemDirectory()."
828 public void testExpectedWorkspaceResult(String workdir, String sysdir,
DebugLevel debug)
830 Assert.NotNull(ws,
"expect a successful creation of GAMSWorkspace.");
831 Assert.NotNull(ws.
SystemDirectory,
"does not expect a NULL system directory");
832 StringAssert.AreEqualIgnoringCase(Directory.CreateDirectory(sysdir).FullName,
833 Directory.CreateDirectory(Path.GetFullPath(ws.
SystemDirectory)).FullName,
834 "expect a gams system dir being set to [" + sysdir +
"].",
null);
835 Assert.True(Directory.Exists(sysdir),
"expect an existence of a directory");
838 Assert.NotNull(ws.
WorkingDirectory,
"does not expect a NULL working directory");
839 Assert.True(Directory.Exists(workdir),
"expect an existence of working directory [" + workdir +
"]");
841 String expectedWorkDir = Path.GetFullPath(workdir);
844 if (Path.GetTempPath().Equals(expectedWorkDir))
846 String actualWorkDir = Path.GetFullPath(Directory.GetParent(ws.
WorkingDirectory).ToString());
847 Assert.AreEqual(
new DirectoryInfo(expectedWorkDir), Directory.GetParent(ws.
WorkingDirectory),
848 "expect a gams working dir being set to [" + expectedWorkDir +
"]."
853 Assert.AreEqual(expectedWorkDir, wsWorkDir,
854 "expect a gams working dir being set to [" + expectedWorkDir +
"].");
859 public void testAddOptionFromOptFile()
861 logger.Debug(
"Entering TestGAMSWorkspace | testAddOptionFromOptFile");
863 wsInfo.WorkingDirectory = HouseKeeper.gamsWorkingDir;
867 String optfilename =
"testoption.pf";
870 FileInfo optfile =
new FileInfo(Path.Combine(ws.
WorkingDirectory, optfilename));
872 using (StreamWriter writer =
new StreamWriter(optfile.FullName))
874 writer.WriteLine(
"IterLim=1");
881 Assert.AreEqual(opt.
IterLim, 1,
"expect option [IterLim] with value 1.");
885 Assert.Fail(
"Exception should not be thrown : " + e.ToString());
887 logger.Debug(
"Exiting TestGAMSWorkspace | testAddOptionFromOptFile");
891 public void testAddOptionFromNonExistingOptFile()
893 logger.Debug(
"Entering TestGAMSWorkspace | testAddOptionFromNonExistingOptFile");
896 String filename =
"ThisIsAStrangeFileName.pf";
900 logger.Debug(
"Exiting TestGAMSWorkspace | testAddOptionNonExistingFromOptFile");
905 public void testAddDuplicatedDatabaseWithName()
907 logger.Debug(
"Entering TestGAMSWorkspace | testAddDuplicatedDatabaseWithName");
910 wsInfo.WorkingDirectory = HouseKeeper.gamsWorkingDir;
939 public void testAddDatabaseFromSourceWithDuplicatedName()
941 logger.Debug(
"Entering TestGAMSWorkspace | testAddDatabaseFromForcedNameGDX");
944 wsInfo.WorkingDirectory = HouseKeeper.gamsWorkingDir;
955 public void testAddDatabaseFromGDXWithDuplicatedName()
957 logger.Debug(
"Entering TestGAMSWorkspace | testAddDatabaseFromGDXWithDuplicatedName");
960 wsInfo.WorkingDirectory = HouseKeeper.gamsWorkingDir;
964 FileInfo gdxFile =
new FileInfo(Path.Combine(ws.
WorkingDirectory,
"p.gdx"));
965 db.
Export(gdxFile.FullName);
972 public void testEquivalentWorkspace()
974 logger.Debug(
"Entering TestGAMSWorkspace | testEquivalentWorkspace");
981 Assert.True(ws1 != ws2);
986 Assert.True(ws1 != ws3);
987 Assert.True(ws2 != ws3);
988 logger.Debug(
"Exiting TestGAMSWorkspace | testEquivalentWorkspace");
993 public void testDebugLevelTmpDir1()
995 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir1");
997 ws =
new GAMSWorkspace(systemDirectory: userDefinedSystemDir);
1002 Assert.False(Directory.Exists(wDir),
"does not expect tmp working directory to exist");
1003 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir1");
1008 public void testDebugLevelTmpDir2()
1010 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir2");
1012 ws =
new GAMSWorkspace(systemDirectory: userDefinedSystemDir);
1017 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1018 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir2");
1023 public void testDebugLevelTmpDir3()
1025 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir3");
1032 Assert.False(Directory.Exists(wDir),
"does not expect tmp working directory to exist");
1033 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir3");
1038 public void testDebugLevelTmpDir4()
1040 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir4");
1047 Assert.False(Directory.Exists(wDir),
"does not expect tmp working directory to exist");
1048 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir4");
1053 public void testDebugLevelTmpDir5()
1055 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir5");
1062 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1063 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir5");
1068 public void testDebugLevelTmpDir6()
1070 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir6");
1077 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1078 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir6");
1083 public void testDebugLevelTmpDir7()
1085 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir7");
1092 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1093 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir7");
1098 public void testDebugLevelTmpDir8()
1100 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDir8");
1107 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1108 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDir8");
1113 public void testDebugLevelTmpDirEngine1()
1115 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDirEngine1");
1117 ws =
new GAMSWorkspace(systemDirectory: userDefinedSystemDir);
1120 username: Environment.GetEnvironmentVariable(
"ENGINE_USER"),
1121 password: Environment.GetEnvironmentVariable(
"ENGINE_PASSWORD"),
1122 space: Environment.GetEnvironmentVariable(
"ENGINE_NAMESPACE"));
1126 Assert.False(Directory.Exists(wDir),
"does not expect tmp working directory to exist");
1127 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDirEngine1");
1132 public void testDebugLevelTmpDirEngine2()
1134 logger.Debug(
"entering TestGAMSWorkspace | testDebugLevelTmpDirEngine2");
1136 ws =
new GAMSWorkspace(systemDirectory: userDefinedSystemDir);
1139 username: Environment.GetEnvironmentVariable(
"ENGINE_USER"),
1140 password: Environment.GetEnvironmentVariable(
"ENGINE_PASSWORD"),
1141 space: Environment.GetEnvironmentVariable(
"ENGINE_NAMESPACE"));
1145 Assert.True(Directory.Exists(wDir),
"does expect tmp working directory to exist");
1146 logger.Debug(
"exiting TestGAMSWorkspace | testDebugLevelTmpDirEngine2");
1153 Assert.NotNull(job);
1156 Assert.NotNull(job);
1157 Assert.NotNull(job.
OutDB);
GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")
void Export(string filePath=null)
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)
void RunEngine(GAMSEngineConfiguration engineConfiguration, HashSet< string > extraModelFiles=null, Dictionary< string, string > engineOptions=null, GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true, Boolean removeResults=true, params GAMSDatabase[] databases)
Dictionary< string, string > Defines
static int APIMinorRelNumber
GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSJob AddJobFromGamsLib(string model, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSDatabase AddDatabaseFromGDX(string gdxFileName, string databaseName=null, string inModelName=null)
GAMSDatabase AddDatabase(string databaseName=null, string inModelName=null)
GAMSCheckpoint AddCheckpoint(string checkpointName=null)
GAMSJob AddJobFromFile(string fileName, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSOptions AddOptions(GAMSOptions optFrom=null)
static int APIMajorRelNumber
static int APIGoldRelNumber
static String findGAMSFromPathEnvironmentVariable()
Find a valid GAMS system directory from environment.
static bool rcleanup(String dir)
(recursively) delete all contents under dir, and delete dir.
static String findGAMS(String systemPath)
Find a valid GAMS system directory from the given path. A valid GAMS system directory contains a file...
static void initializeTestFrom(String filename, String subdir)
initialize class properties from fileName and prepare directory subdir
static bool isGAMSDirectory(String dir)
check a GAMS directory.
void testExpectedWorkspaceInfoResult(String workdir, String sysdir, DebugLevel debug)
Tests globally set workspaceInfo for expected parameters (workdir, sysdir, debuglevel)