11 static readonly String PROPERTIES_FILE =
"test.properties";
16 static Logger logger = LogManager.GetCurrentClassLogger();
19 public void OneTimeSetUp(){
20 logger.Debug(
"entering TestGAMSSymbol | OneTimeSetUp");
22 logger.Info(
"HouseKeeper task initialized");
24 wsInfo.WorkingDirectory =
HouseKeeper.gamsWorkingDir;
28 logger.Info(
"workspace created");
30 logger.Info(
"database created");
32 logger.Debug(
"exiting TestGAMSSymbol | OneTimeSetUp");
36 public void OneTimeTearDown()
38 logger.Debug(
"entering TestGAMSSymbol | OneTimeTearDown");
41 logger.Debug(
"exiting TestGAMSSymbol | OneTimeTearDown");
52 public void TearDown()
59 public void testClear1()
61 logger.Debug(
"entering TestGAMSSymbol | testClear1");
63 String dbName =
"testClear1";
65 logger.Info(
"db added");
67 logger.Info(
"got set [plants]");
69 logger.Info(
"set record added");
70 Assert.That(
set.NumberRecords > 0,
"expect symbol demand with a record.");
73 logger.Info(
"set record cleared");
75 Assert.That(
set.NumberRecords == 0,
"expect symbol demand without a record.");
76 logger.Debug(
"exiting TestGAMSSymbol | testClear1");
80 public void testClear2()
82 logger.Debug(
"entering TestGAMSSymbol | testClear2");
84 String dbName =
"testClear2";
86 logger.Info(
"db added");
88 logger.Info(
"parameter added");
91 logger.Info(
"parameter record cleared");
95 Assert.Fail(
"expect no symbol record after clearing symbol!");
97 logger.Debug(
"exiting TestGAMSSymbol | testClear2");
101 public void testGetFirstRecord()
103 logger.Debug(
"entering TestGAMSSymbol | testGetFirstRecord");
106 logger.Info(
"parameter checked");
109 logger.Info(
"paramter created");
112 logger.Info(
"forst parameter record retrieved");
117 logger.Info(
"checking parameter record #" + count +
" ");
118 Assert.AreEqual(2, record.
Keys.Length,
"expect record with 2 dimensions");
121 Assert.AreEqual(6, count,
"expect 6 iterating record from the slice.");
122 logger.Debug(
"exiting TestGAMSSymbol | testGetFirstRecord");
126 public void testGetLastRecord()
128 logger.Debug(
"entering TestGAMSSymbol | testGetLastRecord");
134 Assert.False(record.
MoveNext(),
"do not expect next record from last record");
135 logger.Info(
"parameter created");
138 logger.Info(
"last parameter record retrieved");
142 logger.Info(
"checking parameter record #" + count +
" ");
143 Assert.AreEqual(2, record.
Keys.Length,
"expect record with 2 dimensions");
147 Assert.AreEqual(1, count,
"expect 1 iterating record from the slice.");
148 logger.Debug(
"exiting TestGAMSSymbol | testGetLastRecord");
152 public void testGetFirstRecordSlice()
154 logger.Debug(
"entering TestGAMSSymbol | testGetFirstRecordSlice");
157 String[] slice =
new String[] {
" ",
"Chicago" };
161 Assert.AreEqual(2, record.
Keys.Length,
"expect record with 2 dimensions");
165 Assert.AreEqual(record.
Keys[1],
"Chicago",
"expect [Chicago] as slice key.");
168 Assert.AreEqual(2, count,
"expect 2 iterating record from the slice.");
170 logger.Debug(
"exiting TestGAMSSymbol | testGetFirstRecordSlice");
174 public void testGetLastRecordSlice()
176 logger.Debug(
"entering TestGAMSSymbol | testGetLastRecordSlice");
179 String[] slice =
new String[] {
" ",
"Chicago" };
183 Assert.AreEqual(2, record.
Keys.Length,
"expect record with 2 dimensions");
184 Assert.False(record.
MoveNext(),
"do not expect next record from last record");
190 Assert.AreEqual(record.
Keys[1],
"Chicago",
"expect [Chicago] as slice key.");
193 Assert.AreEqual(1, count,
"expect 1 iterating record from the slice.");
195 logger.Debug(
"exiting TestGAMSSymbol | testGetLastRecordSlice");
199 public void testCopySymbolSameDB()
201 logger.Debug(
"entering TestGAMSSymbol | testCopySymbolSameDB");
203 String dbName =
"testCopySymbolSameDB";
217 "expect symbols j and jj have the same (first record) key.");
222 Assert.AreEqual(1, record.
Keys.Length);
226 Assert.AreEqual(
"New-York", record.
Keys[0],
"expect first record with name [New-York]");
229 Assert.AreEqual(
"Chicago", record.
Keys[0],
"expect second record with name [Chicago]");
232 Assert.AreEqual(
"Topeka", record.
Keys[0],
"expect third record with name [Topeka]");
237 Assert.AreEqual(3, n,
"expect symbol ii with 3 records.");
239 logger.Debug(
"exiting TestGAMSSymbol | testCopySymbolSameDB");
243 public void testCopySymbolSameDBDifferentDimension()
245 logger.Debug(
"entering TestGAMSSymbol | testCopySymbolSameDBDifferentDimension");
247 String dbName =
"testCopySymbolSameDBDifferentDimension";
254 logger.Debug(
"exiting TestGAMSSymbol | testCopySymbolSameDBDifferentDimension");
258 public void testCopySymbolSameDBDifferentType()
260 logger.Debug(
"entering TestGAMSSymbol | testCopySymbolSameDBDifferentType");
262 String dbName =
"testCopySymbolSameDBDifferentType";
267 logger.Debug(
"exiting TestGAMSSymbol | testCopySymbolSameDBDifferentType");
271 public void testCopySymbolDifferentDBDifferentWS()
273 logger.Debug(
"entering TestGAMSSymbol | testCopySymbolDifferentDBDifferentWS");
275 String dbName =
"testCopySymbolDifferentDBDifferentWS";
282 Assert.AreEqual(3, ii.
NumberRecords,
"expect set[" + ii.
Name +
"] with 3 records.");
283 Assert.AreEqual(1, ii.
Dim,
"expect set[" + ii.
Name +
"] with 1 dimension.");
286 Assert.AreEqual(1, rec.
Keys.Length,
"expect last record with 1 key.");
287 Assert.AreEqual(
"Seattle", rec.
Keys[0],
"expect first record with name [Seattle]");
290 Assert.AreEqual(1, rec.
Keys.Length,
"expect last record with 1 key.");
291 Assert.AreEqual(
"San-Diego", rec.
Keys[0],
"expect last record with name [San-Diego]");
293 logger.Debug(
"exiting TestGAMSSymbol | testCopySymbolDifferentDBDifferentWS");
297 public void testAddRecord()
299 logger.Debug(
"entering TestGAMSSymbol | testAddRecord");
306 Assert.AreEqual(1, rec.
Keys.Length,
"expect last record with 1 key dimension.");
308 "expect set j with [" + (oldNumberRecords + 1) +
"] records.");
310 logger.Debug(
"exiting TestGAMSSymbol | testAddRecord");
314 public void testAddRecordEmptyKey()
316 logger.Debug(
"entering TestGAMSSymbol | testAddRecordEmptyKey");
323 Assert.AreEqual(1, rec.
Keys.Length,
"expect last record with 1 key dimension.");
325 "expect set j with [" + (oldNumberRecords + 1) +
"] records.");
327 logger.Debug(
"exiting TestGAMSSymbol | testAddRecordEmptyKey");
331 public void testAddRecordNullKey()
333 logger.Debug(
"entering TestGAMSSymbol | testAddRecordNullKey");
338 String[] keys = {
null };
341 logger.Debug(
"exiting TestGAMSSymbol | testAddRecordNullKey");
345 public void testDeleteRecord1()
347 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecord1");
353 Assert.That(j.
DeleteRecord(
"Chicago"),
"expect a sucessful delete.");
355 "expect symbol i with [" + (oldNumberRecords - 1) +
"] records.");
357 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecord1");
361 public void testDeleteRecord2()
363 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecord2");
368 Assert.That(j.
DeleteRecord(
"Chicago"),
"expect a successful delete");
371 "expect [Chicago] in markets of globalDB.");
372 Assert.NotNull(j.
FindRecord(
"Topeka"),
"expect [Topeka] in markets of db.");
374 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecord2");
378 public void testDeleteRecord3()
380 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecord3");
385 Assert.That(demand.
DeleteRecord(
"Topeka"),
"expect a successful delete.");
387 "expect [Topeka] in demand of globalDB.");
388 Assert.NotNull(demand.
FindRecord(
"Chicago"),
"expect [Chicago] in demand of db.");
390 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecord3");
394 public void testDeleteRecordDifferentDimensions()
396 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecordDifferentDimensions");
403 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecordDifferentDimensions");
407 public void testDeleteRecordNullKey()
409 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecordNullKey");
414 String[] keys = {
null };
417 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecordNullKey");
421 public void testDeleteRecordEmptyKey1()
423 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecordEmptyKey1");
429 String[] keys = {
"" };
430 Assert.False(j.
DeleteRecord(keys),
"expect an unsucessful delete.");
431 Assert.AreEqual(oldNumberRecords, j.
NumberRecords,
"expect set j with [" + oldNumberRecords +
"] records.");
433 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecordEmptyKey1");
437 public void testDeleteRecordEmptyKey2()
439 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecordEmptyKey2");
445 Assert.NotNull(rec,
"do not exepect a NULL set record");
446 Assert.AreEqual(oldNumberRecords + 1, j.
NumberRecords,
"expect set j with [" + oldNumberRecords +
"] records.");
448 String[] keys = {
"" };
449 Assert.That(j.
DeleteRecord(keys),
"expect an sucessful delete.");
450 Assert.AreEqual(oldNumberRecords, j.
NumberRecords,
"expect set j with [" + oldNumberRecords +
"] records.");
452 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecordEmptyKey2");
456 public void testDeleteRecordNonExistKey()
458 logger.Debug(
"entering TestGAMSSymbol | testDeleteRecordNonExistKey");
463 String[] keys = {
"ThisKeyProbablyDoesNotExistEver" };
465 Assert.False(j.
DeleteRecord(keys),
"expect an unsucessful delete.");
466 Assert.AreEqual(oldNumberRecords, j.
NumberRecords,
"expect set j with ["+(oldNumberRecords)+
"] records.");
468 logger.Debug(
"exiting TestGAMSSymbol | testDeleteRecordNonExistKey");
472 public void testFindNullRecord()
474 logger.Debug(
"entering TestGAMSSymbol | testFindNullRecord");
479 String[] keys = {
null,
null };
482 logger.Debug(
"exiting TestGAMSSymbol | testFindNullRecord");
486 public void testFindRecordDifferentDimension1()
488 logger.Debug(
"entering TestGAMSSymbol | testFindRecordDifferentDimension1");
495 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordDifferentDimension1");
499 public void testFindRecordDifferentDimension2()
501 logger.Debug(
"entering TestGAMSSymbol | testFindRecordDifferentDimension2");
507 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordDifferentDimension2");
511 public void testFindRecordNonExistKey()
513 logger.Debug(
"entering TestGAMSSymbol | testFindRecordNonExistKey");
521 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordNonExistKey");
525 public void testFindRecord()
527 logger.Debug(
"entering TestGAMSSymbol | testFindRecord");
534 Assert.NotNull(rec,
"do not expect a NULL set record");
536 logger.Debug(
"exiting TestGAMSSymbol | testFindRecord");
540 public void testFindRecordEmptyKey()
542 logger.Debug(
"entering TestGAMSSymbol | testFindRecordEmptyKey");
550 Assert.NotNull(findRec,
"do not expect a NULL set record");
551 Assert.AreEqual(1, rec.
Keys.Length,
"expect last record with 1 key dimension.");
552 Assert.AreEqual(oldNumberRecords + 1, j.
NumberRecords,
"expect set j with [" + (oldNumberRecords + 1) +
"] records.");
555 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordEmptyKey");
559 public void testFindRecordNullKey1()
561 logger.Debug(
"entering TestGAMSSymbol | testFindRecordNullKey1");
567 String[] keys = {
null };
571 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordNullKey1");
575 public void testFindRecordNullKey2()
577 logger.Debug(
"entering TestGAMSSymbol | testFindRecordNullKey2");
582 String[] keys = {
null };
585 logger.Debug(
"exiting TestGAMSSymbol | testFindRecordNullKey2");
589 public void testMergeRecordNullKey()
591 logger.Debug(
"entering TestGAMSSymbol | testMergeRecordNullKey");
596 String[] keys = {
null };
599 logger.Debug(
"exiting TestGAMSSymbol | testMergeRecordNullKey");
603 public void testMergeRecordEmptyKey()
605 logger.Debug(
"entering TestGAMSSymbol | testMergeRecordEmptyKey");
610 String[] keys = {
"" };
613 Assert.AreEqual(numberRecords + 1, i.
NumberRecords,
"expect equal number of records");
615 logger.Debug(
"exiting TestGAMSSymbol | testMergeRecordEmptyKey");
619 public void testMergeRecord()
621 logger.Debug(
"entering TestGAMSSymbol | testMergeRecord");
624 String plantName =
"Alburquerque";
628 Assert.NotNull(i.
FindRecord(plantName),
"do not exepect a NULL set record");
630 logger.Debug(
"exiting TestGAMSSymbol | testMergeRecord");
634 public void testMergeRecordExistKey()
636 logger.Debug(
"entering TestGAMSSymbol | testMergeRecordExistKey");
639 String plantName =
"Alburquerque";
646 Assert.NotNull(i.
FindRecord(plantName),
"do not exepect a NULL set record");
647 Assert.AreEqual(oldNumberRecords, i.
NumberRecords,
"expect the same number of records.");
649 logger.Debug(
"exiting TestGAMSSymbol | testMergeRecordExistKey");
653 public void testMergeRecordNonExistKey()
655 logger.Debug(
"entering TestGAMSSymbol | testMergeRecordNonExistKey");
662 Assert.NotNull(j.
FindRecord(
"ThisKeyProbablyDoesNotExist"),
"do not exepect a NULL set record");
663 Assert.AreEqual(oldNumberRecords + 1, j.
NumberRecords,
"do not expect the same number of records.");
665 logger.Debug(
"exiting TestGAMSSymbol | testMergeRecordNonExistKey");
668 [Test, Timeout(20000)]
669 [Ignore(
"heavy load")]
670 public void testAddOneMillionSetRecords()
672 logger.Debug(
"entering TestGAMSSymbol | testAddOneMillionSetRecords");
675 Assert.NotNull(db,
"expect a successful creation of GAMSDatabase.");
678 Assert.AreEqual(1,
set.Dim,
"expect a set with 1 dimension.");
679 Assert.AreEqual(1, db.
NrSymbols,
"textexpect 1 symbol in database.");
680 Assert.AreEqual(0,
set.NumberRecords,
"expect symbol without a record.");
682 for (
int i = 0; i < 1000000; i++)
683 set.AddRecord(i.ToString());
685 Assert.AreEqual(1000000,
set.NumberRecords,
"expect 1,000,000 records in set.");
689 Assert.NotNull(rec,
"do not expect a NULL symbol record instance.");
690 Assert.That(rec is
GAMSSetRecord,
"expect a GAMSSetRecord instance.");
691 Assert.AreEqual(
"set",
set.Name,
"expect [set] as set name.");
694 Assert.AreEqual(1000000, count,
"expect symbol with 1,000,000 records.");
695 Assert.AreEqual(1, db.
NrSymbols,
"expect 1 symbol in database.");
697 logger.Debug(
"exiting TestGAMSSymbol | testAddOneMillionSetRecords");
701 public void testAddGAMSEquationDefaultValue()
703 logger.Debug(
"entering TestGAMSSymbol | testAddGAMSEquationDefaultValue");
708 Assert.AreEqual(1, x.
Dim,
"expect 1 dimension for equation [x].");
709 Assert.AreEqual(
EquType.E, x.
EquType,
"expect x with [" +
EquType.E.ToString() +
"] equation type.");
711 logger.Debug(
"exiting TestGAMSSymbol | testAddGAMSEquationDefaultValue");
715 public void testAddGAMSVariableDefaultValue()
717 logger.Debug(
"entering TestGAMSSymbol | testAddGAMSVariableDefaultValue");
722 Assert.AreEqual(2, x.
Dim,
"expect 2 dimensions for equation [x].");
723 Assert.AreEqual(
VarType.Positive, x.
VarType,
"expect x with [" +
VarType.Positive.ToString() +
"] equation type.");
725 logger.Debug(
"exiting TestGAMSSymbol | testAddGAMSVariableDefaultValue");
729 public void testGetGAMSEquationEquTypeValues()
731 logger.Debug(
"entering TestGAMSSymbol | testGetGAMSEquationEquTypeValues");
733 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
734 "testGetGAMSEquationValues";
743 Assert.AreEqual(
EquType.L, supply.
EquType,
"expect supply with [" +
EquType.L.ToString() +
"] equation type.");
744 Assert.AreEqual(2, supply.
NumberRecords,
"expect 2 records for equation [supply].");
745 Assert.AreEqual(1, supply.
Dim,
"expect 1 dimension for equation [supply].");
748 Assert.AreEqual(
"seattle", rec.
Keys[0],
"expect key [seattle] for first record of equation [supply].");
749 Assert.AreEqual(350.0, rec.
Level,
"expect value for first equation record [supply.seattle].");
751 Assert.AreEqual(
"san-diego", rec.
Keys[0],
"expect key [san-diego] for first record of equation [supply].");
752 Assert.AreEqual(550.0, rec.
Level,
"expect value for first equation record [supply.san-diego].");
755 Assert.AreEqual(
EquType.E, cost.
EquType,
"expect cost with [" +
EquType.E.ToString() +
"] equation type.");
756 Assert.AreEqual(1, cost.
NumberRecords,
"expect 1 records for equation [cost].");
757 Assert.AreEqual(0, cost.
Dim,
"expect 0 dimension for equation [cost].");
761 if (job.
OutDB !=
null)
765 logger.Debug(
"exiting TestGAMSSymbol | testGetGAMSEquationEquTypeValues");
769 public void testGetGAMSVarialbeVarTypeValues()
771 logger.Debug(
"entering TestGAMSSymbol | testGetGAMSVarialbeVarTypeValues");
773 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
774 "testGetGAMSEquationValues";
783 Assert.AreEqual(
VarType.Positive, x.
VarType,
"expect x with [" +
VarType.Positive +
"] variable type.");
784 Assert.AreEqual(2, x.
Dim,
"expect 2 dimensions for variable [x].");
785 Assert.AreEqual(6, x.
NumberRecords,
"expect 6 records for variable [x].");
788 Assert.NotNull(rec,
"expect to find a record with keys(\"seattle\",\"chicago\") from variable [x].");
789 Assert.That((rec.
Level - 300) <= gamsglobals.sv_eps,
790 "expect [300] as the value [z] with keys keys(\"seattle\",\"chicago\").");
794 Assert.AreEqual(0, z.
Dim,
"expect 0 dimension for variable [z].");
795 Assert.AreEqual(1, z.
NumberRecords,
"expect 1 records for variable [z].");
800 if (job.
OutDB !=
null)
804 logger.Debug(
"exiting TestGAMSSymbol | testGetGAMSVarialbeVarTypeValues");
808 public void testEquivalentSymbol()
810 logger.Debug(
"Entering TestGAMSSymbol | testEquivalentSymbol");
812 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testEquivalentSymbol";
825 Assert.True(symbol_j.
Equals(j),
"expect symbol_j and j to be equivalent");
826 Assert.True(symbol_j.
Equals(db.
GetSet(
"j")),
"expect symbol_j and db.GetSet(\"j\") to be equivalent");
828 Assert.False(symbol_j.
Equals(db.
GetSet(
"i")),
"symbol_j and db.GetSet(\"i\") are not equivalent");
829 Assert.False(symbol_j.
Equals(db.
GetParameter(
"a")),
"symbol_j and db.GetParameter(\"a\") are not equivalent");
830 Assert.False(symbol_j.
Equals(db.
GetVariable(
"x")),
"symbol_j and db.GetVariable(\"x\") are not equivalent");
831 Assert.False(symbol_j.
Equals(db.
GetEquation(
"cost")),
"symbol_j and db.GetEquation(\"cost\") are not equivalent");
837 Assert.True(symbol_a.
Equals(a),
"expect symbol_a and a to be equivalent");
838 Assert.True(symbol_a.
Equals(db.
GetParameter(
"a")),
"expect symbol_a and db.GetParameter(\"a\") to be equivalent");
840 Assert.False(symbol_a.
Equals(db.
GetSet(
"i")),
"symbol_a and db.GetSet(\"i\") are not equivalent");
841 Assert.False(symbol_a.
Equals(db.
GetParameter(
"b")),
"symbol_a and db.GetParameter(\"b\") are not equivalent");
842 Assert.False(symbol_a.
Equals(db.
GetVariable(
"x")),
"symbol_a and db.getVariable(\"x\") are not equivalent");
843 Assert.False(symbol_a.
Equals(db.
GetEquation(
"cost")),
"symbol_a and db.GetEquation(\"cost\") are not equivalent");
849 Assert.True(symbol_z.
Equals(z),
"expect symbol_z and z to be equivalent");
850 Assert.True(symbol_z.
Equals(db.
GetVariable(
"z")),
"expect symbol_z and db.getVariable(\"z\") to be equivalent");
852 Assert.False(symbol_z.
Equals(db.
GetSet(
"i")),
"symbol_z and db.GetSet(\"i\") are not equivalent");
853 Assert.False(symbol_z.
Equals(db.
GetParameter(
"a")),
"symbol_z and db.GetParameter(\"a\") are not equivalent");
854 Assert.False(symbol_z.
Equals(db.
GetVariable(
"x")),
"symbol_z and db.getVariable(\"x\") are not equivalent");
855 Assert.False(symbol_z.
Equals(db.
GetEquation(
"cost")),
"symbol_z and db.GetEquation(\"cost\") are not equivalent");
862 Assert.True(x1.
Equals(x2),
"expect x1 and x2 to be equivalent");
864 Assert.True(x1.
Equals(x3),
"expect x1 and x3 to be equivalent");
865 Assert.True(x1 == x3,
"expect x1 and x3 with the same memory reference");
867 Assert.AreEqual(db.
NrSymbols, numberOfSymbols,
"expect number of records in database remains the same after a few queries");
868 logger.Debug(
"Exiting TestGAMSSymbol | testEquivalentSymbol");
872 public void testEquivalentSymbol_IteratingSymbol()
874 logger.Debug(
"Entering TestGAMSSymbol | testEquivalentSymbol_IteratingSymbol");
877 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testEquivalentSymbol_IteratingSymbol";
896 if (symbol.
Name.Equals(
"i"))
899 rec.Text =
"new explanatory text for i";
900 Assert.True(symbol.
Equals(i),
"expect iterating symbol and i to be equivalent");
901 Assert.True(rec.
Text.Equals(i.FirstRecord().Text),
"expect iterating symbol and i to be equivalent");
903 else if (symbol.
Name.Equals(
"b"))
907 Assert.True(symbol.
Equals(b),
"expect iterating symbol and b to be equivalent");
908 Assert.True(rec.
Value == b.FirstRecord().Value,
"expect iterating symbol and b to be equivalent");
910 else if (symbol.
Name.Equals(
"d"))
914 Assert.True(symbol.
Equals(d),
"expect iterating symbol and d to be equivalent");
915 Assert.True(rec.
Value == d.LastRecord().Value,
"expect iterating symbol and d to be equivalent");
917 else if (symbol.
Name.Equals(
"f"))
921 Assert.True(symbol.
Equals(f),
"expect iterating symbol and f to be equivalent");
922 Assert.True(rec.
Value == f.FirstRecord().Value,
"expect iterating symbol and d to be equivalent");
924 else if (symbol.
Name.Equals(
"x"))
928 Assert.True(symbol.
Equals(x),
"expect iterating symbol and x to be equivalent");
929 Assert.True(rec.
Level == x.FirstRecord().Level,
"expect iterating symbol and x to be equivalent");
931 else if (symbol.
Name.Equals(
"supply"))
935 Assert.True(symbol.
Equals(supply),
"expect iterating symbol and supply to be equivalent");
936 Assert.True(rec.
Level == supply.FirstRecord().Level,
"expect iterating symbol and supply to be equivalent");
939 logger.Debug(
"Exiting TestGAMSSymbol | testEquivalentSymbol_IteratingSymbol");
943 public void testEquivalentSymbol_CopiedSymbol()
945 logger.Debug(
"Entering TestGAMSSymbol | testEquivalentSymbol_CopiedSymbol");
948 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testEquivalentSymbol_CopiedSymbol";
977 logger.Debug(
"Exiting TestGAMSSymbol | testEquivalentSymbol_CopiedSymbol");
981 public void testEquivalentSymbol_SameSymbolFromOriginalDatabase()
983 logger.Debug(
"Entering TestGAMSSymbol | testEquivalentSymbol_SameSymbolFromOriginalDatabase");
985 String testDir = HouseKeeper.gamsWorkingDir + Path.DirectorySeparatorChar +
"testEquivalentSymbol_SameSymbolFromOriginalDatabase";
998 Assert.False(i1.
Equals(i2),
"sets with same name from different databases are not equivalent");
1004 Assert.False(j1.
Equals(j2),
"sets with same name from different databases are not equivalent");
1010 Assert.False(b1.
Equals(b2),
"parameters with same name from different databases are not equivalent");
1016 Assert.False(x1.
Equals(x2),
"variables with same name from different databases are not equivalent");
1022 Assert.False(d1.
Equals(d2),
"equations with same name from different databases are not equivalent");
1027 logger.Debug(
"Exiting TestGAMSSymbol | testEquivalentSymbol_SameSymbolFromOriginalDatabase");
GAMSVariable GetVariable(string variableIdentifier)
GAMSSet AddSet(string identifier, int dimension, string explanatoryText="", SetType setType=SetType.multi)
GAMSParameter GetParameter(string parameterIdentifier)
GAMSSet GetSet(string setIdentifier)
GAMSVariable AddVariable(string identifier, int dimension, VarType varType, string explanatoryText="")
GAMSEquation GetEquation(string equationIdentifier)
GAMSEquation AddEquation(string identifier, int dimension, EquType equType, string explanatoryText="")
new GAMSEquationRecord FirstRecord()
new GAMSEquationRecord LastRecord()
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)
new GAMSParameterRecord LastRecord()
new GAMSParameterRecord FindRecord(params string[] keys)
new GAMSParameterRecord FirstRecord()
new GAMSSetRecord AddRecord(params string[] keys)
new GAMSSetRecord LastRecord()
new GAMSSetRecord FirstRecord()
new GAMSSetRecord MergeRecord(params string[] keys)
new GAMSSetRecord FindRecord(params string[] keys)
bool DeleteRecord(params string[] keys)
void CopySymbol(GAMSSymbol target)
override bool Equals(object obj)
new GAMSVariableRecord FindRecord(params string[] keys)
new GAMSVariableRecord FirstRecord()
GAMSJob AddJobFromGamsLib(string model, GAMSCheckpoint checkpoint=null, string jobName=null)
GAMSDatabase AddDatabase(string databaseName=null, string inModelName=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