Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11287


Ignore:
Timestamp:
08/19/14 15:52:56 (10 years ago)
Author:
pfleck
Message:

#2225
Fixed unit test for VRP instances.

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs

    r11286 r11287  
    3737
    3838    protected override void importButton_Click(object sender, EventArgs e) {
    39       var provider = Content as IVRPInstanceProvider<T>;
     39      var provider = Content as IVRPInstanceProvider;
    4040      if (provider != null) {
    4141        using (var dialog = new VRPImportDialog(Content.Name)) {
     
    4343            var instance = provider.Import(dialog.VRPFileName, dialog.TourFileName);
    4444            try {
    45               GenericConsumer.Load(instance);
     45              GenericConsumer.Load(instance as T);
    4646              instancesComboBox.SelectedIndex = -1;
    4747            } catch (Exception ex) {
     
    5454
    5555    protected override void exportButton_Click(object sender, EventArgs e) {
    56       var provider = Content as IVRPInstanceProvider<T>;
     56      var provider = Content as IVRPInstanceProvider;
    5757      if (provider != null) {
    5858        if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/IVRPInstanceProvider.cs

    r11286 r11287  
    2121
    2222namespace HeuristicLab.Problems.Instances.VehicleRouting {
    23   public interface IVRPInstanceProvider<T> where T : IVRPData {
     23  public interface IVRPInstanceProvider {
    2424    bool CanImportData { get; }
    25     T Import(string vrpFile, string tourFile);
     25    IVRPData Import(string vrpFile, string tourFile);
    2626
    2727    bool CanExportData { get; }
    28     void Export(T instance, string path);
     28    void Export(IVRPData instance, string path);
    2929  }
    3030}
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/VRPInstanceProvider.cs

    r11286 r11287  
    2929
    3030namespace HeuristicLab.Problems.Instances.VehicleRouting {
    31   public abstract class VRPInstanceProvider<T> : ProblemInstanceProvider<T>, IVRPInstanceProvider<T> where T : IVRPData {
     31  public abstract class VRPInstanceProvider<T> : ProblemInstanceProvider<T>, IVRPInstanceProvider where T : IVRPData {
    3232    protected abstract string FileName { get; }
    3333
     
    107107    protected abstract T LoadData(Stream stream);
    108108
    109     public T Import(string vrpFile, string tourFile) {
     109    public IVRPData Import(string vrpFile, string tourFile) {
    110110      var data = ImportData(vrpFile);
    111111      if (!String.IsNullOrEmpty(tourFile)) {
     
    115115    }
    116116
    117     public void Export(T instance, string path) {
    118       ExportData(instance, path);
     117    public void Export(IVRPData instance, string path) {
     118      ExportData((T)instance, path);
    119119    }
    120120
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.VehicleRouting-3.4/VRPInstancesTest.cs

    r11171 r11287  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Text;
    25 using HeuristicLab.PluginInfrastructure;
    26 using HeuristicLab.Problems.Instances.VehicleRouting;
     26using HeuristicLab.Problems.Instances;
     27using HeuristicLab.Tests;
    2728using Microsoft.VisualStudio.TestTools.UnitTesting;
    2829
     
    3031  [TestClass]
    3132  public class VRPInstancesTest {
     33    [ClassInitialize]
     34    public static void MyClassInitialize(TestContext testContext) {
     35      PluginLoader.Assemblies.Any();
     36    }
     37
    3238    [TestMethod]
    3339    [TestCategory("Problems.VehicleRouting")]
    3440    [TestProperty("Time", "long")]
    3541    public void TestVRPInstances() {
    36       var providers = ApplicationManager.Manager.GetInstances<VRPInstanceProvider>();
    3742      var vrp = new VehicleRoutingProblem();
     43      var providers = ProblemInstanceManager.GetProviders(vrp);
    3844      var failedInstances = new StringBuilder();
    3945
     
    4147
    4248      foreach (var provider in providers) {
    43         var instances = provider.GetDataDescriptors();
     49        IEnumerable<IDataDescriptor> instances = ((dynamic)provider).GetDataDescriptors();
    4450        Assert.IsTrue(instances.Any(), "No instances could be found.");
    4551
     
    4753          try {
    4854            // throws InvalidOperationException if zero or more than one interpreter is found
    49             vrp.Load(provider.LoadData(instance));
     55            ((dynamic)vrp).Load(((dynamic)provider).LoadData(instance));
    5056          } catch (Exception exc) {
    5157            failedInstances.AppendLine(instance + ": " + exc.Message);
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r11091 r11287  
    330330      <Private>False</Private>
    331331    </Reference>
     332    <Reference Include="Microsoft.CSharp" />
    332333    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
    333334      <Private>false</Private>
Note: See TracChangeset for help on using the changeset viewer.