Changeset 14537 for branches/PersistenceOverhaul/HeuristicLab.Tests
- Timestamp:
- 01/03/17 18:21:40 (8 years ago)
- Location:
- branches/PersistenceOverhaul
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceOverhaul
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:ignore
-
branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs
r13410 r14537 273 273 } 274 274 275 [StorableClass("FD953B0A-BDE6-41E6-91A8-CA3D90C91CDB")] 275 276 public class SimpleClass { 277 [Storable] 276 278 public double x { get; set; } 279 [Storable] 277 280 public int y { get; set; } 278 281 } … … 653 656 [TestCategory("Persistence4")] 654 657 [TestProperty("Time", "short")] 658 public void TestSBytes() { 659 var test = new Func<sbyte[]>(() => { return new sbyte[] { 3, 1 }; }); 660 ProtoBufSerializer serializer = new ProtoBufSerializer(); 661 serializer.Serialize(test(), tempFile); 662 object o = serializer.Deserialize(tempFile); 663 sbyte[] result = (sbyte[])o; 664 Assert.AreEqual(test()[0], result[0]); 665 Assert.AreEqual(test()[1], result[1]); 666 667 string msg = Profile(test); 668 Console.WriteLine(msg); 669 } 670 671 [TestMethod] 672 [TestCategory("Persistence4")] 673 [TestProperty("Time", "short")] 674 public void TestChars() { 675 var test = new Func<char[]>(() => { return new char[] { 'a', 'b' }; }); 676 ProtoBufSerializer serializer = new ProtoBufSerializer(); 677 serializer.Serialize(test(), tempFile); 678 object o = serializer.Deserialize(tempFile); 679 char[] result = (char[])o; 680 Assert.AreEqual(test()[0], result[0]); 681 Assert.AreEqual(test()[1], result[1]); 682 683 string msg = Profile(test); 684 Console.WriteLine(msg); 685 } 686 687 [TestMethod] 688 [TestCategory("Persistence4")] 689 [TestProperty("Time", "short")] 690 public void TestShorts() { 691 var test = new Func<short[]>(() => { return new short[] { 3, 1 }; }); 692 ProtoBufSerializer serializer = new ProtoBufSerializer(); 693 serializer.Serialize(test(), tempFile); 694 object o = serializer.Deserialize(tempFile); 695 short[] result = (short[])o; 696 Assert.AreEqual(test()[0], result[0]); 697 Assert.AreEqual(test()[1], result[1]); 698 699 string msg = Profile(test); 700 Console.WriteLine(msg); 701 } 702 703 [TestMethod] 704 [TestCategory("Persistence4")] 705 [TestProperty("Time", "short")] 706 public void TestUShorts() { 707 var test = new Func<ushort[]>(() => { return new ushort[] { 3, 1 }; }); 708 ProtoBufSerializer serializer = new ProtoBufSerializer(); 709 serializer.Serialize(test(), tempFile); 710 object o = serializer.Deserialize(tempFile); 711 ushort[] result = (ushort[])o; 712 Assert.AreEqual(test()[0], result[0]); 713 Assert.AreEqual(test()[1], result[1]); 714 715 string msg = Profile(test); 716 Console.WriteLine(msg); 717 } 718 719 [TestMethod] 720 [TestCategory("Persistence4")] 721 [TestProperty("Time", "short")] 655 722 public void TestString() { 656 723 var test = new Func<object>(() => { return "Hello World!"; }); … … 669 736 [TestProperty("Time", "short")] 670 737 public void TestColor() { 671 var test = new Func<object>(() => { return Color. DeepSkyBlue; });738 var test = new Func<object>(() => { return Color.FromArgb(12, 34, 56, 78); }); 672 739 ProtoBufSerializer serializer = new ProtoBufSerializer(); 673 740 serializer.Serialize(test(), tempFile); … … 791 858 [TestCategory("Persistence4")] 792 859 [TestProperty("Time", "short")] 860 public void TestStack() { 861 var test = new Func<Stack>(() => { 862 return new Stack(new int[] { 1, 2, 3 }); 863 }); 864 ProtoBufSerializer serializer = new ProtoBufSerializer(); 865 serializer.Serialize(test(), tempFile); 866 object o = serializer.Deserialize(tempFile); 867 Stack result = (Stack)o; 868 var actualStack = test(); 869 Assert.AreEqual(actualStack.Pop(), result.Pop()); 870 Assert.AreEqual(actualStack.Pop(), result.Pop()); 871 Assert.AreEqual(actualStack.Pop(), result.Pop()); 872 873 string msg = Profile(test); 874 Console.WriteLine(msg); 875 } 876 877 [TestMethod] 878 [TestCategory("Persistence4")] 879 [TestProperty("Time", "short")] 880 public void TestArrayOfStack() { 881 var test = new Func<object[]>(() => { 882 return new object[] { 883 new Stack(new int[] { 1, 2, 3 }), 884 new Stack<int>(new int[] { 1, 2, 3 }), 885 }; 886 }); 887 ProtoBufSerializer serializer = new ProtoBufSerializer(); 888 serializer.Serialize(test(), tempFile); 889 object o = serializer.Deserialize(tempFile); 890 var result = (object[])o; 891 var firstStack = (Stack)result[0]; 892 var secondStack = (Stack<int>)result[1]; 893 var actual = test(); 894 var actualFirst = (Stack)actual[0]; 895 var actualSecond = (Stack<int>)actual[1]; 896 897 Assert.AreEqual(actualFirst.Pop(), firstStack.Pop()); 898 Assert.AreEqual(actualFirst.Pop(), firstStack.Pop()); 899 Assert.AreEqual(actualFirst.Pop(), firstStack.Pop()); 900 Assert.AreEqual(actualSecond.Pop(), secondStack.Pop()); 901 Assert.AreEqual(actualSecond.Pop(), secondStack.Pop()); 902 Assert.AreEqual(actualSecond.Pop(), secondStack.Pop()); 903 904 string msg = Profile(test); 905 Console.WriteLine(msg); 906 } 907 908 909 [TestMethod] 910 [TestCategory("Persistence4")] 911 [TestProperty("Time", "short")] 793 912 public void TestIntValueArray() { 794 913 var test = new Func<IntValue[]>(() => { return new[] { new IntValue(41), new IntValue(22), new IntValue(13) }; }); … … 797 916 object o = serializer.Deserialize(tempFile); 798 917 IntValue[] result = (IntValue[])o; 799 Assert.AreEqual(test()[0], result[0]); 800 Assert.AreEqual(test()[1], result[1]); 801 Assert.AreEqual(test()[2], result[2]); 918 Assert.AreEqual(test()[0].Value, result[0].Value); 919 Assert.AreEqual(test()[1].Value, result[1].Value); 920 Assert.AreEqual(test()[2].Value, result[2].Value); 921 922 string msg = Profile(test); 923 Console.WriteLine(msg); 924 } 925 926 [TestMethod] 927 [TestCategory("Persistence4")] 928 [TestProperty("Time", "short")] 929 public void TestIntValueArrayArray() { 930 var test = new Func<IntValue[][]>(() => { return new IntValue[][] { new IntValue[] { new IntValue(41), new IntValue(22), new IntValue(13) } }; }); 931 ProtoBufSerializer serializer = new ProtoBufSerializer(); 932 serializer.Serialize(test(), tempFile); 933 object o = serializer.Deserialize(tempFile); 934 IntValue[][] result = (IntValue[][])o; 935 Assert.AreEqual(test()[0][0].Value, result[0][0].Value); 936 Assert.AreEqual(test()[0][1].Value, result[0][1].Value); 937 Assert.AreEqual(test()[0][2].Value, result[0][2].Value); 802 938 803 939 string msg = Profile(test); … … 809 945 #region Old persistence test methods 810 946 [TestMethod] 811 [TestCategory("Persistence ")]947 [TestCategory("Persistence4")] 812 948 [TestProperty("Time", "short")] 813 949 public void ComplexStorable() { … … 899 1035 900 1036 [TestMethod] 901 [TestCategory("Persistence ")]1037 [TestCategory("Persistence4")] 902 1038 [TestProperty("Time", "short")] 903 1039 public void SelfReferences() { … … 927 1063 928 1064 [TestMethod] 929 [TestCategory("Persistence ")]1065 [TestCategory("Persistence4")] 930 1066 [TestProperty("Time", "short")] 931 1067 public void ArrayCreation() { … … 957 1093 958 1094 [TestMethod] 959 [TestCategory("Persistence ")]1095 [TestCategory("Persistence4")] 960 1096 [TestProperty("Time", "short")] 961 1097 public void CustomSerializationProperty() { … … 974 1110 975 1111 [TestMethod] 976 [TestCategory("Persistence ")]1112 [TestCategory("Persistence4")] 977 1113 [TestProperty("Time", "short")] 978 1114 public void Primitives() { … … 987 1123 988 1124 [TestMethod] 989 [TestCategory("Persistence ")]1125 [TestCategory("Persistence4")] 990 1126 [TestProperty("Time", "short")] 991 1127 public void MultiDimensionalArray() { … … 1018 1154 1019 1155 [TestMethod] 1020 [TestCategory("Persistence ")]1156 [TestCategory("Persistence4")] 1021 1157 [TestProperty("Time", "short")] 1022 1158 public void NestedTypeTest() { … … 1033 1169 1034 1170 [TestMethod] 1035 [TestCategory("Persistence ")]1171 [TestCategory("Persistence4")] 1036 1172 [TestProperty("Time", "short")] 1037 1173 public void SimpleArray() { … … 1046 1182 1047 1183 [TestMethod] 1048 [TestCategory("Persistence ")]1184 [TestCategory("Persistence4")] 1049 1185 [TestProperty("Time", "short")] 1050 1186 public void PrimitiveRoot() { … … 1101 1237 1102 1238 [TestMethod] 1103 [TestCategory("Persistence ")]1239 [TestCategory("Persistence4")] 1104 1240 [TestProperty("Time", "short")] 1105 1241 public void Enums() { … … 1117 1253 1118 1254 [TestMethod] 1119 [TestCategory("Persistence ")]1255 [TestCategory("Persistence4")] 1120 1256 [TestProperty("Time", "short")] 1121 1257 public void TestAliasingWithOverriddenEquals() { … … 1135 1271 1136 1272 [TestMethod] 1137 [TestCategory("Persistence ")]1273 [TestCategory("Persistence4")] 1138 1274 [TestProperty("Time", "short")] 1139 1275 public void NonDefaultConstructorTest() { … … 1143 1279 serializer.Serialize(c, tempFile); 1144 1280 Assert.Fail("Exception not thrown"); 1145 } 1146 catch (PersistenceException) { 1147 } 1148 } 1149 1150 [TestMethod] 1151 [TestCategory("Persistence")] 1281 } catch (PersistenceException) { 1282 } 1283 } 1284 1285 [TestMethod] 1286 [TestCategory("Persistence4")] 1152 1287 [TestProperty("Time", "short")] 1153 1288 public void TestSavingException() { … … 1159 1294 serializer.Serialize(s, tempFile); 1160 1295 Assert.Fail("Exception expected"); 1161 } 1162 catch (PersistenceException) { } 1296 } catch (PersistenceException) { } 1163 1297 List<int> newList = (List<int>)serializer.Deserialize(tempFile); 1164 1298 Assert.AreEqual(list[0], newList[0]); … … 1167 1301 1168 1302 [TestMethod] 1169 [TestCategory("Persistence ")]1303 [TestCategory("Persistence4")] 1170 1304 [TestProperty("Time", "short")] 1171 1305 public void TestTypeStringConversion() { … … 1179 1313 1180 1314 [TestMethod] 1181 [TestCategory("Persistence ")]1315 [TestCategory("Persistence4")] 1182 1316 [TestProperty("Time", "short")] 1183 1317 public void TestHexadecimalPublicKeyToken() { … … 1189 1323 1190 1324 [TestMethod] 1191 [TestCategory("Persistence ")]1325 [TestCategory("Persistence4")] 1192 1326 [TestProperty("Time", "short")] 1193 1327 public void InheritanceTest() { … … 1219 1353 1220 1354 [TestMethod] 1221 [TestCategory("Persistence ")]1355 [TestCategory("Persistence4")] 1222 1356 [TestProperty("Time", "short")] 1223 1357 public void InstantiateParentChainReference() { … … 1244 1378 1245 1379 [TestMethod] 1246 [TestCategory("Persistence ")]1380 [TestCategory("Persistence4")] 1247 1381 [TestProperty("Time", "short")] 1248 1382 public void StructTest() { … … 1255 1389 1256 1390 [TestMethod] 1257 [TestCategory("Persistence ")]1391 [TestCategory("Persistence4")] 1258 1392 [TestProperty("Time", "short")] 1259 1393 public void PointTest() { … … 1266 1400 1267 1401 [TestMethod] 1268 [TestCategory("Persistence ")]1402 [TestCategory("Persistence4")] 1269 1403 [TestProperty("Time", "short")] 1270 1404 public void NullableValueTypes() { … … 1280 1414 1281 1415 [TestMethod] 1282 [TestCategory("Persistence ")]1416 [TestCategory("Persistence4")] 1283 1417 [TestProperty("Time", "short")] 1284 1418 public void BitmapTest() { … … 1314 1448 1315 1449 [TestMethod] 1316 [TestCategory("Persistence ")]1450 [TestCategory("Persistence4")] 1317 1451 [TestProperty("Time", "short")] 1318 1452 public void HookTest() { … … 1347 1481 1348 1482 [TestMethod] 1349 [TestCategory("Persistence ")]1483 [TestCategory("Persistence4")] 1350 1484 [TestProperty("Time", "short")] 1351 1485 public void TestCustomConstructor() { … … 1368 1502 1369 1503 [TestMethod] 1370 [TestCategory("Persistence ")]1504 [TestCategory("Persistence4")] 1371 1505 [TestProperty("Time", "short")] 1372 1506 public void TestConstructorExceptionUnwrapping() { … … 1377 1511 ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)serializer.Deserialize(tempFile); 1378 1512 Assert.Fail("Exception expected"); 1379 } 1380 catch (PersistenceException pe) { 1513 } catch (PersistenceException pe) { 1381 1514 Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail"); 1382 1515 } … … 1384 1517 1385 1518 [TestMethod] 1386 [TestCategory("Persistence")] 1387 [TestProperty("Time", "short")] 1388 public void TestRejectionJustifications() { 1389 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1390 NonSerializable ns = new NonSerializable(); 1391 try { 1392 serializer.Serialize(ns, tempFile); 1393 Assert.Fail("PersistenceException expected"); 1394 } 1395 catch (PersistenceException x) { 1396 Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable)))); 1397 } 1398 } 1399 1400 [TestMethod] 1401 [TestCategory("Persistence")] 1519 [TestCategory("Persistence4")] 1402 1520 [TestProperty("Time", "short")] 1403 1521 public void TestStreaming() { … … 1436 1554 1437 1555 [TestMethod] 1438 [TestCategory("Persistence ")]1556 [TestCategory("Persistence4")] 1439 1557 [TestProperty("Time", "short")] 1440 1558 public void TestLinkInheritance() { … … 1466 1584 1467 1585 [TestMethod] 1468 [TestCategory("Persistence ")]1586 [TestCategory("Persistence4")] 1469 1587 [TestProperty("Time", "short")] 1470 1588 public void TestStorableClassDiscoveryAllFields() { … … 1498 1616 1499 1617 [TestMethod] 1500 [TestCategory("Persistence ")]1618 [TestCategory("Persistence4")] 1501 1619 [TestProperty("Time", "short")] 1502 1620 public void TestStorableClassDiscoveryAllProperties() { … … 1531 1649 1532 1650 [TestMethod] 1533 [TestCategory("Persistence ")]1651 [TestCategory("Persistence4")] 1534 1652 [TestProperty("Time", "short")] 1535 1653 public void TestStorableClassDiscoveryAllFieldsAndAllProperties() { … … 1563 1681 1564 1682 [TestMethod] 1565 [TestCategory("Persistence ")]1683 [TestCategory("Persistence4")] 1566 1684 [TestProperty("Time", "short")] 1567 1685 public void TestStorableClassDiscoveryMarkedOnly() { … … 1577 1695 1578 1696 [TestMethod] 1579 [TestCategory("Persistence ")]1697 [TestCategory("Persistence4")] 1580 1698 [TestProperty("Time", "short")] 1581 1699 public void TestLineEndings() { … … 1594 1712 1595 1713 [TestMethod] 1596 [TestCategory("Persistence ")]1714 [TestCategory("Persistence4")] 1597 1715 [TestProperty("Time", "short")] 1598 1716 public void TestSpecialNumbers() { … … 1610 1728 1611 1729 [TestMethod] 1612 [TestCategory("Persistence ")]1730 [TestCategory("Persistence4")] 1613 1731 [TestProperty("Time", "short")] 1614 1732 public void TestStringSplit() { … … 1633 1751 1634 1752 [TestMethod] 1635 [TestCategory("Persistence ")]1753 [TestCategory("Persistence4")] 1636 1754 [TestProperty("Time", "short")] 1637 1755 public void TestHashSetSerializer() { … … 1654 1772 1655 1773 [TestMethod] 1656 [TestCategory("Persistence ")]1774 [TestCategory("Persistence4")] 1657 1775 [TestProperty("Time", "short")] 1658 1776 public void TestConcreteDictionarySerializer() { … … 1695 1813 1696 1814 [TestMethod] 1697 [TestCategory("Persistence ")]1815 [TestCategory("Persistence4")] 1698 1816 [TestProperty("Time", "short")] 1699 1817 public void TestReadOnlyFail() { … … 1702 1820 serializer.Serialize(new ReadOnlyFail(), tempFile); 1703 1821 Assert.Fail("Exception expected"); 1704 } 1705 catch (PersistenceException) { 1706 } 1707 catch { 1822 } catch (PersistenceException) { 1823 } catch { 1708 1824 Assert.Fail("PersistenceException expected"); 1709 1825 } … … 1720 1836 1721 1837 [TestMethod] 1722 [TestCategory("Persistence ")]1838 [TestCategory("Persistence4")] 1723 1839 [TestProperty("Time", "short")] 1724 1840 public void TestWriteOnlyFail() { … … 1727 1843 serializer.Serialize(new WriteOnlyFail(), tempFile); 1728 1844 Assert.Fail("Exception expected"); 1729 } 1730 catch (PersistenceException) { 1731 } 1732 catch { 1845 } catch (PersistenceException) { 1846 } catch { 1733 1847 Assert.Fail("PersistenceException expected."); 1734 1848 } … … 1751 1865 //TODO 1752 1866 /* [TestMethod] 1753 [TestCategory("Persistence ")]1867 [TestCategory("Persistence4")] 1754 1868 [TestProperty("Time", "short")] 1755 1869 public void TestTypeCacheExport() { … … 1769 1883 1770 1884 [TestMethod] 1771 [TestCategory("Persistence ")]1885 [TestCategory("Persistence4")] 1772 1886 [TestProperty("Time", "short")] 1773 1887 public void TupleTest() { … … 1777 1891 var t4 = Tuple.Create(Tuple.Create(1, 2, 3), Tuple.Create(4, 5, 6), Tuple.Create(8, 9, 10)); 1778 1892 var tuple = Tuple.Create(t1, t2, t3, t4); 1779 XmlGenerator.Serialize(tuple, tempFile);1780 var newTuple = XmlParser.Deserialize<Tuple<Tuple<int>, Tuple<char, string>, Tuple<double, float, int>, Tuple<Tuple<int, int, int>, Tuple<int, int, int>, Tuple<int, int, int>>>>(tempFile);1893 SerializeNew(tuple); 1894 var newTuple = DeserializeNew(); 1781 1895 Assert.AreEqual(tuple, newTuple); 1782 1896 } 1783 1897 1784 1898 [TestMethod] 1785 [TestCategory("Persistence ")]1899 [TestCategory("Persistence4")] 1786 1900 [TestProperty("Time", "short")] 1787 1901 public void FontTest() { … … 1802 1916 1803 1917 [TestMethod] 1804 [TestCategory("Persistence ")]1918 [TestCategory("Persistence4")] 1805 1919 [TestProperty("Time", "medium")] 1806 1920 public void ConcurrencyTest() { … … 1821 1935 1822 1936 [TestMethod] 1823 [TestCategory("Persistence ")]1937 [TestCategory("Persistence4")] 1824 1938 [TestProperty("Time", "medium")] 1825 1939 public void ConcurrentBitmapTest() { … … 1852 1966 1853 1967 [TestMethod] 1854 [TestCategory("Persistence ")]1968 [TestCategory("Persistence4")] 1855 1969 [TestProperty("Time", "short")] 1856 1970 public void TestSpecialCharacters() { … … 1863 1977 1864 1978 [TestMethod] 1865 [TestCategory("Persistence ")]1979 [TestCategory("Persistence4")] 1866 1980 [TestProperty("Time", "short")] 1867 1981 public void TestByteArray() { … … 1877 1991 1878 1992 [TestMethod] 1879 [TestCategory("Persistence ")]1993 [TestCategory("Persistence4")] 1880 1994 [TestProperty("Time", "short")] 1881 1995 public void TestOptionalNumberEnumerable() { … … 1888 2002 1889 2003 [TestMethod] 1890 [TestCategory("Persistence ")]2004 [TestCategory("Persistence4")] 1891 2005 [TestProperty("Time", "short")] 1892 2006 public void TestOptionalDateTimeEnumerable() { … … 1900 2014 1901 2015 [TestMethod] 1902 [TestCategory("Persistence ")]2016 [TestCategory("Persistence4")] 1903 2017 [TestProperty("Time", "short")] 1904 2018 public void TestStringEnumerable() { … … 1911 2025 1912 2026 [TestMethod] 1913 [TestCategory("Persistence ")]2027 [TestCategory("Persistence4")] 1914 2028 [TestProperty("Time", "short")] 1915 2029 public void TestUnicodeCharArray() { … … 1922 2036 1923 2037 [TestMethod] 1924 [TestCategory("Persistence ")]2038 [TestCategory("Persistence4")] 1925 2039 [TestProperty("Time", "short")] 1926 2040 public void TestUnicode() { … … 1933 2047 1934 2048 [TestMethod] 1935 [TestCategory("Persistence ")]2049 [TestCategory("Persistence4")] 1936 2050 [TestProperty("Time", "short")] 1937 2051 public void TestQueue() {
Note: See TracChangeset
for help on using the changeset viewer.