1 /**
2  * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved.
3  * Authors: Jacob Carlborg
4  * Version: Initial created: Aug 6, 2011
5  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6  */
7 module spec.serialization.Typedef;
8 
9 import dspec.Dsl;
10 
11 version (D_Version2) {}
12 else:
13 mixin("
14 import mambo.core.string;
15 import mambo.serialization.Serializer;
16 import mambo.serialization.archives.XmlArchive;
17 import spec.serialization.Util;
18 
19 Serializer serializer;
20 XmlArchive!(char) archive;
21 
22 typedef int Int;
23 
24 class I
25 {
26 	Int a;
27 }
28 
29 I i;
30 
31 unittest
32 {
33 	archive = new XmlArchive!(char);
34 	serializer = new Serializer(archive);
35 
36 	i = new I;
37 	i.a = 1;
38 
39 	describe(\"serialize typedef\") in {
40 		it(\"should return a serialized typedef\") in {
41 			serializer.reset();
42 			serializer.serialize(i);
43 			assert(archive.data().containsDefaultXmlContent());
44 			assert(archive.data().containsXmlTag(\"object\", `runtimeType=\"tests.Typedef.I\" type=\"tests.Typedef.I\" key=\"0\" id=\"0\"`));
45 			assert(archive.data().containsXmlTag(\"typedef\", `type=\"tests.Typedef.Int\" key=\"a\" id=\"2\"`));
46 			assert(archive.data().containsXmlTag(\"int\", `key=\"1\" id=\"3\"`, \"1\"));
47 		};
48 	};
49 	
50 	// describe(\"deserialize typedef\") in {
51 	// 	it(\"should return a deserialized typedef equal to the original typedef\") in {
52 	// 		auto iDeserialized = serializer.deserialize!(I)(archive.untypedData);
53 	// 		assert(i.a == iDeserialized.a);
54 	// 	};
55 	// };
56 }");