Changeset 4068 for trunk/sources/HeuristicLab.Persistence/3.3/Tests
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/Properties/AssemblyInfo.cs
r3742 r4068 21 21 22 22 using System.Reflection; 23 using System.Runtime.CompilerServices;24 23 using System.Runtime.InteropServices; 25 24 -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/StorableAttributeTests.cs
r3742 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using HeuristicLab.Persistence.Core;25 using Microsoft.VisualStudio.TestTools.UnitTesting;26 22 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Reflection;28 23 29 24 namespace HeuristicLab.Persistence_33.Tests { 30 25 31 [StorableClass] 26 [StorableClass] 32 27 class DemoClass { 33 28 … … 74 69 } 75 70 76 /* [TestClass]77 public class AttributeTest {71 /* [TestClass] 72 public class AttributeTest { 78 73 79 [TestMethod]80 public void SimpleStorableAttributeTest() {81 DemoClass t = new DemoClass();82 IEnumerable<DataMemberAccessor> accessorList = StorableAttribute.GetStorableAccessors(t);83 Dictionary<string, DataMemberAccessor> accessors = new Dictionary<string, DataMemberAccessor>();84 foreach (var a in accessorList)85 accessors.Add(a.Name, a);86 Assert.IsTrue(accessors.ContainsKey("TestProperty"));87 Assert.IsTrue(accessors.ContainsKey("x"));88 Assert.IsFalse(accessors.ContainsKey("y"));89 object o = new object();90 t.o = o;91 Assert.AreSame(accessors["TestProperty"].Get(), o);92 t.x = 12;93 Assert.AreEqual(accessors["x"].Get(), 12);94 t.y = 312890;95 accessors["TestProperty"].Set(null);96 Assert.IsNull(t.o);97 accessors["x"].Set(123);98 Assert.AreEqual(t.x, 123);99 }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 } 100 95 101 [TestMethod]102 public void TestInheritance() {103 New n = new New();104 var accessors = StorableAttribute.GetStorableAccessors(n);105 var accessDict = new Dictionary<string, DataMemberAccessor>();106 foreach (var accessor in accessors) // assert uniqueness107 accessDict.Add(accessor.Name, accessor);108 Assert.IsTrue(accessDict.ContainsKey(typeof(New).FullName + ".Name"));109 Assert.IsTrue(accessDict.ContainsKey(typeof(Override).FullName + ".Name"));110 Assert.AreEqual("New", accessDict[typeof(New).FullName + ".Name"].Get());111 Assert.AreEqual("Override", accessDict[typeof(Override).FullName + ".Name"].Get());112 }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 } 113 108 114 }*/109 }*/ 115 110 116 111 } -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3946 r4068 21 21 22 22 using System; 23 using System.Collections; 24 using System.Collections.Generic; 25 using System.Drawing; 26 using System.IO; 27 using System.Linq; 28 using System.Reflection; 23 29 using System.Text; 24 using System.Collections.Generic; 25 using System.Linq; 30 using System.Text.RegularExpressions; 31 using HeuristicLab.Persistence.Auxiliary; 32 using HeuristicLab.Persistence.Core; 33 using HeuristicLab.Persistence.Default.CompositeSerializers; 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 35 using HeuristicLab.Persistence.Default.DebugString; 36 using HeuristicLab.Persistence.Default.Xml; 37 using HeuristicLab.Persistence.Default.Xml.Primitive; 38 using HeuristicLab.Persistence.Interfaces; 26 39 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 using HeuristicLab.Persistence.Core;28 using System.Collections;29 using HeuristicLab.Persistence.Default.Xml;30 using HeuristicLab.Persistence.Default.DebugString;31 using System.IO;32 using System.Reflection;33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;34 using HeuristicLab.Persistence.Interfaces;35 using HeuristicLab.Persistence.Default.Xml.Primitive;36 using HeuristicLab.Persistence.Default.CompositeSerializers;37 using HeuristicLab.Persistence.Auxiliary;38 using System.Text.RegularExpressions;39 using System.Drawing;40 using System.Drawing.Imaging;41 40 42 41 namespace HeuristicLab.Persistence_33.Tests { … … 607 606 XmlGenerator.Serialize(c, tempFile); 608 607 Assert.Fail("Exception not thrown"); 609 } catch (PersistenceException) { 608 } 609 catch (PersistenceException) { 610 610 } 611 611 } … … 619 619 XmlGenerator.Serialize(s, tempFile); 620 620 Assert.Fail("Exception expected"); 621 } catch (PersistenceException) { } 621 } 622 catch (PersistenceException) { } 622 623 List<int> newList = (List<int>)XmlParser.Deserialize(tempFile); 623 624 Assert.AreEqual(list[0], newList[0]); … … 658 659 } 659 660 Assert.Fail("Exception expected"); 660 } catch (PersistenceException px) { 661 } 662 catch (PersistenceException px) { 661 663 Assert.AreEqual(3, px.Data.Count); 662 664 } … … 686 688 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString))); 687 689 Assert.Fail("Exception expected"); 688 } catch (PersistenceException x) { 690 } 691 catch (PersistenceException x) { 689 692 Assert.IsTrue(x.Message.Contains("incompatible")); 690 693 } … … 695 698 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString))); 696 699 Assert.Fail("Exception expected"); 697 } catch (PersistenceException x) { 700 } 701 catch (PersistenceException x) { 698 702 Assert.IsTrue(x.Message.Contains("newer")); 699 703 } … … 862 866 ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile); 863 867 Assert.Fail("Exception expected"); 864 } catch (PersistenceException pe) { 868 } 869 catch (PersistenceException pe) { 865 870 Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail"); 866 871 } … … 873 878 XmlGenerator.Serialize(ns, tempFile); 874 879 Assert.Fail("PersistenceException expected"); 875 } catch (PersistenceException x) { 880 } 881 catch (PersistenceException x) { 876 882 Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable)))); 877 883 }
Note: See TracChangeset
for help on using the changeset viewer.