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;
19 public class StyleInheritance : UnitTest
23 [CUISerializable]
public Color prop0 {
get;
set; }
24 [CUISerializable]
public Color prop1 {
get;
set; }
25 [CUISerializable]
public Color prop2 {
get;
set; }
26 [CUISerializable]
public Color prop3 {
get;
set; }
27 [CUISerializable]
public Color prop4 {
get;
set; }
28 [CUISerializable]
public Color prop5 {
get;
set; }
29 [CUISerializable]
public Color prop6 {
get;
set; }
30 [CUISerializable]
public Color prop7 {
get;
set; }
32 [CUISerializable]
public Color prop8 {
get;
set; }
33 [CUISerializable]
public Color prop9 {
get;
set; }
34 [CUISerializable]
public Color prop10 {
get;
set; }
35 [CUISerializable]
public Color prop11 {
get;
set; }
36 [CUISerializable]
public Color prop12 {
get;
set; }
37 [CUISerializable]
public Color prop13 {
get;
set; }
38 [CUISerializable]
public Color prop14 {
get;
set; }
39 [CUISerializable]
public Color prop15 {
get;
set; }
40 [CUISerializable]
public Color guh {
get;
set; }
48 public class TestClassB : TestClassA
57 public void OneClassTest()
59 TestClassA testA =
new TestClassA();
61 CUIStyle.DefaultFor<TestClassA>()[
"prop1"] =
"red";
63 testA.Style[
"prop2"] =
"blue";
65 CUIStyle.DefaultFor<TestClassA>()[
"prop3"] =
"red";
66 testA.Style[
"prop3"] =
"blue";
68 testA.prop4 = Color.Lime;
70 CUIStyle.DefaultFor<TestClassA>()[
"prop5"] =
"red";
71 testA.prop5 = Color.Lime;
73 testA.Style[
"prop6"] =
"blue";
74 testA.prop6 = Color.Lime;
76 CUIStyle.DefaultFor<TestClassA>()[
"prop7"] =
"red";
77 testA.Style[
"prop7"] =
"blue";
78 testA.prop7 = Color.Lime;
80 Expect(testA.prop0).ToBeEqual(Color.Transparent);
81 Expect(testA.prop1).ToBeEqual(Color.Red);
82 Expect(testA.prop2).ToBeEqual(Color.Blue);
83 Expect(testA.prop3).ToBeEqual(Color.Blue);
84 Expect(testA.prop4).ToBeEqual(Color.Lime);
85 Expect(testA.prop5).ToBeEqual(Color.Lime);
86 Expect(testA.prop6).ToBeEqual(Color.Lime);
87 Expect(testA.prop7).ToBeEqual(Color.Lime);
89 Describe(
"-------------------------------", () => { Expect(
"guh").ToNotThrow(); });
95 public void TwoClassTest()
97 TestClassB testB =
new TestClassB();
99 for (
int i = 0; i < 2; i++)
101 for (
int j = 0; j < 2; j++)
103 for (
int k = 0; k < 2; k++)
105 for (
int l = 0; l < 2; l++)
107 int num = i + 2 * j + 4 * k + 8 * l;
108 string propName = $
"prop{num}";
109 PropertyInfo pi = typeof(TestClassB).GetProperty(propName);
111 if (i == 1)
CUIStyle.DefaultFor<TestClassA>()[propName] =
"red";
112 if (j == 1)
CUIStyle.DefaultFor<TestClassB>()[propName] =
"blue";
113 if (k == 1) testB.Style[propName] =
"lime";
114 if (l == 1) pi.SetValue(testB, Color.Yellow);
118 Expect(pi.GetValue(testB)).ToBeEqual(Color.Yellow);
124 Expect(pi.GetValue(testB)).ToBeEqual(Color.Lime);
130 Expect(pi.GetValue(testB)).ToBeEqual(Color.Blue);
136 Expect(pi.GetValue(testB)).ToBeEqual(Color.Red);
140 Expect(pi.GetValue(testB)).ToBeEqual(Color.Transparent);
153 public void SpecTest()
155 TestClassB testB =
new TestClassB();
157 CUIStyle.DefaultFor<TestClassA>()[
"guh"] =
"red";
162 Expect(testB.guh).ToBeEqual(Color.Red);
Base class for all components.
In Fact just an observable dict.