Last change
on this file since 3494 was
1823,
checked in by epitzer, 16 years ago
|
Namespace refactoring: rename formatters & decomposers -> primitive and composite serializers. (#603)
|
File size:
1.1 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using HeuristicLab.Persistence.Core;
|
---|
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Persistence.Test {
|
---|
8 |
|
---|
9 | class DemoClass {
|
---|
10 |
|
---|
11 | [Storable(Name = "TestProperty", DefaultValue = 12)]
|
---|
12 | public object o;
|
---|
13 |
|
---|
14 | [Storable]
|
---|
15 | public int x = 2;
|
---|
16 |
|
---|
17 | public int y;
|
---|
18 |
|
---|
19 | }
|
---|
20 |
|
---|
21 | [TestClass]
|
---|
22 | public class AttributeTest {
|
---|
23 |
|
---|
24 | [TestMethod]
|
---|
25 | public void SimpleStorableAttributeTest() {
|
---|
26 | DemoClass t = new DemoClass();
|
---|
27 | Dictionary<string, DataMemberAccessor> accessors = StorableAttribute.GetStorableAccessors(t);
|
---|
28 | Assert.IsTrue(accessors.ContainsKey("o"));
|
---|
29 | Assert.IsTrue(accessors.ContainsKey("x"));
|
---|
30 | Assert.IsFalse(accessors.ContainsKey("y"));
|
---|
31 | object o = new object();
|
---|
32 | t.o = o;
|
---|
33 | Assert.AreSame(accessors["o"].Get(), o);
|
---|
34 | t.x = 12;
|
---|
35 | Assert.AreEqual(accessors["x"].Get(), 12);
|
---|
36 | t.y = 312890;
|
---|
37 | accessors["o"].Set(null);
|
---|
38 | Assert.IsNull(t.o);
|
---|
39 | accessors["x"].Set(123);
|
---|
40 | Assert.AreEqual(t.x, 123);
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.