Changeset 9778
- Timestamp:
- 07/26/13 13:32:27 (11 years ago)
- 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 68 68 } 69 69 } 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 uniqueness102 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 111 70 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs
r9764 r9778 286 286 287 287 [TestMethod] 288 [TestCategory("Persistence")] 289 [TestProperty("Time", "short")] 288 290 public void ComplexStorable() { 289 291 Root r = InitializeComplexStorable(); … … 294 296 295 297 [TestMethod] 298 [TestCategory("Persistence")] 299 [TestProperty("Time", "short")] 296 300 public void ComplexEasyStorable() { 297 301 Root r = InitializeComplexStorable(); … … 383 387 384 388 [TestMethod] 389 [TestCategory("Persistence")] 390 [TestProperty("Time", "short")] 385 391 public void SelfReferences() { 386 392 C c = new C(); … … 408 414 409 415 [TestMethod] 416 [TestCategory("Persistence")] 417 [TestProperty("Time", "short")] 410 418 public void ArrayCreation() { 411 419 ArrayList[] arrayListArray = new ArrayList[4]; … … 435 443 436 444 [TestMethod] 445 [TestCategory("Persistence")] 446 [TestProperty("Time", "short")] 437 447 public void CustomSerializationProperty() { 438 448 Manager m = new Manager(); … … 449 459 450 460 [TestMethod] 461 [TestCategory("Persistence")] 462 [TestProperty("Time", "short")] 451 463 public void Primitives() { 452 464 PrimitivesTest sdt = new PrimitivesTest(); … … 459 471 460 472 [TestMethod] 473 [TestCategory("Persistence")] 474 [TestProperty("Time", "short")] 461 475 public void MultiDimensionalArray() { 462 476 string[,] mDimString = new string[,] { … … 487 501 488 502 [TestMethod] 503 [TestCategory("Persistence")] 504 [TestProperty("Time", "short")] 489 505 public void NestedTypeTest() { 490 506 NestedType t = new NestedType(); … … 499 515 500 516 [TestMethod] 517 [TestCategory("Persistence")] 518 [TestProperty("Time", "short")] 501 519 public void SimpleArray() { 502 520 string[] strings = { "ora", "et", "labora" }; … … 509 527 510 528 [TestMethod] 529 [TestCategory("Persistence")] 530 [TestProperty("Time", "short")] 511 531 public void PrimitiveRoot() { 512 532 XmlGenerator.Serialize(12.3f, tempFile); … … 561 581 562 582 [TestMethod] 583 [TestCategory("Persistence")] 584 [TestProperty("Time", "short")] 563 585 public void Number2StringDecomposer() { 564 586 NumberTest sdt = new NumberTest(); … … 577 599 578 600 [TestMethod] 601 [TestCategory("Persistence")] 602 [TestProperty("Time", "short")] 579 603 public void Enums() { 580 604 EnumTest et = new EnumTest(); … … 590 614 591 615 [TestMethod] 616 [TestCategory("Persistence")] 617 [TestProperty("Time", "short")] 592 618 public void TestAliasingWithOverriddenEquals() { 593 619 List<IntWrapper> ints = new List<IntWrapper>(); … … 605 631 606 632 [TestMethod] 633 [TestCategory("Persistence")] 634 [TestProperty("Time", "short")] 607 635 public void NonDefaultConstructorTest() { 608 636 NonDefaultConstructorClass c = new NonDefaultConstructorClass(1); … … 610 638 XmlGenerator.Serialize(c, tempFile); 611 639 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")] 618 647 public void TestSavingException() { 619 648 List<int> list = new List<int> { 1, 2, 3 }; … … 623 652 XmlGenerator.Serialize(s, tempFile); 624 653 Assert.Fail("Exception expected"); 625 } 626 catch (PersistenceException) { } 654 } catch (PersistenceException) { } 627 655 List<int> newList = (List<int>)XmlParser.Deserialize(tempFile); 628 656 Assert.AreEqual(list[0], newList[0]); … … 631 659 632 660 [TestMethod] 661 [TestCategory("Persistence")] 662 [TestProperty("Time", "short")] 633 663 public void TestTypeStringConversion() { 634 664 string name = typeof(List<int>[]).AssemblyQualifiedName; … … 641 671 642 672 [TestMethod] 673 [TestCategory("Persistence")] 674 [TestProperty("Time", "short")] 643 675 public void TestHexadecimalPublicKeyToken() { 644 676 string name = "TestClass, TestAssembly, Version=1.2.3.4, PublicKey=1234abc"; … … 649 681 650 682 [TestMethod] 683 [TestCategory("Persistence")] 684 [TestProperty("Time", "short")] 651 685 public void TestMultipleFailure() { 652 686 List<NonSerializable> l = new List<NonSerializable>(); … … 663 697 } 664 698 Assert.Fail("Exception expected"); 665 } 666 catch (PersistenceException px) { 699 } catch (PersistenceException px) { 667 700 Assert.AreEqual(3, px.Data.Count); 668 701 } … … 670 703 671 704 [TestMethod] 705 [TestCategory("Persistence")] 706 [TestProperty("Time", "short")] 672 707 public void TestAssemblyVersionCheck() { 673 708 IntWrapper i = new IntWrapper(1); … … 692 727 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString))); 693 728 Assert.Fail("Exception expected"); 694 } 695 catch (PersistenceException x) { 729 } catch (PersistenceException x) { 696 730 Assert.IsTrue(x.Message.Contains("incompatible")); 697 731 } … … 702 736 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString))); 703 737 Assert.Fail("Exception expected"); 704 } 705 catch (PersistenceException x) { 738 } catch (PersistenceException x) { 706 739 Assert.IsTrue(x.Message.Contains("newer")); 707 740 } … … 709 742 710 743 [TestMethod] 744 [TestCategory("Persistence")] 745 [TestProperty("Time", "short")] 711 746 public void InheritanceTest() { 712 747 New n = new New(); … … 736 771 737 772 [TestMethod] 773 [TestCategory("Persistence")] 774 [TestProperty("Time", "short")] 738 775 public void InstantiateParentChainReference() { 739 776 GrandParent gp = new GrandParent(); … … 758 795 759 796 [TestMethod] 797 [TestCategory("Persistence")] 798 [TestProperty("Time", "short")] 760 799 public void StructTest() { 761 800 TestStruct s = new TestStruct(10); … … 766 805 767 806 [TestMethod] 807 [TestCategory("Persistence")] 808 [TestProperty("Time", "short")] 768 809 public void PointTest() { 769 810 Point p = new Point(12, 34); … … 774 815 775 816 [TestMethod] 817 [TestCategory("Persistence")] 818 [TestProperty("Time", "short")] 776 819 public void NullableValueTypes() { 777 820 double?[] d = new double?[] { null, 1, 2, 3 }; … … 785 828 786 829 [TestMethod] 830 [TestCategory("Persistence")] 831 [TestProperty("Time", "short")] 787 832 public void BitmapTest() { 788 833 Icon icon = System.Drawing.SystemIcons.Hand; … … 816 861 817 862 [TestMethod] 863 [TestCategory("Persistence")] 864 [TestProperty("Time", "short")] 818 865 public void HookTest() { 819 866 PersistenceHooks hookTest = new PersistenceHooks(); … … 846 893 847 894 [TestMethod] 895 [TestCategory("Persistence")] 896 [TestProperty("Time", "short")] 848 897 public void TestCustomConstructor() { 849 898 CustomConstructor cc = new CustomConstructor(); … … 864 913 865 914 [TestMethod] 915 [TestCategory("Persistence")] 916 [TestProperty("Time", "short")] 866 917 public void TestConstructorExceptionUnwrapping() { 867 918 ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password"); … … 870 921 ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile); 871 922 Assert.Fail("Exception expected"); 872 } 873 catch (PersistenceException pe) { 923 } catch (PersistenceException pe) { 874 924 Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail"); 875 925 } … … 877 927 878 928 [TestMethod] 929 [TestCategory("Persistence")] 930 [TestProperty("Time", "short")] 879 931 public void TestRejectionJustifications() { 880 932 NonSerializable ns = new NonSerializable(); … … 882 934 XmlGenerator.Serialize(ns, tempFile); 883 935 Assert.Fail("PersistenceException expected"); 884 } 885 catch (PersistenceException x) { 936 } catch (PersistenceException x) { 886 937 Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable)))); 887 938 } … … 889 940 890 941 [TestMethod] 942 [TestCategory("Persistence")] 943 [TestProperty("Time", "short")] 891 944 public void TestStreaming() { 892 945 using (MemoryStream stream = new MemoryStream()) { … … 923 976 924 977 [TestMethod] 978 [TestCategory("Persistence")] 979 [TestProperty("Time", "short")] 925 980 public void TestLinkInheritance() { 926 981 HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass(); … … 950 1005 951 1006 [TestMethod] 1007 [TestCategory("Persistence")] 1008 [TestProperty("Time", "short")] 952 1009 public void TestStorableClassDiscoveryAllFields() { 953 1010 AllFieldsStorable afs = new AllFieldsStorable(false); … … 979 1036 980 1037 [TestMethod] 1038 [TestCategory("Persistence")] 1039 [TestProperty("Time", "short")] 981 1040 public void TestStorableClassDiscoveryAllProperties() { 982 1041 AllPropertiesStorable afs = new AllPropertiesStorable(false); … … 1009 1068 1010 1069 [TestMethod] 1070 [TestCategory("Persistence")] 1071 [TestProperty("Time", "short")] 1011 1072 public void TestStorableClassDiscoveryAllFieldsAndAllProperties() { 1012 1073 AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false); … … 1038 1099 1039 1100 [TestMethod] 1101 [TestCategory("Persistence")] 1102 [TestProperty("Time", "short")] 1040 1103 public void TestStorableClassDiscoveryMarkedOnly() { 1041 1104 MarkedOnlyStorable afs = new MarkedOnlyStorable(false); … … 1049 1112 1050 1113 [TestMethod] 1114 [TestCategory("Persistence")] 1115 [TestProperty("Time", "short")] 1051 1116 public void TestLineEndings() { 1052 1117 List<string> lineBreaks = new List<string> { "\r\n", "\n", "\r", "\n\r", Environment.NewLine }; … … 1063 1128 1064 1129 [TestMethod] 1130 [TestCategory("Persistence")] 1131 [TestProperty("Time", "short")] 1065 1132 public void TestSpecialNumbers() { 1066 1133 List<double> specials = new List<double>() { 1.0 / 0, -1.0 / 0, 0.0 / 0 }; … … 1076 1143 1077 1144 [TestMethod] 1145 [TestCategory("Persistence")] 1146 [TestProperty("Time", "short")] 1078 1147 public void TestStringSplit() { 1079 1148 string s = "1.2;2.3;3.4;;;4.9"; … … 1086 1155 1087 1156 [TestMethod] 1157 [TestCategory("Persistence")] 1158 [TestProperty("Time", "medium")] 1088 1159 public void TestCompactNumberArraySerializer() { 1089 1160 System.Random r = new System.Random(); … … 1118 1189 1119 1190 [TestMethod] 1191 [TestCategory("Persistence")] 1192 [TestProperty("Time", "short")] 1120 1193 public void TestHashSetSerializer() { 1121 1194 var hashSets = new List<HashSet<int>>() { … … 1136 1209 1137 1210 [TestMethod] 1211 [TestCategory("Persistence")] 1212 [TestProperty("Time", "short")] 1138 1213 public void TestConcreteDictionarySerializer() { 1139 1214 var dictionaries = new List<Dictionary<int, int>>() { … … 1174 1249 1175 1250 [TestMethod] 1251 [TestCategory("Persistence")] 1252 [TestProperty("Time", "short")] 1176 1253 public void TestReadOnlyFail() { 1177 1254 try { 1178 1255 XmlGenerator.Serialize(new ReadOnlyFail(), tempFile); 1179 1256 Assert.Fail("Exception expected"); 1180 } 1181 catch (PersistenceException) { 1182 } 1183 catch { 1257 } catch (PersistenceException) { 1258 } catch { 1184 1259 Assert.Fail("PersistenceException expected"); 1185 1260 } … … 1196 1271 1197 1272 [TestMethod] 1273 [TestCategory("Persistence")] 1274 [TestProperty("Time", "short")] 1198 1275 public void TestWriteOnlyFail() { 1199 1276 try { 1200 1277 XmlGenerator.Serialize(new WriteOnlyFail(), tempFile); 1201 1278 Assert.Fail("Exception expected"); 1202 } 1203 catch (PersistenceException) { 1204 } 1205 catch { 1279 } catch (PersistenceException) { 1280 } catch { 1206 1281 Assert.Fail("PersistenceException expected."); 1207 1282 } … … 1223 1298 1224 1299 [TestMethod] 1300 [TestCategory("Persistence")] 1301 [TestProperty("Time", "short")] 1225 1302 public void TestOneWaySerialization() { 1226 1303 var test = new OneWayTest(); … … 1243 1320 1244 1321 [TestMethod] 1322 [TestCategory("Persistence")] 1323 [TestProperty("Time", "short")] 1245 1324 public void TestTypeCacheExport() { 1246 1325 var test = new List<List<int>>(); … … 1258 1337 1259 1338 [TestMethod] 1339 [TestCategory("Persistence")] 1340 [TestProperty("Time", "short")] 1260 1341 public void TupleTest() { 1261 1342 var t1 = Tuple.Create(1); … … 1270 1351 1271 1352 [TestMethod] 1353 [TestCategory("Persistence")] 1354 [TestProperty("Time", "short")] 1272 1355 public void FontTest() { 1273 1356 List<Font> fonts = new List<Font>() { … … 1286 1369 1287 1370 [TestMethod] 1371 [TestCategory("Persistence")] 1372 [TestProperty("Time", "medium")] 1288 1373 public void ConcurrencyTest() { 1289 1374 int n = 20; … … 1302 1387 1303 1388 [TestMethod] 1389 [TestCategory("Persistence")] 1390 [TestProperty("Time", "medium")] 1304 1391 public void ConcurrentBitmapTest() { 1305 1392 Bitmap b = new Bitmap(300, 300); … … 1323 1410 } 1324 1411 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")] 1331 1420 public void TestInternalClassOfGeneric() { 1332 1421 var s = new G<int, char>.S(); … … 1340 1429 1341 1430 [TestMethod] 1431 [TestCategory("Persistence")] 1432 [TestProperty("Time", "short")] 1342 1433 public void TestInternalClassOfGeneric2() { 1343 1434 var s = new G<int, float>.S2<int, char>();
Note: See TracChangeset
for help on using the changeset viewer.