#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Parameters;
using HeuristicLab.Problems.DataAnalysis;
using HeuristicLab_33.Tests;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace HeuristicLab.PluginInfrastructure.Tests {
///
/// Summary description for TypeDiscoveryTest
///
[TestClass]
public class TypeDiscoveryTest {
public TypeDiscoveryTest() { }
private TestContext testContextInstance;
///
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///
public TestContext TestContext {
get { return testContextInstance; }
set { testContextInstance = value; }
}
public static void MyClassInitialize(TestContext testContext) {
PluginLoader.Assemblies.Any();
}
[TestMethod]
public void IsSubTypeOfTest() {
Assert.IsTrue(typeof(int).IsSubTypeOf(typeof(object)));
Assert.IsTrue(typeof(IntValue).IsSubTypeOf(typeof(IItem)));
Assert.IsTrue(typeof(List).IsSubTypeOf(typeof(object)));
Assert.IsTrue(typeof(List).IsSubTypeOf(typeof(IList)));
Assert.IsTrue(typeof(List<>).IsSubTypeOf(typeof(IList)));
Assert.IsFalse(typeof(NamedItemCollection<>).IsSubTypeOf(typeof(ICollection)));
Assert.IsFalse(typeof(NamedItemCollection<>).IsSubTypeOf(typeof(ICollection)));
Assert.IsTrue(typeof(List).IsSubTypeOf(typeof(IList)));
Assert.IsFalse(typeof(IList).IsSubTypeOf(typeof(IList)));
Assert.IsTrue(typeof(List).IsSubTypeOf(typeof(IList)));
Assert.IsFalse(typeof(ItemList<>).IsSubTypeOf(typeof(IList)));
Assert.IsFalse(typeof(ItemList<>).IsSubTypeOf(typeof(List)));
Assert.IsFalse(typeof(List).IsSubTypeOf(typeof(List<>)));
Assert.IsTrue(typeof(List<>).IsSubTypeOf(typeof(IList<>)));
Assert.IsTrue(typeof(ItemList<>).IsSubTypeOf(typeof(IList<>)));
Assert.IsTrue(typeof(NamedItemCollection<>).IsSubTypeOf(typeof(IItemCollection<>)));
Assert.IsFalse(typeof(List).IsSubTypeOf(typeof(IList<>)));
}
[TestMethod]
public void BuildTypeTest() {
Assert.AreEqual(typeof(List<>).BuildType(typeof(List<>)), typeof(List<>));
Assert.AreEqual(typeof(List).BuildType(typeof(List<>)), typeof(List));
Assert.AreEqual(typeof(List<>).BuildType(typeof(List)), typeof(List));
Assert.AreEqual(typeof(ICollection<>).BuildType(typeof(List<>)), typeof(ICollection<>));
Assert.AreEqual(typeof(ICollection).BuildType(typeof(List<>)), typeof(ICollection));
Assert.AreEqual(typeof(ICollection<>).BuildType(typeof(List)), typeof(ICollection));
Assert.AreEqual(typeof(ItemCollection<>).BuildType(typeof(ICollection)), null);
Assert.AreEqual(typeof(ItemCollection<>).BuildType(typeof(Dictionary)), null);
Assert.AreEqual(typeof(ItemCollection<>).BuildType(typeof(ICollection)), typeof(ItemCollection));
Assert.AreEqual(typeof(FixedValueParameter<>).BuildType(typeof(ItemCollection)), null);
Assert.AreEqual(typeof(IFixedValueParameter<>).BuildType(typeof(ItemCollection)), typeof(IFixedValueParameter));
Assert.AreEqual(typeof(IFixedValueParameter<>).BuildType(typeof(ItemCollection)), typeof(IFixedValueParameter));
}
}
}