using System; using System.Text; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using HeuristicLab.Clients.Hive.Salve; using HeuristicLab.Services.Hive.Common; using HeuristicLab.Services.Hive.Common.ServiceContracts; using HeuristicLab.Clients.Common; namespace HeuristicLab.Clients.Hive.Slave.Tests { [TestClass] public class SlaveTest { // Use ClassInitialize to run code before running the first test in the class [ClassInitialize] public static void MyClassInitialize(TestContext testContext) { PluginLoader.pluginAssemblies.Any(); ServiceLocator.Instance = new MockServiceLocator(); } public List> CreateMsgs() { List> allMsgs = new List>(); //get slave to fetch job List msg = new List(); msg.Add(new MessageContainer(MessageContainer.MessageType.AquireJob)); allMsgs.Add(msg); //do nothing msg = new List(); allMsgs.Add(msg); msg = new List(); msg.Add(new MessageContainer(MessageContainer.MessageType.ShutdownSlave)); allMsgs.Add(msg); return allMsgs; } [TestMethod] public void TestMethod1() { using (Disposable service = ServiceLocator.Instance.GetService()) { ((MockHiveService)service.Obj).Messages = CreateMsgs(); } HeuristicLab.Clients.Hive.Salve.Core core = new Salve.Core(); core.Start(); } } }