2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
18 public class ParserTest : UnitTest
20 public void ParseTest()
22 Expect(
CUIParser.Parse(
"123", typeof(
int))).ToBeEqual(123);
23 Expect(
CUIParser.Parse(
"123", typeof(
string))).ToBeEqual(
"123");
24 Expect(
CUIParser.Parse(
"123", typeof(
float))).ToBeEqual(123.0f);
25 Expect(
CUIParser.Parse(
"123", typeof(
double))).ToBeEqual(123.0);
26 Expect(
CUIParser.Parse(
"bebe", typeof(
double))).ToBeEqual(0.0);
27 Expect(
CUIParser.Parse(
"BoOl", typeof(
bool))).ToBeEqual(
false);
28 Expect(
CUIParser.Parse(
"TrUe", typeof(
bool))).ToBeEqual(
true);
30 Expect(
CUIParser.Parse(
"Reverse", typeof(CUIDirection))).ToBeEqual(CUIDirection.Reverse);
31 Expect(
CUIParser.Parse(
"Beberse", typeof(CUIDirection))).ToBeEqual(CUIDirection.Straight);
33 Expect(
CUIParser.Parse(
"[2,2]", typeof(Vector2))).ToBeEqual(
new Vector2(2, 2));
34 Expect(
CUIParser.Parse(
"red", typeof(Color))).ToBeEqual(
new Color(255, 0, 0));
37 public void SerializeTest()
39 Expect(
CUIParser.Serialize(
new Vector2(2, 2))).ToBeEqual(
"[2,2]");
40 Expect(
CUIParser.Serialize(2)).ToBeEqual(
"2");
41 Expect(
CUIParser.Serialize(2 + 2 == 4)).ToBeEqual(
"True");
42 Expect(
CUIParser.Serialize(Color.Red)).ToBeEqual(
"255,0,0,255");
Class for easy parsing and serialization of anything.