- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.