Skip to content

Commit 0c1fb2c

Browse files
committed
Simple parallelization support p.1
1 parent 24bfd66 commit 0c1fb2c

36 files changed

+2932
-2108
lines changed

Musoq.Evaluator.Tests/ArithmeticTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using System;
2+
using System.Threading.Tasks;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
24
using Musoq.Evaluator.Tests.Schema.Basic;
35

46
namespace Musoq.Evaluator.Tests;

Musoq.Evaluator.Tests/ComparsionsTests.cs renamed to Musoq.Evaluator.Tests/ComparisonTests.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Musoq.Evaluator.Tests;
77

88
[TestClass]
9-
public class ComparsionsTests : BasicEntityTestBase
9+
public class ComparisonTests : BasicEntityTestBase
1010
{
1111
[TestMethod]
1212
public void ArithmeticOpsGreaterTest()
@@ -60,9 +60,10 @@ public void ArithmeticOpsGreaterEqualTest()
6060
Assert.AreEqual(1, table.Columns.Count());
6161
Assert.AreEqual("City", table.Columns.ElementAt(0).ColumnName);
6262

63-
Assert.AreEqual(2, table.Count());
64-
Assert.AreEqual("WARSAW", table[0].Values[0]);
65-
Assert.AreEqual("CZESTOCHOWA", table[1].Values[0]);
63+
Assert.IsTrue(table.Count() == 2, "Table should have 2 entries");
64+
65+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "WARSAW"), "First entry should be 'WARSAW'");
66+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "CZESTOCHOWA"), "Second entry should be 'CZESTOCHOWA'");
6667
}
6768

6869
[TestMethod]
@@ -90,8 +91,8 @@ public void ArithmeticOpsEqualsTest()
9091
Assert.AreEqual("City", table.Columns.ElementAt(0).ColumnName);
9192

9293
Assert.AreEqual(2, table.Count());
93-
Assert.AreEqual("KATOWICE", table[0].Values[0]);
94-
Assert.AreEqual("BERLIN", table[1].Values[0]);
94+
Assert.IsTrue(table.Any(row => (string) row.Values[0] == "KATOWICE"), "Collection should contain KATOWICE");
95+
Assert.IsTrue(table.Any(row => (string) row.Values[0] == "BERLIN"), "Collection should contain BERLIN");
9596
}
9697

9798
[TestMethod]
@@ -117,10 +118,11 @@ public void ArithmeticOpsLessTest()
117118

118119
Assert.AreEqual(1, table.Columns.Count());
119120
Assert.AreEqual("City", table.Columns.ElementAt(0).ColumnName);
121+
122+
Assert.IsTrue(table.Count() == 2, "Table should have 2 entries");
120123

121-
Assert.AreEqual(2, table.Count());
122-
Assert.AreEqual("KATOWICE", table[0].Values[0]);
123-
Assert.AreEqual("BERLIN", table[1].Values[0]);
124+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "KATOWICE"), "First entry should be 'KATOWICE'");
125+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "BERLIN"), "Second entry should be 'BERLIN'");
124126
}
125127

126128

@@ -147,10 +149,11 @@ public void ArithmeticOpsLessEqualTest()
147149

148150
Assert.AreEqual(1, table.Columns.Count());
149151
Assert.AreEqual("City", table.Columns.ElementAt(0).ColumnName);
152+
153+
Assert.IsTrue(table.Count() == 3, "Table should have 3 entries");
150154

151-
Assert.AreEqual(3, table.Count());
152-
Assert.AreEqual("KATOWICE", table[0].Values[0]);
153-
Assert.AreEqual("BERLIN", table[1].Values[0]);
154-
Assert.AreEqual("MUNICH", table[2].Values[0]);
155+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "KATOWICE"), "First entry should be 'KATOWICE'");
156+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "BERLIN"), "Second entry should be 'BERLIN'");
157+
Assert.IsTrue(table.Any(entry => (string)entry.Values[0] == "MUNICH"), "Third entry should be 'MUNICH'");
155158
}
156159
}

Musoq.Evaluator.Tests/CouplingSyntaxTests.cs

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,23 @@ public void WhenSingleValueTableIsCoupledWithSchema_ShouldHaveAppropriateTypesTe
4444
Assert.AreEqual("Name", table.Columns.ElementAt(0).ColumnName);
4545
Assert.AreEqual(typeof(string), table.Columns.ElementAt(0).ColumnType);
4646

47-
Assert.AreEqual(4, table.Count);
48-
Assert.AreEqual("ABCAACBA", table[0].Values[0]);
49-
Assert.AreEqual("AAeqwgQEW", table[1].Values[0]);
50-
Assert.AreEqual("XXX", table[2].Values[0]);
51-
Assert.AreEqual("dadsqqAA", table[3].Values[0]);
47+
Assert.AreEqual(4, table.Count, "Result should contain exactly 4 strings");
48+
49+
var actualStrings = table
50+
.Select(row => (string)row.Values[0])
51+
.ToList();
52+
53+
Assert.IsTrue(actualStrings.Any(s => s == "ABCAACBA"),
54+
"Expected string 'ABCAACBA' not found in results");
55+
56+
Assert.IsTrue(actualStrings.Any(s => s == "AAeqwgQEW"),
57+
"Expected string 'AAeqwgQEW' not found in results");
58+
59+
Assert.IsTrue(actualStrings.Any(s => s == "XXX"),
60+
"Expected string 'XXX' not found in results");
61+
62+
Assert.IsTrue(actualStrings.Any(s => s == "dadsqqAA"),
63+
"Expected string 'dadsqqAA' not found in results");
5264
}
5365

5466
[TestMethod]
@@ -85,17 +97,22 @@ public void WhenTwoValuesTableIsCoupledWithSchema_ShouldHaveAppropriateTypesTest
8597
Assert.AreEqual(typeof(decimal), table.Columns.ElementAt(1).ColumnType);
8698

8799
Assert.AreEqual(4, table.Count);
88-
Assert.AreEqual("ABCAACBA", table[0].Values[0]);
89-
Assert.AreEqual(10m, table[0].Values[1]);
90-
91-
Assert.AreEqual("AAeqwgQEW", table[1].Values[0]);
92-
Assert.AreEqual(20m, table[1].Values[1]);
93-
94-
Assert.AreEqual("XXX", table[2].Values[0]);
95-
Assert.AreEqual(30m, table[2].Values[1]);
96-
97-
Assert.AreEqual("dadsqqAA", table[3].Values[0]);
98-
Assert.AreEqual(40m, table[3].Values[1]);
100+
101+
Assert.IsTrue(table.Any(row =>
102+
(string)row.Values[0] == "ABCAACBA" &&
103+
(decimal)row.Values[1] == 10m));
104+
105+
Assert.IsTrue(table.Any(row =>
106+
(string)row.Values[0] == "AAeqwgQEW" &&
107+
(decimal)row.Values[1] == 20m));
108+
109+
Assert.IsTrue(table.Any(row =>
110+
(string)row.Values[0] == "XXX" &&
111+
(decimal)row.Values[1] == 30m));
112+
113+
Assert.IsTrue(table.Any(row =>
114+
(string)row.Values[0] == "dadsqqAA" &&
115+
(decimal)row.Values[1] == 40m));
99116
}
100117

101118
[TestMethod]
@@ -140,12 +157,23 @@ public void WhenTwoTablesAreCoupledWithSchemas_ShouldHaveAppropriateTypesTest()
140157
Assert.AreEqual(1, table.Columns.Count());
141158
Assert.AreEqual("s2.Name", table.Columns.ElementAt(0).ColumnName);
142159
Assert.AreEqual(typeof(string), table.Columns.ElementAt(0).ColumnType);
143-
144-
Assert.AreEqual(4, table.Count);
145-
Assert.AreEqual("ABCAACBA", table[0].Values[0]);
146-
Assert.AreEqual("AAeqwgQEW", table[1].Values[0]);
147-
Assert.AreEqual("XXX", table[2].Values[0]);
148-
Assert.AreEqual("dadsqqAA", table[3].Values[0]);
160+
Assert.IsTrue(table.Count == 4, "Table should have 4 entries");
161+
162+
Assert.IsTrue(table.Any(entry =>
163+
(string)entry.Values[0] == "ABCAACBA"),
164+
"First entry should be 'ABCAACBA'");
165+
166+
Assert.IsTrue(table.Any(entry =>
167+
(string)entry.Values[0] == "AAeqwgQEW"),
168+
"Second entry should be 'AAeqwgQEW'");
169+
170+
Assert.IsTrue(table.Any(entry =>
171+
(string)entry.Values[0] == "XXX"),
172+
"Third entry should be 'XXX'");
173+
174+
Assert.IsTrue(table.Any(entry =>
175+
(string)entry.Values[0] == "dadsqqAA"),
176+
"Fourth entry should be 'dadsqqAA'");
149177
}
150178

151179
[TestMethod]
@@ -202,10 +230,15 @@ public void WhenDataSourceIsBasedOnAnotherDataSource_ShouldPass()
202230
Assert.AreEqual("Text", table.Columns.ElementAt(0).ColumnName);
203231
Assert.AreEqual(typeof(string), table.Columns.ElementAt(0).ColumnType);
204232

205-
Assert.AreEqual(2, table.Count);
233+
Assert.AreEqual(2, table.Count, "Result should contain exactly 2 test values");
234+
235+
Assert.IsTrue(table.Any(row =>
236+
(string)row.Values[0] == "test1"
237+
), "Expected value 'test1' not found in results");
206238

207-
Assert.AreEqual("test1", table[0].Values[0]);
208-
Assert.AreEqual("test2", table[1].Values[0]);
239+
Assert.IsTrue(table.Any(row =>
240+
(string)row.Values[0] == "test2"
241+
), "Expected value 'test2' not found in results");
209242
}
210243

211244
private class ParametersSchemaProvider : ISchemaProvider

0 commit comments

Comments
 (0)