Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8088 for trunk/sources


Ignore:
Timestamp:
06/22/12 11:25:12 (12 years ago)
Author:
mkommend
Message:

#1879: Corrected ToString unit test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs

    r7915 r8088  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
    2324using HeuristicLab.Core;
     
    2930  public class ToStringTest {
    3031
     32    private TestContext testContextInstance;
     33    /// <summary>
     34    ///Gets or sets the test context which provides
     35    ///information about and functionality for the current test run.
     36    ///</summary>
     37    public TestContext TestContext {
     38      get {
     39        return testContextInstance;
     40      }
     41      set {
     42        testContextInstance = value;
     43      }
     44    }
     45
    3146    // Use ClassInitialize to run code before running the first test in the class
    3247    [ClassInitialize]
     
    3752    [TestMethod]
    3853    public void TestToString() {
     54      bool success = true;
    3955      // just test for all IItems that the ToString method doesn't throw an exception
    4056      foreach (object item in ApplicationManager.Manager.GetInstances(typeof(IItem))) {
    41         item.ToString();
     57        try {
     58          item.ToString();
     59        }
     60        catch (Exception e) {
     61          TestContext.WriteLine(item.GetType() + " throws a " + e.GetType() + " in the ToString method.");
     62          success = false;
     63        }
    4264      }
     65      Assert.IsTrue(success, "There are potential errors in the ToString methods of  objects.");
    4366    }
    4467  }
Note: See TracChangeset for help on using the changeset viewer.