Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using HEAL.Attic;
|
---|
5 | using HeuristicLab.PluginInfrastructure;
|
---|
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Tests.Persistence.Attic {
|
---|
9 | [TestClass]
|
---|
10 | public class PersistenceConsistencyChecks {
|
---|
11 | [TestCategory("Persistence.Attic")]
|
---|
12 | [TestCategory("Essential")]
|
---|
13 | [TestProperty("Time", "short")]
|
---|
14 | [TestMethod]
|
---|
15 | public void CheckDuplicateGUIDs() {
|
---|
16 | // easy to produce duplicate GUIDs with copy&paste
|
---|
17 |
|
---|
18 | var dict = new Dictionary<Guid, string>();
|
---|
19 | var duplicates = new Dictionary<string, string>();
|
---|
20 | //get all non-generic and instantiable classes which implement IContentView
|
---|
21 | foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(object))) {
|
---|
22 | var attr = StorableTypeAttribute.GetStorableTypeAttribute(type);
|
---|
23 | if (attr == null)
|
---|
24 | continue;
|
---|
25 |
|
---|
26 | foreach (var guid in attr.Guids) {
|
---|
27 | if (!dict.ContainsKey(guid)) {
|
---|
28 | dict.Add(guid, type.FullName);
|
---|
29 | } else {
|
---|
30 | duplicates.Add(type.FullName, dict[guid]);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | foreach (var kvp in duplicates) {
|
---|
36 | Console.WriteLine($"{kvp.Key} has same GUID as {kvp.Value}");
|
---|
37 | }
|
---|
38 | if (duplicates.Any()) Assert.Fail("Duplicate GUIDs found.");
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.