Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/Tests/UnitTest.cs @ 4384

Last change on this file since 4384 was 4384, checked in by swagner, 14 years ago

Worked on OKB data model (#1174)

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Text;
24using System.Collections.Generic;
25using System.Linq;
26using System.Data.Linq;
27using Microsoft.VisualStudio.TestTools.UnitTesting;
28using HeuristicLab.Services.OKB.DataAccess;
29
30namespace HeuristicLab.Services.OKB.DataAccess_33.Tests {
31  /// <summary>
32  /// Summary description for UnitTest1
33  /// </summary>
34  [TestClass]
35  public class UnitTest {
36    public UnitTest() {
37      //
38      // TODO: Add constructor logic here
39      //
40    }
41
42    private TestContext testContextInstance;
43
44    /// <summary>
45    ///Gets or sets the test context which provides
46    ///information about and functionality for the current test run.
47    ///</summary>
48    public TestContext TestContext {
49      get {
50        return testContextInstance;
51      }
52      set {
53        testContextInstance = value;
54      }
55    }
56
57    #region Additional test attributes
58    //
59    // You can use the following additional attributes as you write your tests:
60    //
61    // Use ClassInitialize to run code before running the first test in the class
62    // [ClassInitialize()]
63    // public static void MyClassInitialize(TestContext testContext) { }
64    //
65    // Use ClassCleanup to run code after all tests in a class have run
66    // [ClassCleanup()]
67    // public static void MyClassCleanup() { }
68    //
69    // Use TestInitialize to run code before running each test
70    // [TestInitialize()]
71    // public void MyTestInitialize() { }
72    //
73    // Use TestCleanup to run code after each test has run
74    // [TestCleanup()]
75    // public void MyTestCleanup() { }
76    //
77    #endregion
78
79    [TestMethod]
80    public void TestMethod1() {
81      using (OKBDataContext okb = new OKBDataContext()) {
82        okb.AlgorithmParameterIntValues.DeleteAllOnSubmit(okb.AlgorithmParameterIntValues);
83        okb.AlgorithmParameters.DeleteAllOnSubmit(okb.AlgorithmParameters);
84        okb.Experiments.DeleteAllOnSubmit(okb.Experiments);
85        okb.Algorithms.DeleteAllOnSubmit(okb.Algorithms);
86        okb.Problems.DeleteAllOnSubmit(okb.Problems);
87        okb.SolutionRepresentations.DeleteAllOnSubmit(okb.SolutionRepresentations);
88        okb.ProblemClasses.DeleteAllOnSubmit(okb.ProblemClasses);
89        okb.AlgorithmClasses.DeleteAllOnSubmit(okb.AlgorithmClasses);
90        okb.SubmitChanges();
91        AlgorithmClass ac = new AlgorithmClass() { Name = "AlgorithmClass" };
92        ProblemClass pc = new ProblemClass() { Name = "ProblemClass" };
93        SolutionRepresentation sr = new SolutionRepresentation() { Name = "SolutionRepresentation" };
94        Algorithm a = new Algorithm() { Name = "Alg", AlgorithmClass = ac, PlatformId = 1 };
95        Problem p = new Problem() { Name = "Prb", ProblemClass = pc, SolutionRepresentation = sr, PlatformId = 1 };
96        Experiment e = new Experiment() { Algorithm = a, Problem = p };
97        AlgorithmParameter ap = new AlgorithmParameter() { Name = "Param", Algorithm = a, DataTypeId = 1 };
98        ap.AlgorithmParameterIntValues.Add(new AlgorithmParameterIntValue() { AlgorithmParameterId = 0, Experiment = e, Value = 23 });
99        okb.AlgorithmClasses.InsertOnSubmit(ac);
100        okb.SubmitChanges();
101      }
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.