Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/SlaveTest.cs @ 5106

Last change on this file since 5106 was 5104, checked in by ascheibe, 14 years ago

added some more functionality to the MockService #1233

File size: 1.6 KB
Line 
1using System;
2using System.Text;
3using System.Collections.Generic;
4using System.Linq;
5using Microsoft.VisualStudio.TestTools.UnitTesting;
6using HeuristicLab.Clients.Hive.Salve;
7using HeuristicLab.Services.Hive.Common;
8using HeuristicLab.Services.Hive.Common.ServiceContracts;
9using HeuristicLab.Clients.Common;
10
11namespace HeuristicLab.Clients.Hive.Slave.Tests {
12  [TestClass]
13  public class SlaveTest {
14
15    // Use ClassInitialize to run code before running the first test in the class
16    [ClassInitialize]
17    public static void MyClassInitialize(TestContext testContext) {
18      PluginLoader.pluginAssemblies.Any();     
19      ServiceLocator.Instance = new MockServiceLocator();
20    }
21
22    public List<List<MessageContainer>> CreateMsgs() {
23      List<List<MessageContainer>> allMsgs = new List<List<MessageContainer>>();
24      //get slave to fetch job
25      List<MessageContainer> msg = new List<MessageContainer>();
26      msg.Add(new MessageContainer(MessageContainer.MessageType.AquireJob));
27      allMsgs.Add(msg);
28
29      //do nothing
30      msg = new List<MessageContainer>();
31      allMsgs.Add(msg);
32
33      msg = new List<MessageContainer>();
34      msg.Add(new MessageContainer(MessageContainer.MessageType.ShutdownSlave));
35      allMsgs.Add(msg);
36      return allMsgs;
37    }
38
39    [TestMethod]
40    public void TestMethod1() {
41      using (Disposable<IHiveService> service = ServiceLocator.Instance.GetService()) {
42        ((MockHiveService)service.Obj).Messages = CreateMsgs();
43      }
44     
45      HeuristicLab.Clients.Hive.Salve.Core core = new Salve.Core();
46      core.Start();
47    }
48  }
49}
Note: See TracBrowser for help on using the repository browser.