[7465] | 1 | using System;
|
---|
| 2 | using System.Text;
|
---|
| 3 | using HeuristicLab.Problems.Instances.TSPLIB;
|
---|
| 4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 5 |
|
---|
[7470] | 6 | namespace UnitTests {
|
---|
[7465] | 7 | [TestClass()]
|
---|
| 8 | public class TSPLIBInstanceProviderTest {
|
---|
[7470] | 9 |
|
---|
[7465] | 10 | [TestMethod()]
|
---|
| 11 | public void GetTSPLIBTSPInstanceTest() {
|
---|
[7470] | 12 | var target = new TSPLIBTSPInstanceProvider();
|
---|
[7465] | 13 | StringBuilder erroneousInstances = new StringBuilder();
|
---|
| 14 | int count = 0;
|
---|
| 15 | foreach (var id in target.GetInstanceDescriptors()) {
|
---|
| 16 | try {
|
---|
| 17 | target.GetInstance(id);
|
---|
| 18 | } catch (Exception ex) {
|
---|
| 19 | erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
|
---|
| 20 | }
|
---|
| 21 | count++;
|
---|
| 22 | }
|
---|
| 23 | Assert.IsTrue(count > 0, "No problem instances were found.");
|
---|
| 24 | Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
|
---|
| 25 | }
|
---|
[7470] | 26 |
|
---|
| 27 | [TestMethod()]
|
---|
| 28 | public void GetTSPLIBATSPInstanceTest() {
|
---|
| 29 | var target = new TSPLIBATSPInstanceProvider();
|
---|
| 30 | StringBuilder erroneousInstances = new StringBuilder();
|
---|
| 31 | int count = 0;
|
---|
| 32 | foreach (var id in target.GetInstanceDescriptors()) {
|
---|
| 33 | try {
|
---|
| 34 | target.GetInstance(id);
|
---|
| 35 | } catch (Exception ex) {
|
---|
| 36 | erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
|
---|
| 37 | }
|
---|
| 38 | count++;
|
---|
| 39 | }
|
---|
| 40 | Assert.IsTrue(count > 0, "No problem instances were found.");
|
---|
| 41 | Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | [TestMethod()]
|
---|
| 45 | public void GetTSPLIBCVRPInstanceTest() {
|
---|
| 46 | var target = new TSPLIBCVRPInstanceProvider();
|
---|
| 47 | StringBuilder erroneousInstances = new StringBuilder();
|
---|
| 48 | int count = 0;
|
---|
| 49 | foreach (var id in target.GetInstanceDescriptors()) {
|
---|
| 50 | try {
|
---|
| 51 | target.GetInstance(id);
|
---|
| 52 | } catch (Exception ex) {
|
---|
| 53 | erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
|
---|
| 54 | }
|
---|
| 55 | count++;
|
---|
| 56 | }
|
---|
| 57 | Assert.IsTrue(count > 0, "No problem instances were found.");
|
---|
| 58 | Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
|
---|
| 59 | }
|
---|
[7465] | 60 | }
|
---|
| 61 | }
|
---|