Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9778


Ignore:
Timestamp:
07/26/13 13:32:27 (11 years ago)
Author:
abeham
Message:

#2088: Added test attributes to persistence unit tests

Location:
trunk/sources/HeuristicLab.Tests/HeuristicLab.Persistence-3.3
Files:
2 edited

Legend:

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

    r9764 r9778  
    6868    }
    6969  }
    70 
    71   /*  [TestClass]
    72     public class AttributeTest {
    73 
    74       [TestMethod]
    75       public void SimpleStorableAttributeTest() {
    76         DemoClass t = new DemoClass();
    77         IEnumerable<DataMemberAccessor> accessorList = StorableAttribute.GetStorableAccessors(t);
    78         Dictionary<string, DataMemberAccessor> accessors = new Dictionary<string, DataMemberAccessor>();
    79         foreach (var a in accessorList)
    80           accessors.Add(a.Name, a);
    81         Assert.IsTrue(accessors.ContainsKey("TestProperty"));
    82         Assert.IsTrue(accessors.ContainsKey("x"));
    83         Assert.IsFalse(accessors.ContainsKey("y"));
    84         object o = new object();
    85         t.o = o;
    86         Assert.AreSame(accessors["TestProperty"].Get(), o);
    87         t.x = 12;
    88         Assert.AreEqual(accessors["x"].Get(), 12);
    89         t.y = 312890;
    90         accessors["TestProperty"].Set(null);
    91         Assert.IsNull(t.o);
    92         accessors["x"].Set(123);
    93         Assert.AreEqual(t.x, 123);
    94       }
    95 
    96       [TestMethod]
    97       public void TestInheritance() {
    98         New n = new New();
    99         var accessors = StorableAttribute.GetStorableAccessors(n);
    100         var accessDict = new Dictionary<string, DataMemberAccessor>();
    101         foreach (var accessor in accessors) // assert uniqueness
    102           accessDict.Add(accessor.Name, accessor);
    103         Assert.IsTrue(accessDict.ContainsKey(typeof(New).FullName + ".Name"));
    104         Assert.IsTrue(accessDict.ContainsKey(typeof(Override).FullName + ".Name"));
    105         Assert.AreEqual("New", accessDict[typeof(New).FullName + ".Name"].Get());
    106         Assert.AreEqual("Override", accessDict[typeof(Override).FullName + ".Name"].Get());
    107       }
    108 
    109     }*/
    110 
    11170}
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs

    r9764 r9778  
    286286
    287287    [TestMethod]
     288    [TestCategory("Persistence")]
     289    [TestProperty("Time", "short")]
    288290    public void ComplexStorable() {
    289291      Root r = InitializeComplexStorable();
     
    294296
    295297    [TestMethod]
     298    [TestCategory("Persistence")]
     299    [TestProperty("Time", "short")]
    296300    public void ComplexEasyStorable() {
    297301      Root r = InitializeComplexStorable();
     
    383387
    384388    [TestMethod]
     389    [TestCategory("Persistence")]
     390    [TestProperty("Time", "short")]
    385391    public void SelfReferences() {
    386392      C c = new C();
     
    408414
    409415    [TestMethod]
     416    [TestCategory("Persistence")]
     417    [TestProperty("Time", "short")]
    410418    public void ArrayCreation() {
    411419      ArrayList[] arrayListArray = new ArrayList[4];
     
    435443
    436444    [TestMethod]
     445    [TestCategory("Persistence")]
     446    [TestProperty("Time", "short")]
    437447    public void CustomSerializationProperty() {
    438448      Manager m = new Manager();
     
    449459
    450460    [TestMethod]
     461    [TestCategory("Persistence")]
     462    [TestProperty("Time", "short")]
    451463    public void Primitives() {
    452464      PrimitivesTest sdt = new PrimitivesTest();
     
    459471
    460472    [TestMethod]
     473    [TestCategory("Persistence")]
     474    [TestProperty("Time", "short")]
    461475    public void MultiDimensionalArray() {
    462476      string[,] mDimString = new string[,] {
     
    487501
    488502    [TestMethod]
     503    [TestCategory("Persistence")]
     504    [TestProperty("Time", "short")]
    489505    public void NestedTypeTest() {
    490506      NestedType t = new NestedType();
     
    499515
    500516    [TestMethod]
     517    [TestCategory("Persistence")]
     518    [TestProperty("Time", "short")]
    501519    public void SimpleArray() {
    502520      string[] strings = { "ora", "et", "labora" };
     
    509527
    510528    [TestMethod]
     529    [TestCategory("Persistence")]
     530    [TestProperty("Time", "short")]
    511531    public void PrimitiveRoot() {
    512532      XmlGenerator.Serialize(12.3f, tempFile);
     
    561581
    562582    [TestMethod]
     583    [TestCategory("Persistence")]
     584    [TestProperty("Time", "short")]
    563585    public void Number2StringDecomposer() {
    564586      NumberTest sdt = new NumberTest();
     
    577599
    578600    [TestMethod]
     601    [TestCategory("Persistence")]
     602    [TestProperty("Time", "short")]
    579603    public void Enums() {
    580604      EnumTest et = new EnumTest();
     
    590614
    591615    [TestMethod]
     616    [TestCategory("Persistence")]
     617    [TestProperty("Time", "short")]
    592618    public void TestAliasingWithOverriddenEquals() {
    593619      List<IntWrapper> ints = new List<IntWrapper>();
     
    605631
    606632    [TestMethod]
     633    [TestCategory("Persistence")]
     634    [TestProperty("Time", "short")]
    607635    public void NonDefaultConstructorTest() {
    608636      NonDefaultConstructorClass c = new NonDefaultConstructorClass(1);
     
    610638        XmlGenerator.Serialize(c, tempFile);
    611639        Assert.Fail("Exception not thrown");
    612       }
    613       catch (PersistenceException) {
    614       }
    615     }
    616 
    617     [TestMethod]
     640      } catch (PersistenceException) {
     641      }
     642    }
     643
     644    [TestMethod]
     645    [TestCategory("Persistence")]
     646    [TestProperty("Time", "short")]
    618647    public void TestSavingException() {
    619648      List<int> list = new List<int> { 1, 2, 3 };
     
    623652        XmlGenerator.Serialize(s, tempFile);
    624653        Assert.Fail("Exception expected");
    625       }
    626       catch (PersistenceException) { }
     654      } catch (PersistenceException) { }
    627655      List<int> newList = (List<int>)XmlParser.Deserialize(tempFile);
    628656      Assert.AreEqual(list[0], newList[0]);
     
    631659
    632660    [TestMethod]
     661    [TestCategory("Persistence")]
     662    [TestProperty("Time", "short")]
    633663    public void TestTypeStringConversion() {
    634664      string name = typeof(List<int>[]).AssemblyQualifiedName;
     
    641671
    642672    [TestMethod]
     673    [TestCategory("Persistence")]
     674    [TestProperty("Time", "short")]
    643675    public void TestHexadecimalPublicKeyToken() {
    644676      string name = "TestClass, TestAssembly, Version=1.2.3.4, PublicKey=1234abc";
     
    649681
    650682    [TestMethod]
     683    [TestCategory("Persistence")]
     684    [TestProperty("Time", "short")]
    651685    public void TestMultipleFailure() {
    652686      List<NonSerializable> l = new List<NonSerializable>();
     
    663697        }
    664698        Assert.Fail("Exception expected");
    665       }
    666       catch (PersistenceException px) {
     699      } catch (PersistenceException px) {
    667700        Assert.AreEqual(3, px.Data.Count);
    668701      }
     
    670703
    671704    [TestMethod]
     705    [TestCategory("Persistence")]
     706    [TestProperty("Time", "short")]
    672707    public void TestAssemblyVersionCheck() {
    673708      IntWrapper i = new IntWrapper(1);
     
    692727        d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));
    693728        Assert.Fail("Exception expected");
    694       }
    695       catch (PersistenceException x) {
     729      } catch (PersistenceException x) {
    696730        Assert.IsTrue(x.Message.Contains("incompatible"));
    697731      }
     
    702736        d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));
    703737        Assert.Fail("Exception expected");
    704       }
    705       catch (PersistenceException x) {
     738      } catch (PersistenceException x) {
    706739        Assert.IsTrue(x.Message.Contains("newer"));
    707740      }
     
    709742
    710743    [TestMethod]
     744    [TestCategory("Persistence")]
     745    [TestProperty("Time", "short")]
    711746    public void InheritanceTest() {
    712747      New n = new New();
     
    736771
    737772    [TestMethod]
     773    [TestCategory("Persistence")]
     774    [TestProperty("Time", "short")]
    738775    public void InstantiateParentChainReference() {
    739776      GrandParent gp = new GrandParent();
     
    758795
    759796    [TestMethod]
     797    [TestCategory("Persistence")]
     798    [TestProperty("Time", "short")]
    760799    public void StructTest() {
    761800      TestStruct s = new TestStruct(10);
     
    766805
    767806    [TestMethod]
     807    [TestCategory("Persistence")]
     808    [TestProperty("Time", "short")]
    768809    public void PointTest() {
    769810      Point p = new Point(12, 34);
     
    774815
    775816    [TestMethod]
     817    [TestCategory("Persistence")]
     818    [TestProperty("Time", "short")]
    776819    public void NullableValueTypes() {
    777820      double?[] d = new double?[] { null, 1, 2, 3 };
     
    785828
    786829    [TestMethod]
     830    [TestCategory("Persistence")]
     831    [TestProperty("Time", "short")]
    787832    public void BitmapTest() {
    788833      Icon icon = System.Drawing.SystemIcons.Hand;
     
    816861
    817862    [TestMethod]
     863    [TestCategory("Persistence")]
     864    [TestProperty("Time", "short")]
    818865    public void HookTest() {
    819866      PersistenceHooks hookTest = new PersistenceHooks();
     
    846893
    847894    [TestMethod]
     895    [TestCategory("Persistence")]
     896    [TestProperty("Time", "short")]
    848897    public void TestCustomConstructor() {
    849898      CustomConstructor cc = new CustomConstructor();
     
    864913
    865914    [TestMethod]
     915    [TestCategory("Persistence")]
     916    [TestProperty("Time", "short")]
    866917    public void TestConstructorExceptionUnwrapping() {
    867918      ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password");
     
    870921        ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile);
    871922        Assert.Fail("Exception expected");
    872       }
    873       catch (PersistenceException pe) {
     923      } catch (PersistenceException pe) {
    874924        Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail");
    875925      }
     
    877927
    878928    [TestMethod]
     929    [TestCategory("Persistence")]
     930    [TestProperty("Time", "short")]
    879931    public void TestRejectionJustifications() {
    880932      NonSerializable ns = new NonSerializable();
     
    882934        XmlGenerator.Serialize(ns, tempFile);
    883935        Assert.Fail("PersistenceException expected");
    884       }
    885       catch (PersistenceException x) {
     936      } catch (PersistenceException x) {
    886937        Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable))));
    887938      }
     
    889940
    890941    [TestMethod]
     942    [TestCategory("Persistence")]
     943    [TestProperty("Time", "short")]
    891944    public void TestStreaming() {
    892945      using (MemoryStream stream = new MemoryStream()) {
     
    923976
    924977    [TestMethod]
     978    [TestCategory("Persistence")]
     979    [TestProperty("Time", "short")]
    925980    public void TestLinkInheritance() {
    926981      HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass();
     
    9501005
    9511006    [TestMethod]
     1007    [TestCategory("Persistence")]
     1008    [TestProperty("Time", "short")]
    9521009    public void TestStorableClassDiscoveryAllFields() {
    9531010      AllFieldsStorable afs = new AllFieldsStorable(false);
     
    9791036
    9801037    [TestMethod]
     1038    [TestCategory("Persistence")]
     1039    [TestProperty("Time", "short")]
    9811040    public void TestStorableClassDiscoveryAllProperties() {
    9821041      AllPropertiesStorable afs = new AllPropertiesStorable(false);
     
    10091068
    10101069    [TestMethod]
     1070    [TestCategory("Persistence")]
     1071    [TestProperty("Time", "short")]
    10111072    public void TestStorableClassDiscoveryAllFieldsAndAllProperties() {
    10121073      AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false);
     
    10381099
    10391100    [TestMethod]
     1101    [TestCategory("Persistence")]
     1102    [TestProperty("Time", "short")]
    10401103    public void TestStorableClassDiscoveryMarkedOnly() {
    10411104      MarkedOnlyStorable afs = new MarkedOnlyStorable(false);
     
    10491112
    10501113    [TestMethod]
     1114    [TestCategory("Persistence")]
     1115    [TestProperty("Time", "short")]
    10511116    public void TestLineEndings() {
    10521117      List<string> lineBreaks = new List<string> { "\r\n", "\n", "\r", "\n\r", Environment.NewLine };
     
    10631128
    10641129    [TestMethod]
     1130    [TestCategory("Persistence")]
     1131    [TestProperty("Time", "short")]
    10651132    public void TestSpecialNumbers() {
    10661133      List<double> specials = new List<double>() { 1.0 / 0, -1.0 / 0, 0.0 / 0 };
     
    10761143
    10771144    [TestMethod]
     1145    [TestCategory("Persistence")]
     1146    [TestProperty("Time", "short")]
    10781147    public void TestStringSplit() {
    10791148      string s = "1.2;2.3;3.4;;;4.9";
     
    10861155
    10871156    [TestMethod]
     1157    [TestCategory("Persistence")]
     1158    [TestProperty("Time", "medium")]
    10881159    public void TestCompactNumberArraySerializer() {
    10891160      System.Random r = new System.Random();
     
    11181189
    11191190    [TestMethod]
     1191    [TestCategory("Persistence")]
     1192    [TestProperty("Time", "short")]
    11201193    public void TestHashSetSerializer() {
    11211194      var hashSets = new List<HashSet<int>>() {
     
    11361209
    11371210    [TestMethod]
     1211    [TestCategory("Persistence")]
     1212    [TestProperty("Time", "short")]
    11381213    public void TestConcreteDictionarySerializer() {
    11391214      var dictionaries = new List<Dictionary<int, int>>() {
     
    11741249
    11751250    [TestMethod]
     1251    [TestCategory("Persistence")]
     1252    [TestProperty("Time", "short")]
    11761253    public void TestReadOnlyFail() {
    11771254      try {
    11781255        XmlGenerator.Serialize(new ReadOnlyFail(), tempFile);
    11791256        Assert.Fail("Exception expected");
    1180       }
    1181       catch (PersistenceException) {
    1182       }
    1183       catch {
     1257      } catch (PersistenceException) {
     1258      } catch {
    11841259        Assert.Fail("PersistenceException expected");
    11851260      }
     
    11961271
    11971272    [TestMethod]
     1273    [TestCategory("Persistence")]
     1274    [TestProperty("Time", "short")]
    11981275    public void TestWriteOnlyFail() {
    11991276      try {
    12001277        XmlGenerator.Serialize(new WriteOnlyFail(), tempFile);
    12011278        Assert.Fail("Exception expected");
    1202       }
    1203       catch (PersistenceException) {
    1204       }
    1205       catch {
     1279      } catch (PersistenceException) {
     1280      } catch {
    12061281        Assert.Fail("PersistenceException expected.");
    12071282      }
     
    12231298
    12241299    [TestMethod]
     1300    [TestCategory("Persistence")]
     1301    [TestProperty("Time", "short")]
    12251302    public void TestOneWaySerialization() {
    12261303      var test = new OneWayTest();
     
    12431320
    12441321    [TestMethod]
     1322    [TestCategory("Persistence")]
     1323    [TestProperty("Time", "short")]
    12451324    public void TestTypeCacheExport() {
    12461325      var test = new List<List<int>>();
     
    12581337
    12591338    [TestMethod]
     1339    [TestCategory("Persistence")]
     1340    [TestProperty("Time", "short")]
    12601341    public void TupleTest() {
    12611342      var t1 = Tuple.Create(1);
     
    12701351
    12711352    [TestMethod]
     1353    [TestCategory("Persistence")]
     1354    [TestProperty("Time", "short")]
    12721355    public void FontTest() {
    12731356      List<Font> fonts = new List<Font>() {
     
    12861369
    12871370    [TestMethod]
     1371    [TestCategory("Persistence")]
     1372    [TestProperty("Time", "medium")]
    12881373    public void ConcurrencyTest() {
    12891374      int n = 20;
     
    13021387
    13031388    [TestMethod]
     1389    [TestCategory("Persistence")]
     1390    [TestProperty("Time", "medium")]
    13041391    public void ConcurrentBitmapTest() {
    13051392      Bitmap b = new Bitmap(300, 300);
     
    13231410    }
    13241411
    1325     public class G<T,T2> {
    1326       public class S {}
    1327       public class S2<T3,T4> {}
    1328     }
    1329 
    1330     [TestMethod]
     1412    public class G<T, T2> {
     1413      public class S { }
     1414      public class S2<T3, T4> { }
     1415    }
     1416
     1417    [TestMethod]
     1418    [TestCategory("Persistence")]
     1419    [TestProperty("Time", "short")]
    13311420    public void TestInternalClassOfGeneric() {
    13321421      var s = new G<int, char>.S();
     
    13401429
    13411430    [TestMethod]
     1431    [TestCategory("Persistence")]
     1432    [TestProperty("Time", "short")]
    13421433    public void TestInternalClassOfGeneric2() {
    13431434      var s = new G<int, float>.S2<int, char>();
Note: See TracChangeset for help on using the changeset viewer.