public void StressTest() { AiBrain[] b = new AiBrain[StressTestSize]; AiState[] s = new AiState[StressTestSize]; DummyInterface dummy = new DummyInterface(); AiCore.InitCore(); Thread thread = new Thread(AiCore.Run); thread.Start(); for (int i = 0; i < StressTestSize; i++) { s[i] = new AiState(template, "0"); b[i] = new AiBrain(dummy, s[i]); AiCore.AddBrain(b[i]); } Thread.Sleep(1000); AiCore.Shutdown(); for (int i = 0; i < StressTestSize; i++) { Assert.AreEqual(10, ((Accumulator)s[i].nodes["0"]).val); } thread.Join(); }
public void TestMethod1() { AiCore.InitCore(); Thread thread = new Thread(AiCore.Run); thread.Start(); DummyInterface dummy = new DummyInterface(); AiBrain b1 = new AiBrain(dummy, state_1); AiBrain b2 = new AiBrain(dummy, state_2); AiCore.AddBrain(b1); AiCore.AddBrain(b2); Thread.Sleep(1000); AiCore.Shutdown(); Assert.AreEqual(1, ((Accumulator)state_1.nodes["0"]).val); Assert.AreEqual(1, ((Accumulator)state_2.nodes["0"]).val); thread.Join(); }
public void RemoveTest() { AiBrain[] b = new AiBrain[RemoveTestSize]; AiState[] s = new AiState[RemoveTestSize]; DummyInterface dummy = new DummyInterface(); AiCore.InitCore(); Thread thread = new Thread(AiCore.Run); thread.Start(); for (int i = 0; i < RemoveTestSize; i++) { s[i] = new AiState(template, "0"); b[i] = new AiBrain(dummy, s[i]); AiCore.AddBrain(b[i]); if (i > RemoveTestSize * parity) { AiCore.RemoveBrain(b[i]); } } Thread.Sleep(1000); AiCore.Shutdown(); for (int i = 0; i < RemoveTestSize; i++) { if (i > RemoveTestSize * parity) { Assert.IsFalse(AiCore.HasBrain(b[i])); } else { Assert.IsTrue(AiCore.HasBrain(b[i])); } } thread.Join(); }