12 static readonly String PROPERTIES_FILE =
"test.properties";
17 static Logger logger = LogManager.GetCurrentClassLogger();
20 public void OneTimeSetup() {
21 logger.Info(
"entering TestGAMSJob",
"setUpBeforeClass");
23 logger.Trace(
"HouseKeeper task initialized");
25 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
29 logger.Trace(
"Workspace created");
31 logger.Trace(
"database created");
33 logger.Info(
"exiting TestGAMSJob",
"Setup");
37 public void OneTimeTearDown()
39 logger.Info(
"entering TestGAMSJob",
"Setup");
43 logger.Info(
"exiting TestGAMSJob",
"Setup");
54 public void TearDown()
61 public void testAddJobFromNonExistFileString()
63 logger.Debug(
"entering testAddJobFromNonExistingFileString");
67 Assert.That(
true,
"Test skipped",
null);
71 public void testAddJobFromFileString() {
72 logger.Debug(
"entering TestGAMSJob",
"testAddJobFromFileString");
74 String testDir = HouseKeeper.gamsWorkingDir +
75 Path.DirectorySeparatorChar +
76 "testAddJobFromFileString";
83 Assert.NotNull(job,
"does not expect a NULL GAMSJob",
null);
86 Assert.NotNull(job.
Name,
"does not expect GAMSJob instance with a NULL file name",
null);
88 logger.Debug(
"job initialized");
90 logger.Debug(
"job executed");
95 if (job.
OutDB !=
null)
98 logger.Info(
"exiting TestGAMSJob",
"testAddJobFromFileString");
102 public void testAddJobFromFileGAMSWorkspaceString()
104 logger.Debug(
"entering TestGAMSJob",
"testAddJobFromFileGAMSWorkspaceString");
106 String testDir = HouseKeeper.gamsWorkingDir +
107 Path.DirectorySeparatorChar +
108 "testAddJobFromFileGAMSWorkspaceString";
112 db = ws.
AddDatabase(
"testAddJobFromFileStringGAMSWorkspaceString");
115 String jobName =
"testAddJobFromFileGAMSWorkspaceString";
118 Assert.NotNull(
"does not expect GAMSJob instance with a NULL file name", job.
Name);
119 Assert.AreEqual(job.
Name, jobName,
"expect GAMSJob instance whose name is [" +
121 logger.Trace(
"job initialized");
125 logger.Trace(
"job executed");
129 if (job.
OutDB !=
null)
132 logger.Debug(
"exiting TestGAMSJob",
"testAddJobFromFileGAMSWorkspaceString");
136 public void testRunWithMultipleTimesDefinesOption()
138 logger.Debug(
"Entering TestGAMSJob | testRunWithMultipleTimesDefinesOption");
140 int numberOfTimes = 5000;
141 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testRunWithMultipleTimesDefinesOption";
146 String data =
"Sets i canning plants / seattle, san-diego / ; ";
147 String model =
"Sets i canning plants \n" +
148 "$if not set gdxincname $abort 'no include file name for data file provided'\n" +
149 "$gdxin %gdxincname% \n" +
160 for (
int i = 0; i < numberOfTimes; i++)
161 opt.
Defines[
"dummyname" + i] =
"dummyvalue" + i;
162 opt.
Defines[
"gdxincname"] =
"pdata";
172 if (job.
OutDB !=
null)
174 logger.Debug(
"Exiting TestGAMSJob | testRunWithMultipleTimesDefinesOption");
178 public void testOutDB()
180 logger.Debug(
"Entering TestGAMSJob | testOutDB");
185 Assert.True(job.
OutDB ==
null,
"expect null OutDB before job.run");
190 Assert.AreEqual(job.
OutDB.
NrSymbols, 12,
"expect null OutDB before job.run");
192 logger.Debug(
"Exiting TestGAMSJob | testOutDB");
GAMSSet GetSet(string setIdentifier)
void Export(string filePath=null)
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)
Dictionary< string, string > Defines
GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSJob AddJobFromGamsLib(string model, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSDatabase AddDatabase(string databaseName=null, string inModelName=null)
GAMSJob AddJobFromFile(string fileName, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSOptions AddOptions(GAMSOptions optFrom=null)
static void prepare(String dir)
Prepare directory by checking its existence. If exists, (non - recursively) delete all its contents,...
static void initializeTestFrom(String filename, String subdir)
initialize class properties from fileName and prepare directory subdir