[5106] | 1 | using System;
|
---|
| 2 | using System.Text;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
| 5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 6 | using HeuristicLab.Services.Hive.Common.DataTransfer;
|
---|
| 7 | using HeuristicLab.Services.Hive.Common.ServiceContracts;
|
---|
| 8 | using HeuristicLab.Clients.Hive.Slave.Tests;
|
---|
| 9 | using HeuristicLab.Clients.Hive;
|
---|
| 10 | using HeuristicLab.Services.Hive.DataAccess;
|
---|
| 11 |
|
---|
| 12 | namespace HeuristicLab.Services.Hive.Tests {
|
---|
| 13 | using DA = HeuristicLab.Services.Hive.DataAccess;
|
---|
| 14 | using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
|
---|
| 15 |
|
---|
| 16 | [TestClass]
|
---|
| 17 | public class DaoTests {
|
---|
| 18 |
|
---|
| 19 | [ClassInitialize]
|
---|
| 20 | public static void MyClassInitialize(TestContext testContext) {
|
---|
| 21 | PluginLoader.pluginAssemblies.Any();
|
---|
| 22 | ServiceLocator.Instance = new MockServiceLocator(ServiceLocator.Instance);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | private IHiveService GetLocalService() {
|
---|
| 26 | return new HiveService();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | [TestMethod]
|
---|
| 30 | public void TestJobDao() {
|
---|
| 31 | IHiveDao dao = ServiceLocator.Instance.HiveDao;
|
---|
| 32 |
|
---|
| 33 | DT.Job job1 = new DT.Job();
|
---|
| 34 | job1.DateCreated = DateTime.Now;
|
---|
| 35 | job1.Id = dao.AddJob(job1);
|
---|
| 36 |
|
---|
| 37 | DT.Job job1loaded = dao.GetJob(job1.Id);
|
---|
| 38 | Assert.AreEqual(job1.Id, job1loaded.Id);
|
---|
| 39 | Assert.AreEqual(job1.CoresNeeded, job1loaded.CoresNeeded);
|
---|
| 40 | Assert.AreEqual(null, job1loaded.DateCalculated);
|
---|
| 41 | Assert.AreEqual(job1.DateCreated.ToString(), job1loaded.DateCreated.ToString());
|
---|
| 42 | Assert.AreEqual(null, job1loaded.DateFinished);
|
---|
| 43 |
|
---|
| 44 | dao.DeleteJob(job1.Id);
|
---|
| 45 |
|
---|
| 46 | Assert.AreEqual(null, dao.GetJob(job1.Id));
|
---|
[5155] | 47 | }
|
---|
[5106] | 48 |
|
---|
[5155] | 49 | [TestMethod]
|
---|
| 50 | public void TestSlaveDao() {
|
---|
| 51 | IHiveDao dao = ServiceLocator.Instance.HiveDao;
|
---|
[5106] | 52 | DT.SlaveGroup slaveGroup = new DT.SlaveGroup() {
|
---|
| 53 | Name = "Test"
|
---|
| 54 | };
|
---|
| 55 | slaveGroup.Id = dao.AddSlaveGroup(slaveGroup);
|
---|
| 56 |
|
---|
[5155] | 57 | DT.Slave slave = new DT.Slave() {
|
---|
| 58 | Name = "Test"
|
---|
| 59 | };
|
---|
| 60 | slave.Id= dao.AddSlave(slave);
|
---|
| 61 |
|
---|
| 62 | dao.DeleteSlave(slave.Id);
|
---|
[5106] | 63 | dao.DeleteSlaveGroup(slaveGroup.Id);
|
---|
| 64 | }
|
---|
[5155] | 65 |
|
---|
| 66 | [TestMethod]
|
---|
| 67 | public void TestJobDaoWaiting() {
|
---|
| 68 | IHiveDao dao = ServiceLocator.Instance.HiveDao;
|
---|
| 69 |
|
---|
| 70 | DT.Job job = new DT.Job();
|
---|
| 71 | job.DateCreated = DateTime.Now;
|
---|
| 72 | job.JobState = JobState.Waiting;
|
---|
| 73 | job.Id = dao.AddJob(job);
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | }
|
---|
[5106] | 77 | }
|
---|
| 78 | }
|
---|