Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs @ 5234

Last change on this file since 5234 was 5155, checked in by cneumuel, 14 years ago

#1233

  • minor changes
File size: 2.3 KB
Line 
1using System;
2using System.Text;
3using System.Collections.Generic;
4using System.Linq;
5using Microsoft.VisualStudio.TestTools.UnitTesting;
6using HeuristicLab.Services.Hive.Common.DataTransfer;
7using HeuristicLab.Services.Hive.Common.ServiceContracts;
8using HeuristicLab.Clients.Hive.Slave.Tests;
9using HeuristicLab.Clients.Hive;
10using HeuristicLab.Services.Hive.DataAccess;
11
12namespace 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));
47    }
48
49    [TestMethod]
50    public void TestSlaveDao() {
51      IHiveDao dao = ServiceLocator.Instance.HiveDao;
52      DT.SlaveGroup slaveGroup = new DT.SlaveGroup() {
53        Name = "Test"
54      };
55      slaveGroup.Id = dao.AddSlaveGroup(slaveGroup);
56
57      DT.Slave slave = new DT.Slave() {
58        Name = "Test"
59      };
60      slave.Id= dao.AddSlave(slave);
61
62      dao.DeleteSlave(slave.Id);
63      dao.DeleteSlaveGroup(slaveGroup.Id);
64    }
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    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.