Skip to content

Commit 8507e6b

Browse files
committed
Added new test for global cost and fix the rest of tests.
1 parent af9f0f9 commit 8507e6b

1 file changed

Lines changed: 47 additions & 4 deletions

File tree

MultiagentAlgorithm/MultiagentAlgorithm.Test/GlobalCostTest.cs

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public class GlobalCostTest
129129

130130

131131
[TestMethod]
132-
public void GraphMyciel4_CalculateGlobalCostFunction_Success()
132+
public void GraphMyciel4_CalculateGlobalCostFunction_34()
133133
{
134134
var loaderMock = new Mock<IDataLoader>();
135135
loaderMock.Setup(m => m.LoadData()).Returns(_myciel4);
@@ -168,7 +168,50 @@ public void GraphMyciel4_CalculateGlobalCostFunction_Success()
168168

169169
var globalCost = graph.GetGlobalCostFunction();
170170

171-
Assert.AreEqual(68, globalCost);
171+
Assert.AreEqual(34, globalCost);
172+
}
173+
174+
[TestMethod]
175+
public void GraphMyciel4_CalculateGlobalCostFunction_28()
176+
{
177+
var loaderMock = new Mock<IDataLoader>();
178+
loaderMock.Setup(m => m.LoadData()).Returns(_myciel4);
179+
180+
var randomMock = new StubRandom()
181+
{
182+
NextInt32Int32 = (a, b) => 1
183+
};
184+
185+
var graph = new DimacsGraph(loaderMock.Object, randomMock);
186+
graph.InitializeGraph();
187+
188+
graph.Vertices[0].Color = 1;
189+
graph.Vertices[1].Color = 1;
190+
graph.Vertices[2].Color = 1;
191+
graph.Vertices[3].Color = 0;
192+
graph.Vertices[4].Color = 1;
193+
graph.Vertices[5].Color = 0;
194+
graph.Vertices[6].Color = 0;
195+
graph.Vertices[7].Color = 0;
196+
graph.Vertices[8].Color = 0;
197+
graph.Vertices[9].Color = 0;
198+
graph.Vertices[10].Color = 0;
199+
graph.Vertices[11].Color = 0;
200+
graph.Vertices[12].Color = 1;
201+
graph.Vertices[13].Color = 1;
202+
graph.Vertices[14].Color = 1;
203+
graph.Vertices[15].Color = 0;
204+
graph.Vertices[16].Color = 0;
205+
graph.Vertices[17].Color = 1;
206+
graph.Vertices[18].Color = 1;
207+
graph.Vertices[19].Color = 1;
208+
graph.Vertices[20].Color = 0;
209+
graph.Vertices[21].Color = 0;
210+
graph.Vertices[22].Color = 1;
211+
212+
var globalCost = graph.GetGlobalCostFunction();
213+
214+
Assert.AreEqual(28, globalCost);
172215
}
173216

174217
[TestMethod]
@@ -195,7 +238,7 @@ public void GraphMetisTest_CalculateGlobalCostFunction_Success()
195238

196239
var globalCost = graph.GetGlobalCostFunction();
197240

198-
Assert.AreEqual(6, globalCost);
241+
Assert.AreEqual(3, globalCost);
199242
}
200243

201244
[TestMethod]
@@ -240,7 +283,7 @@ public void GraphQueen5_5_CalculateGlobalCostFunction_Success()
240283

241284
var globalCost = graph.GetGlobalCostFunction();
242285

243-
Assert.AreEqual(168, globalCost);
286+
Assert.AreEqual(84, globalCost);
244287
}
245288
}
246289
}

0 commit comments

Comments
 (0)