Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Tests/HeuristicLab-3.3/ContentViewTests.cs @ 16864

Last change on this file since 16864 was 16709, checked in by gkronber, 6 years ago

#2999 merged r16703 from trunk to stable

File size: 2.7 KB
RevLine 
[4490]1#region License Information
2/* HeuristicLab
[15584]3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[4490]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;
[4486]23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.MainForm;
26using HeuristicLab.PluginInfrastructure;
27using Microsoft.VisualStudio.TestTools.UnitTesting;
28
[9885]29namespace HeuristicLab.Tests {
[4486]30  [TestClass]
31  public class ContentViewTests {
32    [TestMethod]
[9885]33    [TestCategory("General")]
34    [TestCategory("Essential")]
35    [TestProperty("Time", "long")]
[4486]36    public void ContentViewAttributeTest() {
37      //get all non-generic and instantiable classes which implement IContentView
[7111]38      foreach (Type viewType in ApplicationManager.Manager.GetTypes(typeof(IContentView))) {
[16709]39        // jkarder: skip this test for the SymbolicDataAnalysisModelMathView (and for views that derive from it)
40        // reason: our new build agent cannot create an instance of this view due to the use of System.Windows.Forms.WebBrowser
41        if (typeof(HeuristicLab.Problems.DataAnalysis.Symbolic.Views.SymbolicDataAnalysisModelMathView).IsAssignableFrom(viewType))
42          continue;
43
[4486]44        //get all ContentAttributes on the instantiable view
45        foreach (ContentAttribute attribute in viewType.GetCustomAttributes(typeof(ContentAttribute), false).Cast<ContentAttribute>()) {
46          Assert.IsTrue(attribute.ContentType == typeof(IContent) || attribute.ContentType.GetInterfaces().Contains(typeof(IContent)),
47            "The type specified in the ContentAttribute of {0} must implement IContent.", viewType);
48        }
49        //check if view can handle null as content by calling OnContentChanged
50        IContentView view = (IContentView)Activator.CreateInstance(viewType);
[13246]51        var accessor = new PrivateObject(view);
[4486]52        try {
[13246]53          accessor.Invoke("OnContentChanged");
[16709]54        } catch (Exception ex) {
[4486]55          Assert.Fail(viewType.ToString() + Environment.NewLine + ex.Message);
56        }
57      }
58    }
59  }
60}
Note: See TracBrowser for help on using the repository browser.