3 using System
.Reflection
;
6 using System
.Windows
.Controls
;
7 using System
.Windows
.Documents
;
8 using System
.Windows
.Ink
;
9 using System
.Windows
.Input
;
10 using System
.Windows
.Markup
;
11 using System
.Windows
.Media
;
12 using System
.Windows
.Media
.Animation
;
13 using System
.Windows
.Shapes
;
14 using System
.Collections
.Generic
;
15 using Mono
.Moonlight
.UnitTesting
;
16 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
17 using System
.Windows
.Data
;
18 using Microsoft
.Silverlight
.Testing
;
20 #pragma warning disable 414
21 #pragma warning disable 219
23 namespace MoonTest
.System
.Windows
26 public class DependencyPropertyTest
: SilverlightTest
29 * Declaring Type _ Property Name _ [index, not included in property name _] _ Property Type
31 private DependencyPropertyInfo Canvas_Custom_double
;
32 private DependencyPropertyInfo Canvas_Custom_nullable_double
;
33 private DependencyPropertyInfo Canvas_Custom_nullable_bool
;
34 private DependencyPropertyInfo Canvas_Custom_Canvas
;
35 private DependencyPropertyInfo Canvas_Custom_CustomClass
;
36 private DependencyPropertyInfo Canvas_Custom_CustomCanvasType
;
38 private DependencyPropertyInfo Canvas_Height_int
;
39 private DependencyPropertyInfo Canvas_Height_double
;
40 private DependencyPropertyInfo Canvas_Height_CustomClass
;
41 private DependencyPropertyInfo Canvas_Height_CustomCanvasType
;
43 private DependencyPropertyInfo CustomClass_Height_int
;
44 private DependencyPropertyInfo CustomClass_Height_double
;
45 private DependencyPropertyInfo CustomClass_Height_CustomClass
;
46 private DependencyPropertyInfo CustomClass_Height_CustomCanvasType
;
48 private DependencyPropertyInfo CustomCanvasType_Height_int
;
49 private DependencyPropertyInfo CustomCanvasType_Height_double
;
50 private DependencyPropertyInfo CustomCanvasType_Height_void
;
51 private DependencyPropertyInfo CustomCanvasType_Height_Canvas
;
52 private DependencyPropertyInfo CustomCanvasType_Height_CustomClass
;
53 private DependencyPropertyInfo CustomCanvasType_Height_CustomCanvasType
;
54 private DependencyPropertyInfo CustomCanvasType_Height_CustomInterface
;
55 private DependencyPropertyInfo CustomCanvasType_Height_CustomStruct
;
56 private DependencyPropertyInfo CustomCanvasType_Height_CustomEnum
;
57 private DependencyPropertyInfo CustomCanvasType_Height_CustomDelegate
;
58 private DependencyPropertyInfo CustomCanvasType_Height_CustomClassCtorA
;
59 private DependencyPropertyInfo CustomCanvasType_Height_CustomClassCtorB
;
61 private DependencyPropertyInfo CustomCanvasType2_Height_double
;
63 // These are interesting because Height is already defined on FrameworkElement
64 private DependencyPropertyInfo FrameworkElement_Height_int
;
65 private DependencyPropertyInfo FrameworkElement_Height_double
;
66 private DependencyPropertyInfo FrameworkElement_Height_CustomClass
;
69 public void Register_NullParametersTest ()
71 Assert
.Throws (delegate { DependencyProperty.Register (null, typeof (int), typeof (Canvas), new PropertyMetadata (null)); }
, typeof (ArgumentNullException
));
72 Assert
.Throws (delegate { DependencyProperty.Register (string.Empty, typeof (int), typeof (Canvas), new PropertyMetadata (null)); }
, typeof (ArgumentException
));
73 Assert
.Throws (delegate { DependencyProperty.Register ("a", null, typeof (Canvas), new PropertyMetadata (null)); }
, typeof (ArgumentNullException
));
74 Assert
.Throws (delegate { DependencyProperty.Register ("a", typeof (int), null, new PropertyMetadata (null)); }
, typeof (ArgumentNullException
));
75 // null PropertyMetadata shouldn't throw.
76 DependencyProperty
.Register ("a", typeof (int), typeof (Canvas
), null);
80 public void Register_HuhTest1 ()
82 DependencyPropertyInfo info
= new DependencyPropertyInfo ("Custom", typeof (InkPresenter
), typeof (int), false);
83 DependencyProperty property
= info
.Property
;
84 Canvas canvas
= new Canvas ();
86 canvas
.GetValue (property
); // This should throw, the property doesn't exist on the canvas.
88 Assert
.Throws (delegate { canvas.GetValue (InkPresenter.StrokesProperty); }
, typeof (Exception
)); // And this throws a catastrophic error.
91 static DependencyProperty ValidationOrderProperty
= DependencyProperty
.Register (
92 "ValidationOrder", typeof (double), typeof (ScrollViewer
),
93 new PropertyMetadata (new PropertyChangedCallback (OnReadOnlyDependencyPropertyChanged
)));
95 private static void OnReadOnlyDependencyPropertyChanged (DependencyObject d
, DependencyPropertyChangedEventArgs e
)
97 throw new InvalidOperationException ();
101 public void ValidationOrder ()
103 ScrollViewer sc
= new ScrollViewer ();
104 // we're setting a boolean value to a double DependencyProperty
105 // and even with a PropertyChangedCallback we still get the
106 // ArgumentException before the InvalidOperationException
107 Assert
.Throws
<ArgumentException
> (delegate {
108 sc
.SetValue (ValidationOrderProperty
, true);
109 }, "wrong value, callback is called later");
114 public void SameReferenceTest ()
119 // 'Core' types do not preserve the object reference
120 Assert
.AreNotSame (text
, new TextBox { Text = text }
.GetValue (TextBox
.TextProperty
), "#2");
121 Assert
.AreNotSame (text
, new TextBox { Name = text }
.GetValue (FrameworkElement
.NameProperty
), "#3");
122 Assert
.AreNotSame (text
, new TimelineMarker { Type = text }
.GetValue (TimelineMarker
.TypeProperty
), "#4");
123 Assert
.AreNotSame (o
, new ContentControl { Content = o }
.GetValue (ContentControl
.ContentProperty
), "#13");
124 Assert
.AreNotSame (o
, new DiscreteObjectKeyFrame { Value = o }
.GetValue (ObjectKeyFrame
.ValueProperty
), "#13");
126 // DataContext appears to be the odd one out here - it likes to break the 'rule'
127 Assert
.AreSame (o
, new TextBox { DataContext = o }
.GetValue (TextBox
.DataContextProperty
), "#12");
130 // 'User types' do preserve the object reference
131 Assert
.AreSame (text
, new TextBox { Tag = text }
.GetValue(FrameworkElement
.TagProperty
), "#6");
132 Assert
.AreSame (o
, new TextBox { Tag = o }
.GetValue (TextBox
.TagProperty
), "#11");
134 ManagedTestClass c
= new ManagedTestClass ();
135 c
.SetValue (ManagedTestClass
.A
.Property
, text
);
136 Assert
.AreSame (text
, c
._A_
, "#8");
138 ListBox box
= new ListBox ();
139 box
.Items
.Add (text
);
140 box
.SelectedItem
= text
;
141 Assert
.AreSame (text
, box
.GetValue (ListBox
.SelectedItemProperty
), "#9");
142 Assert
.AreSame (text
, box
.GetValue (ListBox
.SelectedItemProperty
), "#10");
147 #region Canvas Custom
149 public void Custom_Property_Parents ()
151 bool buttonLoaded
= false;
152 CustomCanvas canvas
= new CustomCanvas ();
153 TestPanel
.Children
.Add (canvas
);
154 canvas
.Child
= new Button { Name = "Ted" }
;
155 canvas
.Child2
= new Button { Name = "Ted" }
;
156 canvas
.Children
.Add (new Button { Name= "Ted" }
);
160 public void Register_Canvas_Custom_double ()
162 Canvas canvas
= new Canvas ();
163 CustomCanvasType custom_canvas
= new CustomCanvasType ();
164 DependencyProperty property
;
165 DependencyPropertyInfo info
;
166 DependencyPropertyInfo
.ChangedInfo changed_info
;
167 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
169 object previous_expected_value
= (double) 0;
173 Canvas_Custom_double
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (double), false);
174 info
= Canvas_Custom_double
;
176 property
= info
.Property
;
178 Assert
.AreEqual (0.0, (double) canvas
.GetValue (property
));
180 Assert
.AreEqual (0.0, (double) ink
.GetValue (property
));
182 Assert
.Throws (delegate { canvas.SetValue (property, 1); }
, typeof (ArgumentException
));
183 Assert
.Throws (delegate { canvas.SetValue (property, ""); }
, typeof (ArgumentException
));
184 Assert
.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
185 Assert
.Throws (delegate { canvas.SetValue (property, null); }
, typeof (ArgumentException
));
186 Assert
.Throws (delegate { canvas.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
188 foreach (object expected_value
in new object [] { 1.1 }
) {
191 canvas
.SetValue (property
, expected_value
);
192 actual_value
= canvas
.GetValue (property
);
194 if ((double) expected_value
!= (double) previous_expected_value
) {
196 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
197 Assert
.AreEqual ((double) changed_info
.args
.OldValue
, (double) previous_expected_value
);
198 Assert
.AreEqual ((double) changed_info
.args
.NewValue
, (double) expected_value
);
199 Assert
.AreSame (changed_info
.obj
, canvas
);
202 previous_expected_value
= expected_value
;
204 Assert
.AreEqual ((double) expected_value
, (double) actual_value
, "Iteration #{0}", iterations
);
205 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
209 public void Register_Canvas_Custom_nullable_double ()
211 Canvas canvas
= new Canvas ();
212 CustomCanvasType custom_canvas
= new CustomCanvasType ();
213 DependencyProperty property
;
214 DependencyPropertyInfo info
;
215 DependencyPropertyInfo
.ChangedInfo changed_info
;
216 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
218 object previous_expected_value
= null;
222 Canvas_Custom_nullable_double
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (Nullable
<double>), false);
223 info
= Canvas_Custom_nullable_double
;
225 property
= info
.Property
;
227 Assert
.AreEqual (null, (Nullable
<double>) canvas
.GetValue (property
));
229 Assert
.AreEqual (null, (Nullable
<double>) ink
.GetValue (property
));
231 Assert
.Throws (delegate { canvas.SetValue (property, 1); }
, typeof (ArgumentException
));
232 Assert
.Throws (delegate { canvas.SetValue (property, ""); }
, typeof (ArgumentException
));
233 Assert
.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
234 Assert
.Throws (delegate { canvas.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
236 foreach (object expected_value
in new object [] { (Nullable<double>) 1.1, null, 2.2 }
) {
239 canvas
.SetValue (property
, expected_value
);
240 actual_value
= canvas
.GetValue (property
);
242 if ((Nullable
<double>) expected_value
!= (Nullable
<double>) previous_expected_value
) {
244 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
245 Assert
.AreEqual ((Nullable
<double>) changed_info
.args
.OldValue
, (Nullable
<double>) previous_expected_value
);
246 Assert
.AreEqual ((Nullable
<double>) changed_info
.args
.NewValue
, (Nullable
<double>) expected_value
);
247 Assert
.AreSame (changed_info
.obj
, canvas
);
250 previous_expected_value
= expected_value
;
252 Assert
.AreEqual ((Nullable
<double>) expected_value
, (Nullable
<double>) actual_value
, "Iteration #{0}", iterations
);
253 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
258 public void Register_Canvas_Custom_nullable_bool ()
260 Canvas canvas
= new Canvas ();
261 CustomCanvasType custom_canvas
= new CustomCanvasType ();
262 DependencyProperty property
;
263 DependencyPropertyInfo info
;
264 DependencyPropertyInfo
.ChangedInfo changed_info
;
265 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
267 object previous_expected_value
= null;
271 Canvas_Custom_nullable_bool
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (Nullable
<bool>), false);
272 info
= Canvas_Custom_nullable_bool
;
274 property
= info
.Property
;
276 Assert
.AreEqual (null, (Nullable
<bool>) canvas
.GetValue (property
));
278 Assert
.AreEqual (null, (Nullable
<bool>) ink
.GetValue (property
));
280 Assert
.Throws (delegate { canvas.SetValue (property, 1); }
, typeof (ArgumentException
));
281 Assert
.Throws (delegate { canvas.SetValue (property, ""); }
, typeof (ArgumentException
));
282 Assert
.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
283 Assert
.Throws (delegate { canvas.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
285 foreach (object expected_value
in new object [] { (Nullable<bool>) true, null, false, null, (Nullable<bool>) false, (Nullable<bool>) true}
) {
288 canvas
.SetValue (property
, expected_value
);
289 actual_value
= canvas
.GetValue (property
);
291 if ((Nullable
<bool>) expected_value
!= (Nullable
<bool>) previous_expected_value
) {
293 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
294 Assert
.AreEqual ((Nullable
<bool>) changed_info
.args
.OldValue
, (Nullable
<bool>) previous_expected_value
);
295 Assert
.AreEqual ((Nullable
<bool>) changed_info
.args
.NewValue
, (Nullable
<bool>) expected_value
);
296 Assert
.AreSame (changed_info
.obj
, canvas
);
299 previous_expected_value
= expected_value
;
301 Assert
.AreEqual ((Nullable
<bool>) expected_value
, (Nullable
<bool>) actual_value
, "Iteration #{0}", iterations
);
302 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
307 public void Register_Canvas_Custom_CustomClass ()
309 Canvas_Custom_CustomClass
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (CustomClass
), false);
313 public void Register_Canvas_Custom_Canvas ()
315 Canvas canvas
= new Canvas ();
316 CustomCanvasType custom_canvas
= new CustomCanvasType ();
317 DependencyProperty property
;
318 DependencyPropertyInfo info
;
319 DependencyPropertyInfo
.ChangedInfo changed_info
;
320 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
322 object previous_expected_value
= null;
326 Canvas_Custom_Canvas
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (Canvas
), false);
327 info
= Canvas_Custom_Canvas
;
329 property
= info
.Property
;
331 Assert
.IsNull (canvas
.GetValue (property
));
332 Assert
.IsNull (ink
.GetValue (property
));
334 Assert
.Throws (delegate { canvas.SetValue (property, 1); }
, typeof (ArgumentException
));
335 Assert
.Throws (delegate { canvas.SetValue (property, ""); }
, typeof (ArgumentException
));
336 Assert
.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
338 foreach (object expected_value
in new object [] { null, new Canvas (), null, canvas, canvas, null, new CustomCanvasType (), custom_canvas, custom_canvas, ink}
) {
341 canvas
.SetValue (property
, expected_value
);
342 actual_value
= canvas
.GetValue (property
);
344 if (expected_value
!= previous_expected_value
) {
346 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
347 Assert
.AreSame (changed_info
.args
.OldValue
, previous_expected_value
);
348 Assert
.AreSame (changed_info
.args
.NewValue
, expected_value
);
349 Assert
.AreSame (changed_info
.obj
, canvas
);
352 previous_expected_value
= expected_value
;
354 Assert
.AreSame (expected_value
, actual_value
, "Iteration #{0}", iterations
);
355 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
360 public void Register_Canvas_Custom_CustomCanvasType ()
362 Canvas_Custom_CustomCanvasType
= new DependencyPropertyInfo ("Custom", typeof (Canvas
), typeof (CustomCanvasType
), false);
365 #region Canvas Height
367 public void Register_Canvas_Height_int ()
369 // Register a custom property with the same name and type as an existing builtin property
370 Canvas_Height_int
= new DependencyPropertyInfo ("Height", typeof (Canvas
), typeof (int), false);
374 public void Register_Canvas_Height_double ()
376 // Register a custom property with the same name and type as an existing builtin property
377 Canvas_Height_double
= new DependencyPropertyInfo ("Height", typeof (Canvas
), typeof (double), false);
381 public void Register_Canvas_Height_CustomClass ()
383 // Register a custom property with the same name (but not type) as an existing builtin AND another custom property
384 Canvas_Height_CustomClass
= new DependencyPropertyInfo ("Height", typeof (Canvas
), typeof (CustomClass
), false);
388 public void Register_Canvas_Height_CustomCanvasType ()
390 // Register a custom property with the same name (but not type) as an existing builtin AND another custom property
391 Canvas_Height_CustomCanvasType
= new DependencyPropertyInfo ("Height", typeof (Canvas
), typeof (CustomCanvasType
), false);
394 #region CustomClass Height
396 public void Register_CustomClass_Height_int ()
398 CustomClass_Height_int
= new DependencyPropertyInfo ("Height", typeof (CustomClass
), typeof (int), false);
402 public void Register_CustomClass_Height_double ()
404 CustomClass_Height_double
= new DependencyPropertyInfo ("Height", typeof (CustomClass
), typeof (double), false);
408 public void Register_CustomClass_Height_CustomClass ()
410 CustomClass_Height_CustomClass
= new DependencyPropertyInfo ("Height", typeof (CustomClass
), typeof (CustomClass
), false);
414 public void Register_CustomClass_Height_CustomCanvasType ()
416 CustomClass_Height_CustomCanvasType
= new DependencyPropertyInfo ("Height", typeof (CustomClass
), typeof (CustomCanvasType
), false);
419 #region CustomCanvasType Height
421 public void Register_CustomCanvasType_Height_int ()
423 CustomCanvasType the_object
= new CustomCanvasType ();
424 CustomCanvasType custom_canvas
= new CustomCanvasType ();
425 Canvas canvas
= new Canvas ();
426 DependencyProperty property
;
427 DependencyPropertyInfo info
;
428 DependencyPropertyInfo
.ChangedInfo changed_info
;
429 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
431 object previous_expected_value
= (int) 0;
435 CustomCanvasType_Height_int
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (int), false);
436 info
= CustomCanvasType_Height_int
;
438 property
= info
.Property
;
440 Assert
.AreEqual (0, (int) the_object
.GetValue (property
));
441 Assert
.AreEqual (0, (int) ink
.GetValue (property
));
443 Assert
.Throws (delegate { the_object.SetValue (property, 1.1); }
, typeof (ArgumentException
));
444 Assert
.Throws (delegate { the_object.SetValue (property, "1"); }
, typeof (ArgumentException
));
445 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
446 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
447 Assert
.Throws (delegate { the_object.SetValue (property, null); }
, typeof (ArgumentException
));
448 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
450 foreach (object expected_value
in new object [] { 1, 1, 2 }
) {
453 the_object
.SetValue (property
, expected_value
);
454 actual_value
= the_object
.GetValue (property
);
456 if ((int) expected_value
!= (int) previous_expected_value
) {
458 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
459 Assert
.AreEqual ((int) changed_info
.args
.OldValue
, (int) previous_expected_value
);
460 Assert
.AreEqual ((int) changed_info
.args
.NewValue
, (int) expected_value
);
461 Assert
.AreSame (changed_info
.obj
, the_object
);
464 previous_expected_value
= expected_value
;
466 Assert
.AreEqual ((int) expected_value
, (int) actual_value
, "Iteration #{0}", iterations
);
467 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
472 public void Register_CustomCanvasType_Height_double ()
474 CustomCanvasType the_object
= new CustomCanvasType ();
475 CustomCanvasType custom_canvas
= new CustomCanvasType ();
476 Canvas canvas
= new Canvas ();
477 DependencyProperty property
;
478 DependencyPropertyInfo info
;
479 DependencyPropertyInfo
.ChangedInfo changed_info
;
480 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
482 object previous_expected_value
= (double) 0;
486 CustomCanvasType_Height_double
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (double), false);
487 info
= CustomCanvasType_Height_double
;
489 property
= info
.Property
;
491 Assert
.AreEqual (0.0, (double) the_object
.GetValue (property
));
492 Assert
.AreEqual (0.0, (double) ink
.GetValue (property
));
494 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
495 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
496 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
497 Assert
.Throws (delegate { the_object.SetValue (property, null); }
, typeof (ArgumentException
));
498 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
500 foreach (object expected_value
in new object [] { 1.1, 1.1, 2.2 }
) {
503 the_object
.SetValue (property
, expected_value
);
504 actual_value
= the_object
.GetValue (property
);
506 if ((double) expected_value
!= (double) previous_expected_value
) {
508 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
509 Assert
.AreEqual ((double) changed_info
.args
.OldValue
, (double) previous_expected_value
);
510 Assert
.AreEqual ((double) changed_info
.args
.NewValue
, (double) expected_value
);
511 Assert
.AreSame (changed_info
.obj
, the_object
);
514 previous_expected_value
= expected_value
;
516 Assert
.AreEqual ((double) expected_value
, (double) actual_value
, "Iteration #{0}", iterations
);
517 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
522 public void Register_CustomCanvasType_Height_void ()
524 Assert
.Throws (delegate { CustomCanvasType_Height_void = new DependencyPropertyInfo ("Height", typeof (CustomCanvasType), typeof (void), false);}
, typeof (NotSupportedException
));
528 public void Register_CustomCanvasType_Height_Canvas ()
530 CustomCanvasType_Height_Canvas
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (Canvas
), false);
534 public void Register_CustomCanvasType_Height_CustomClass ()
536 CustomCanvasType_Height_CustomClass
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomClass
), false);
540 public void Register_CustomCanvasType_Height_CustomCanvasType ()
542 CustomCanvasType_Height_CustomCanvasType
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomCanvasType
), false);
546 public void Register_CustomCanvasType_Height_CustomInterface ()
548 CustomCanvasType the_object
= new CustomCanvasType ();
549 CustomCanvasType custom_canvas
= new CustomCanvasType ();
550 Canvas canvas
= new Canvas ();
551 CustomStruct custom_struct_1
= new CustomStruct (1);
552 CustomEnum custom_enum
= CustomEnum
.EnumValue1
;
553 CustomDelegate custom_delegate
= delegate { }
;
554 CustomInterface custom_interface_a
= new CustomInterfaceImplA ();
555 CustomInterface custom_interface_b
= new CustomInterfaceImplB ();
556 DependencyProperty property
;
557 DependencyPropertyInfo info
;
558 DependencyPropertyInfo
.ChangedInfo changed_info
;
559 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
561 object previous_expected_value
= null;
565 CustomCanvasType_Height_CustomInterface
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomInterface
), false);
566 info
= CustomCanvasType_Height_CustomInterface
;
568 property
= info
.Property
;
570 Assert
.AreEqual (null, the_object
.GetValue (property
), "Default value 1");
571 Assert
.AreEqual (null, ink
.GetValue (property
), "Default value 2");
573 Assert
.Throws (delegate { the_object.SetValue (property, 0); }
, typeof (ArgumentException
));
574 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
575 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
576 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
577 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
578 Assert
.Throws (delegate { the_object.SetValue (property, custom_enum); }
, typeof (ArgumentException
));
580 foreach (object expected_value
in new object [] { null, custom_interface_a, null, custom_interface_b, custom_interface_b, null }
) {
583 the_object
.SetValue (property
, expected_value
);
584 actual_value
= the_object
.GetValue (property
);
586 if (!object.Equals (expected_value
, previous_expected_value
)) {
588 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
589 Assert
.AreEqual (changed_info
.args
.OldValue
, previous_expected_value
, "OldValue, iteration: " + iterations
.ToString ());
590 Assert
.AreEqual (changed_info
.args
.NewValue
, expected_value
, "NewValue, iteration: " + iterations
.ToString ());
591 Assert
.AreSame (changed_info
.obj
, the_object
);
594 previous_expected_value
= expected_value
;
596 Assert
.AreEqual (expected_value
, actual_value
, "Iteration #{0}", iterations
);
597 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
602 public void Register_CustomCanvasType_Height_CustomStruct ()
604 CustomCanvasType the_object
= new CustomCanvasType ();
605 CustomCanvasType custom_canvas
= new CustomCanvasType ();
606 Canvas canvas
= new Canvas ();
607 CustomStruct custom_struct_1
= new CustomStruct (1);
608 DependencyProperty property
;
609 DependencyPropertyInfo info
;
610 DependencyPropertyInfo
.ChangedInfo changed_info
;
611 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
613 object previous_expected_value
= new CustomStruct ();
617 CustomCanvasType_Height_CustomStruct
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomStruct
), false);
618 info
= CustomCanvasType_Height_CustomStruct
;
620 property
= info
.Property
;
622 Assert
.AreEqual (new CustomStruct (), (CustomStruct
) the_object
.GetValue (property
));
623 Assert
.AreEqual (new CustomStruct (), (CustomStruct
) ink
.GetValue (property
));
625 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
626 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
627 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
628 Assert
.Throws (delegate { the_object.SetValue (property, null); }
, typeof (ArgumentException
));
629 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
631 foreach (object expected_value
in new object [] { custom_struct_1, custom_struct_1, new CustomStruct (), new CustomStruct () }
) {
634 the_object
.SetValue (property
, expected_value
);
635 actual_value
= the_object
.GetValue (property
);
637 if (!object.Equals (expected_value
, previous_expected_value
)) {
639 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
640 Assert
.AreEqual (changed_info
.args
.OldValue
, previous_expected_value
);
641 Assert
.AreEqual (changed_info
.args
.NewValue
, expected_value
);
642 Assert
.AreSame (changed_info
.obj
, the_object
);
645 previous_expected_value
= expected_value
;
647 Assert
.AreEqual (expected_value
, actual_value
, "Iteration #{0}", iterations
);
648 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
653 public void Register_CustomCanvasType_Height_CustomEnum ()
655 CustomCanvasType the_object
= new CustomCanvasType ();
656 CustomCanvasType custom_canvas
= new CustomCanvasType ();
657 Canvas canvas
= new Canvas ();
658 CustomStruct custom_struct_1
= new CustomStruct (1);
659 CustomEnum custom_enum
= CustomEnum
.EnumValue1
;
660 DependencyProperty property
;
661 DependencyPropertyInfo info
;
662 DependencyPropertyInfo
.ChangedInfo changed_info
;
663 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
665 object previous_expected_value
= (CustomEnum
) 0;
669 CustomCanvasType_Height_CustomEnum
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomEnum
), false);
670 info
= CustomCanvasType_Height_CustomEnum
;
672 property
= info
.Property
;
674 Assert
.AreEqual ((CustomEnum
) 0, the_object
.GetValue (property
), "Default value 1");
675 Assert
.AreEqual ((CustomEnum
) 0, ink
.GetValue (property
), "Default value 2");
677 Assert
.Throws (delegate { the_object.SetValue (property, 0); }
, typeof (ArgumentException
));
678 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
679 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
680 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
681 Assert
.Throws (delegate { the_object.SetValue (property, null); }
, typeof (ArgumentException
));
682 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
684 foreach (object expected_value
in new object [] { CustomEnum.EnumValue1, CustomEnum.EnumValue1, CustomEnum.EnumValue2, (CustomEnum) 0, custom_enum, custom_enum}
) {
687 the_object
.SetValue (property
, expected_value
);
688 actual_value
= the_object
.GetValue (property
);
690 if (!object.Equals (expected_value
, previous_expected_value
)) {
692 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
693 Assert
.AreEqual (changed_info
.args
.OldValue
, previous_expected_value
, "OldValue");
694 Assert
.AreEqual (changed_info
.args
.NewValue
, expected_value
, "NewValue");
695 Assert
.AreSame (changed_info
.obj
, the_object
);
698 previous_expected_value
= expected_value
;
700 Assert
.AreEqual (expected_value
, actual_value
, "Iteration #{0}", iterations
);
701 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
706 public void Register_CustomCanvasType_Height_CustomDelegate ()
708 CustomCanvasType the_object
= new CustomCanvasType ();
709 CustomCanvasType custom_canvas
= new CustomCanvasType ();
710 Canvas canvas
= new Canvas ();
711 CustomStruct custom_struct_1
= new CustomStruct (1);
712 CustomEnum custom_enum
= CustomEnum
.EnumValue1
;
713 CustomDelegate custom_delegate
= delegate { }
;
714 DependencyProperty property
;
715 DependencyPropertyInfo info
;
716 DependencyPropertyInfo
.ChangedInfo changed_info
;
717 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
719 object previous_expected_value
= null;
723 CustomCanvasType_Height_CustomDelegate
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomDelegate
), false);
724 info
= CustomCanvasType_Height_CustomDelegate
;
726 property
= info
.Property
;
728 Assert
.AreEqual (null, the_object
.GetValue (property
), "Default value 1");
729 Assert
.AreEqual (null, ink
.GetValue (property
), "Default value 2");
731 Assert
.Throws (delegate { the_object.SetValue (property, 0); }
, typeof (ArgumentException
));
732 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
733 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
734 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
735 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
737 foreach (object expected_value
in new CustomDelegate
[] { null, delegate {}
, delegate {}, custom_delegate, custom_delegate }
) {
740 the_object
.SetValue (property
, expected_value
);
741 actual_value
= the_object
.GetValue (property
);
743 if (!object.Equals (expected_value
, previous_expected_value
)) {
745 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
746 Assert
.AreEqual (changed_info
.args
.OldValue
, previous_expected_value
, "OldValue");
747 Assert
.AreEqual (changed_info
.args
.NewValue
, expected_value
, "NewValue");
748 Assert
.AreSame (changed_info
.obj
, the_object
);
751 previous_expected_value
= expected_value
;
753 Assert
.AreEqual (expected_value
, actual_value
, "Iteration #{0}", iterations
);
754 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
759 public void Register_CustomCanvasType_Height_CustomClassCtorA ()
761 CustomCanvasType_Height_CustomClassCtorA
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomClassCtorA
), false);
765 public void Register_CustomCanvasType_Height_CustomClassCtorB ()
767 CustomCanvasType_Height_CustomClassCtorB
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType
), typeof (CustomClassCtorB
), false);
770 ///////////////////////////////////////////////////////
773 #region CustomCanvasType2 Height
776 public void Register_CustomCanvasType2_Height_double ()
778 CustomCanvasType2 the_object
= new CustomCanvasType2 ();
779 CustomCanvasType custom_canvas
= new CustomCanvasType ();
780 Canvas canvas
= new Canvas ();
781 DependencyProperty property
;
782 DependencyPropertyInfo info
;
783 DependencyPropertyInfo
.ChangedInfo changed_info
;
784 InkPresenter ink
= new InkPresenter (); // The only builtin type derived from Canvas
786 object previous_expected_value
= (double) 0;
790 CustomCanvasType2_Height_double
= new DependencyPropertyInfo ("Height", typeof (CustomCanvasType2
), typeof (double), false);
791 info
= CustomCanvasType2_Height_double
;
793 property
= info
.Property
;
795 Assert
.AreEqual (0.0, (double) the_object
.GetValue (property
));
796 Assert
.AreEqual (0.0, (double) ink
.GetValue (property
));
797 Assert
.AreEqual (0.0, (double) custom_canvas
.GetValue (property
));
799 Assert
.Throws (delegate { the_object.SetValue (property, 1); }
, typeof (ArgumentException
));
800 Assert
.Throws (delegate { the_object.SetValue (property, ""); }
, typeof (ArgumentException
));
801 Assert
.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }
, typeof (ArgumentException
));
802 Assert
.Throws (delegate { the_object.SetValue (property, null); }
, typeof (ArgumentException
));
803 Assert
.Throws (delegate { the_object.SetValue (property, new Canvas ()); }
, typeof (ArgumentException
));
805 Assert
.Throws (delegate { custom_canvas.SetValue (property, 1.1); }
, typeof (ArgumentException
));
807 foreach (object expected_value
in new object [] { 1.1 }
) {
810 the_object
.SetValue (property
, expected_value
);
811 actual_value
= the_object
.GetValue (property
);
813 if ((double) expected_value
!= (double) previous_expected_value
) {
815 changed_info
= info
.Changes
[info
.Changes
.Count
- 1];
816 Assert
.AreEqual ((double) changed_info
.args
.OldValue
, (double) previous_expected_value
);
817 Assert
.AreEqual ((double) changed_info
.args
.NewValue
, (double) expected_value
);
818 Assert
.AreSame (changed_info
.obj
, the_object
);
821 previous_expected_value
= expected_value
;
823 Assert
.AreEqual ((double) expected_value
, (double) actual_value
, "Iteration #{0}", iterations
);
824 Assert
.AreEqual (changes
, info
.Changes
.Count
, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations
, changes
, info
.Changes
.Count
);
828 #region FrameworkElement Height
830 public void Register_FrameworkElement_Height_int ()
832 FrameworkElement_Height_int
= new DependencyPropertyInfo ("Height", typeof (FrameworkElement
), typeof (int), false);
836 public void Register_FrameworkElement_Height_double ()
838 FrameworkElement_Height_double
= new DependencyPropertyInfo ("Height", typeof (FrameworkElement
), typeof (double), false);
842 public void Register_FrameworkElement_Height_CustomClass ()
844 FrameworkElement_Height_CustomClass
= new DependencyPropertyInfo ("Height", typeof (FrameworkElement
), typeof (CustomClass
), false);
848 #region DefaultValue tests
850 public void DefaultValue_Run_Foreground ()
852 Assert
.Throws
<UnauthorizedAccessException
> (delegate {
854 ((SolidColorBrush
)r
.Foreground
).Color
= Colors
.Blue
;
855 }, "modifying the default value of a property should throw an exception");
859 #region Custom types, etc
862 public class CustomCanvasType
: Canvas
865 public class CustomCanvasType2
: Canvas
868 public class CustomDerivedClass
: CustomClass
872 public class CustomClass
875 public struct CustomStruct
879 public CustomStruct (int v
) { this.value = v; }
881 public override string ToString ()
883 return "<CustomStruct (" + value.ToString () + ")>";
886 public interface CustomInterface
890 public class CustomInterfaceImplA
: CustomInterface
892 public void Method ()
894 throw new NotImplementedException ();
897 public class CustomInterfaceImplB
: CustomInterface
899 public void Method ()
901 throw new NotImplementedException ();
905 public delegate void CustomDelegate ();
906 public enum CustomEnum
911 // A class with no default ctor
912 public class CustomClassCtorA
914 public CustomClassCtorA (string an_argument
) { }
916 // A class with a private default ctor
917 public class CustomClassCtorB
919 private CustomClassCtorB () {}
926 public void ManagedTest_A ()
928 ManagedTestClass mtc
;
929 string format
= "'{1}' => '{2}'";
934 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_A1.xaml");
935 Assert
.AreEqual ("ok", mtc
._A_
, "A1-A");
936 Assert
.AreEqual ("b", mtc
._b_
, "A1-b");
937 Assert
.AreEqual ("c", mtc
._c_
, "A1-c");
938 Assert
.AreEqual ("C", mtc
._C_
, "A1-C");
939 Assert
.AreEqual ("D", mtc
._D_1_
, "A1-D1");
940 Assert
.AreEqual ("d", mtc
._d_2_
, "A1-D2");
941 Assert
.AreEqual ("d", mtc
._d_3_
, "A1-D3");
942 Assert
.AreEqual ("'A' => 'ok'", ManagedTestClass
.A
.ChangesToString (format
, sep
), "A1-A-Changes");
943 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "A1-b-Changes");
944 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "A1-c-Changes");
945 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "A1-C-Changes");
946 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "A1-D1-Changes");
947 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "A1-d2-Changes");
948 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "A1-d3-Changes");
950 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_A2.xaml");
951 Assert
.AreEqual ("ok", mtc
._A_
, "A2-A");
952 Assert
.AreEqual ("b", mtc
._b_
, "A2-b");
953 Assert
.AreEqual ("c", mtc
._c_
, "A2-c");
954 Assert
.AreEqual ("C", mtc
._C_
, "A2-C");
955 Assert
.AreEqual ("D", mtc
._D_1_
, "A2-D1");
956 Assert
.AreEqual ("d", mtc
._d_2_
, "A2-D2");
957 Assert
.AreEqual ("d", mtc
._d_3_
, "A2-D3");
958 Assert
.AreEqual ("'A' => 'ok'", ManagedTestClass
.A
.ChangesToString (format
, sep
), "A2-A-Changes");
959 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "A2-b-Changes");
960 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "A2-c-Changes");
961 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "A2-C-Changes");
962 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "A2-D1-Changes");
963 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "A2-d2-Changes");
964 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "A2-d3-Changes");
967 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_A3.xaml");
968 Assert
.AreEqual ("ok-2", mtc
._A_
, "A3-A");
969 Assert
.AreEqual ("b", mtc
._b_
, "A3-b");
970 Assert
.AreEqual ("c", mtc
._c_
, "A3-c");
971 Assert
.AreEqual ("C", mtc
._C_
, "A3-C");
972 Assert
.AreEqual ("D", mtc
._D_1_
, "A3-D1");
973 Assert
.AreEqual ("d", mtc
._d_2_
, "A3-D2");
974 Assert
.AreEqual ("d", mtc
._d_3_
, "A3-D3");
975 Assert
.AreEqual ("'A' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.A
.ChangesToString (format
, sep
), "A3-A-Changes");
976 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "A3-b-Changes");
977 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "A3-c-Changes");
978 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "A3-C-Changes");
979 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "A3-D1-Changes");
980 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "A3-d2-Changes");
981 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "A3-d3-Changes");
987 public void ManagedTest_B ()
989 ManagedTestClass mtc
;
990 string format
= "'{1}' => '{2}'";
995 Assert
.Throws
<XamlParseException
> (delegate () { mtc = new ManagedTestClass ("DependencyPropertyTest_ManagedTest_B1.xaml"); }
);
997 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_B2.xaml");
998 Assert
.AreEqual ("A", mtc
._A_
, "B2-A");
999 Assert
.AreEqual ("ok", mtc
._b_
, "B2-b");
1000 Assert
.AreEqual ("c", mtc
._c_
, "B2-c");
1001 Assert
.AreEqual ("C", mtc
._C_
, "B2-C");
1002 Assert
.AreEqual ("D", mtc
._D_1_
, "B2-D1");
1003 Assert
.AreEqual ("d", mtc
._d_2_
, "B2-D2");
1004 Assert
.AreEqual ("d", mtc
._d_3_
, "B2-D3");
1005 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "B2-A-Changes");
1006 Assert
.AreEqual ("'b' => 'ok'", ManagedTestClass
.b
.ChangesToString (format
, sep
), "B2-b-Changes");
1007 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "B2-c-Changes");
1008 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "B2-C-Changes");
1009 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "B2-D1-Changes");
1010 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "B2-d2-Changes");
1011 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "B2-d3-Changes");
1013 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_B3.xaml");
1014 Assert
.AreEqual ("A", mtc
._A_
, "B3-A");
1015 Assert
.AreEqual ("ok-2", mtc
._b_
, "B3-b");
1016 Assert
.AreEqual ("c", mtc
._c_
, "B3-c");
1017 Assert
.AreEqual ("C", mtc
._C_
, "B3-C");
1018 Assert
.AreEqual ("D", mtc
._D_1_
, "B3-D1");
1019 Assert
.AreEqual ("d", mtc
._d_2_
, "B3-D2");
1020 Assert
.AreEqual ("d", mtc
._d_3_
, "B3-D3");
1021 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "B3-A-Changes");
1022 Assert
.AreEqual ("'b' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.b
.ChangesToString (format
, sep
), "B3-b-Changes");
1023 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "B3-c-Changes");
1024 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "B3-C-Changes");
1025 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "B3-D1-Changes");
1026 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "B3-d2-Changes");
1027 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "B3-d3-Changes");
1032 public void ManagedTest_C ()
1034 ManagedTestClass mtc
;
1035 string format
= "'{1}' => '{2}'";
1039 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_C1.xaml");
1040 Assert
.AreEqual ("A", mtc
._A_
, "C1-A");
1041 Assert
.AreEqual ("b", mtc
._b_
, "C1-b");
1042 Assert
.AreEqual ("c", mtc
._c_
, "C1-c");
1043 Assert
.AreEqual ("ok", mtc
._C_
, "C1-C");
1044 Assert
.AreEqual ("D", mtc
._D_1_
, "C1-D1");
1045 Assert
.AreEqual ("d", mtc
._d_2_
, "C1-D2");
1046 Assert
.AreEqual ("d", mtc
._d_3_
, "C1-D3");
1047 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "C1-A-Changes");
1048 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "C1-b-Changes");
1049 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "C1-c-Changes");
1050 Assert
.AreEqual ("'C' => 'ok'", ManagedTestClass
.C
.ChangesToString (format
, sep
), "C1-C-Changes");
1051 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "C1-D1-Changes");
1052 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "C1-d2-Changes");
1053 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "C1-d3-Changes");
1055 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_C2.xaml");
1056 Assert
.AreEqual ("A", mtc
._A_
, "C2-A");
1057 Assert
.AreEqual ("b", mtc
._b_
, "C2-b");
1058 Assert
.AreEqual ("c", mtc
._c_
, "C2-c");
1059 Assert
.AreEqual ("ok", mtc
._C_
, "C2-C");
1060 Assert
.AreEqual ("D", mtc
._D_1_
, "C2-D1");
1061 Assert
.AreEqual ("d", mtc
._d_2_
, "C2-D2");
1062 Assert
.AreEqual ("d", mtc
._d_3_
, "C2-D3");
1063 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "C2-A-Changes");
1064 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "C2-b-Changes");
1065 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "C2-c-Changes");
1066 Assert
.AreEqual ("'C' => 'ok'", ManagedTestClass
.C
.ChangesToString (format
, sep
), "C2-C-Changes");
1067 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "C2-D1-Changes");
1068 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "C2-d2-Changes");
1069 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "C2-d3-Changes");
1071 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_C3.xaml");
1072 Assert
.AreEqual ("A", mtc
._A_
, "C3-A");
1073 Assert
.AreEqual ("b", mtc
._b_
, "C3-b");
1074 Assert
.AreEqual ("c", mtc
._c_
, "C3-c");
1075 Assert
.AreEqual ("ok-2", mtc
._C_
, "C3-C");
1076 Assert
.AreEqual ("D", mtc
._D_1_
, "C3-D1");
1077 Assert
.AreEqual ("d", mtc
._d_2_
, "C3-D2");
1078 Assert
.AreEqual ("d", mtc
._d_3_
, "C3-D3");
1079 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "C3-A-Changes");
1080 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "C3-b-Changes");
1081 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "C3-c-Changes");
1082 Assert
.AreEqual ("'C' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.C
.ChangesToString (format
, sep
), "C3-C-Changes");
1083 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "C3-D1-Changes");
1084 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "C3-d2-Changes");
1085 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "C3-d3-Changes");
1090 public void ManagedTest_D ()
1092 ManagedTestClass mtc
;
1093 string format
= "'{1}' => '{2}'";
1098 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_D1.xaml");
1099 Assert
.AreEqual ("A", mtc
._A_
, "D1-A");
1100 Assert
.AreEqual ("b", mtc
._b_
, "D1-b");
1101 Assert
.AreEqual ("c", mtc
._c_
, "D1-c");
1102 Assert
.AreEqual ("C", mtc
._C_
, "D1-C");
1103 Assert
.AreEqual ("ok", mtc
._D_1_
, "D1-D1");
1104 Assert
.AreEqual ("d", mtc
._d_2_
, "D1-D2");
1105 Assert
.AreEqual ("d", mtc
._d_3_
, "D1-D3");
1106 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "D1-A-Changes");
1107 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "D1-b-Changes");
1108 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "D1-c-Changes");
1109 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "D1-C-Changes");
1110 Assert
.AreEqual ("'D' => 'ok'", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "D1-D1-Changes");
1111 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "D1-d2-Changes");
1112 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "C3-d3-Changes");
1114 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_D2.xaml");
1115 Assert
.AreEqual ("A", mtc
._A_
, "D2-A");
1116 Assert
.AreEqual ("b", mtc
._b_
, "D2-b");
1117 Assert
.AreEqual ("c", mtc
._c_
, "D2-c");
1118 Assert
.AreEqual ("C", mtc
._C_
, "D2-C");
1119 Assert
.AreEqual ("ok", mtc
._D_1_
, "D2-D1");
1120 Assert
.AreEqual ("d", mtc
._d_2_
, "D2-D2");
1121 Assert
.AreEqual ("d", mtc
._d_3_
, "D2-D3");
1122 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "D2-A-Changes");
1123 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "D2-b-Changes");
1124 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "D2-c-Changes");
1125 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "D2-C-Changes");
1126 Assert
.AreEqual ("'D' => 'ok'", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "D2-D1-Changes");
1127 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "D2-d2-Changes");
1128 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "D2-d3-Changes");
1130 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_D3.xaml");
1131 Assert
.AreEqual ("A", mtc
._A_
, "D3-A");
1132 Assert
.AreEqual ("b", mtc
._b_
, "D3-b");
1133 Assert
.AreEqual ("c", mtc
._c_
, "D3-c");
1134 Assert
.AreEqual ("C", mtc
._C_
, "D3-C");
1135 Assert
.AreEqual ("ok-2", mtc
._D_1_
, "D3-D1");
1136 Assert
.AreEqual ("d", mtc
._d_2_
, "D3-D2");
1137 Assert
.AreEqual ("d", mtc
._d_3_
, "D3-D3");
1138 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "D3-A-Changes");
1139 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "D3-b-Changes");
1140 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "D3-c-Changes");
1141 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "D3-C-Changes");
1142 Assert
.AreEqual ("'D' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "D3-D1-Changes");
1143 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "D3-d2-Changes");
1144 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "D3-d3-Changes");
1146 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_D4.xaml");
1147 Assert
.AreEqual ("A", mtc
._A_
, "D4-A");
1148 Assert
.AreEqual ("b", mtc
._b_
, "D4-b");
1149 Assert
.AreEqual ("c", mtc
._c_
, "D4-c");
1150 Assert
.AreEqual ("C", mtc
._C_
, "D4-C");
1151 Assert
.AreEqual ("ok-2", mtc
._D_1_
, "D4-D1");
1152 Assert
.AreEqual ("d", mtc
._d_2_
, "D4-D2");
1153 Assert
.AreEqual ("d", mtc
._d_3_
, "D4-D3");
1154 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "D4-A-Changes");
1155 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "D4-b-Changes");
1156 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "D4-c-Changes");
1157 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "D4-C-Changes");
1158 Assert
.AreEqual ("'D' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "D4-D1-Changes");
1159 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "D4-d2-Changes");
1160 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "D4-d3-Changes");
1165 public void ManagedTest_E ()
1167 ManagedTestClass mtc
;
1168 string format
= "'{1}' => '{2}'";
1172 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_E1.xaml");
1173 Assert
.AreEqual ("A", mtc
._A_
, "E1-A");
1174 Assert
.AreEqual ("b", mtc
._b_
, "E1-b");
1175 Assert
.AreEqual ("c", mtc
._c_
, "E1-c");
1176 Assert
.AreEqual ("C", mtc
._C_
, "E1-C");
1177 Assert
.AreEqual ("D", mtc
._D_1_
, "E1-D1");
1178 Assert
.AreEqual ("d", mtc
._d_2_
, "E1-D2");
1179 Assert
.AreEqual ("d", mtc
._d_3_
, "E1-D3");
1180 Assert
.AreEqual ("E", mtc
._E_1_
, "E1-E1");
1181 Assert
.AreEqual ("E", mtc
._E_2_
, "E1-E2");
1182 Assert
.AreEqual ("ok", mtc
._E_3_
, "E1-E3");
1183 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "E1-A-Changes");
1184 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "E1-b-Changes");
1185 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "E1-c-Changes");
1186 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "E1-C-Changes");
1187 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "E1-D1-Changes");
1188 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "E1-d2-Changes");
1189 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "E1-d3-Changes");
1190 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "E1-E1-Changes");
1191 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "E1-E2-Changes");
1192 Assert
.AreEqual ("'E' => 'ok'", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "E1-E3-Changes");
1194 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_E2.xaml");
1195 Assert
.AreEqual ("A", mtc
._A_
, "E2-A");
1196 Assert
.AreEqual ("b", mtc
._b_
, "E2-b");
1197 Assert
.AreEqual ("c", mtc
._c_
, "E2-c");
1198 Assert
.AreEqual ("C", mtc
._C_
, "E2-C");
1199 Assert
.AreEqual ("D", mtc
._D_1_
, "E2-D1");
1200 Assert
.AreEqual ("d", mtc
._d_2_
, "E2-D2");
1201 Assert
.AreEqual ("d", mtc
._d_3_
, "E2-D3");
1202 Assert
.AreEqual ("E", mtc
._E_1_
, "E2-E1");
1203 Assert
.AreEqual ("E", mtc
._E_2_
, "E2-E2");
1204 Assert
.AreEqual ("ok", mtc
._E_3_
, "E2-E3");
1205 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "E2-A-Changes");
1206 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "E2-b-Changes");
1207 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "E2-c-Changes");
1208 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "E2-C-Changes");
1209 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "E2-D1-Changes");
1210 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "E2-d2-Changes");
1211 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "E2-d3-Changes");
1212 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "E2-E1-Changes");
1213 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "E2-E2-Changes");
1214 Assert
.AreEqual ("'E' => 'ok'", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "E2-E3-Changes");
1221 public void ManagedTest_F ()
1223 ManagedTestClass mtc
;
1224 string format
= "'{1}' => '{2}'";
1229 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_F1.xaml");
1230 Assert
.AreEqual ("A", mtc
._A_
, "F1-A");
1231 Assert
.AreEqual ("b", mtc
._b_
, "F1-b");
1232 Assert
.AreEqual ("c", mtc
._c_
, "F1-c");
1233 Assert
.AreEqual ("C", mtc
._C_
, "F1-C");
1234 Assert
.AreEqual ("D", mtc
._D_1_
, "F1-D1");
1235 Assert
.AreEqual ("d", mtc
._d_2_
, "F1-D2");
1236 Assert
.AreEqual ("d", mtc
._d_3_
, "F1-D3");
1237 Assert
.AreEqual ("E", mtc
._E_1_
, "F1-E1");
1238 Assert
.AreEqual ("E", mtc
._E_2_
, "F1-E2");
1239 Assert
.AreEqual ("E", mtc
._E_3_
, "F1-E3");
1240 Assert
.AreEqual ("F", mtc
._F_1_
, "F1-F1");
1241 Assert
.AreEqual ("ok", mtc
._F_2_
, "F1-F2");
1242 Assert
.AreEqual ("f", mtc
._f_3_
, "F1-F3");
1243 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "F1-A-Changes");
1244 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "F1-b-Changes");
1245 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "F1-c-Changes");
1246 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "F1-C-Changes");
1247 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "F1-D1-Changes");
1248 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "F1-d2-Changes");
1249 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "F1-d3-Changes");
1250 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "F1-E1-Changes");
1251 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "F1-E2-Changes");
1252 Assert
.AreEqual ("", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "F1-E3-Changes");
1253 Assert
.AreEqual ("", ManagedTestClass
.F_1
.ChangesToString (format
, sep
), "F1-F1-Changes");
1254 Assert
.AreEqual ("'F' => 'ok'", ManagedTestClass
.F_2
.ChangesToString (format
, sep
), "F1-F2-Changes");
1255 Assert
.AreEqual ("", ManagedTestClass
.f_3
.ChangesToString (format
, sep
), "F1-F3-Changes");
1257 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_F2.xaml");
1258 Assert
.AreEqual ("A", mtc
._A_
, "F2-A");
1259 Assert
.AreEqual ("b", mtc
._b_
, "F2-b");
1260 Assert
.AreEqual ("c", mtc
._c_
, "F2-c");
1261 Assert
.AreEqual ("C", mtc
._C_
, "F2-C");
1262 Assert
.AreEqual ("D", mtc
._D_1_
, "F2-D1");
1263 Assert
.AreEqual ("d", mtc
._d_2_
, "F2-D2");
1264 Assert
.AreEqual ("d", mtc
._d_3_
, "F2-D3");
1265 Assert
.AreEqual ("E", mtc
._E_1_
, "F2-E1");
1266 Assert
.AreEqual ("E", mtc
._E_2_
, "F2-E2");
1267 Assert
.AreEqual ("E", mtc
._E_3_
, "F2-E3");
1268 Assert
.AreEqual ("F", mtc
._F_1_
, "F2-F1");
1269 Assert
.AreEqual ("ok", mtc
._F_2_
, "F2-F2");
1270 Assert
.AreEqual ("f", mtc
._f_3_
, "F2-F3");
1271 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "F2-A-Changes");
1272 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "F2-b-Changes");
1273 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "F2-c-Changes");
1274 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "F2-C-Changes");
1275 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "F2-D1-Changes");
1276 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "F2-d2-Changes");
1277 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "F2-d3-Changes");
1278 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "F2-E1-Changes");
1279 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "F2-E2-Changes");
1280 Assert
.AreEqual ("", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "F2-E3-Changes");
1281 Assert
.AreEqual ("", ManagedTestClass
.F_1
.ChangesToString (format
, sep
), "F2-F1-Changes");
1282 Assert
.AreEqual ("'F' => 'ok'", ManagedTestClass
.F_2
.ChangesToString (format
, sep
), "F2-F2-Changes");
1283 Assert
.AreEqual ("", ManagedTestClass
.f_3
.ChangesToString (format
, sep
), "F2-F3-Changes");
1285 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_F3.xaml");
1286 Assert
.AreEqual ("A", mtc
._A_
, "F3-A");
1287 Assert
.AreEqual ("b", mtc
._b_
, "F3-b");
1288 Assert
.AreEqual ("c", mtc
._c_
, "F3-c");
1289 Assert
.AreEqual ("C", mtc
._C_
, "F3-C");
1290 Assert
.AreEqual ("D", mtc
._D_1_
, "F3-D1");
1291 Assert
.AreEqual ("d", mtc
._d_2_
, "F3-D2");
1292 Assert
.AreEqual ("d", mtc
._d_3_
, "F3-D3");
1293 Assert
.AreEqual ("E", mtc
._E_1_
, "F3-E1");
1294 Assert
.AreEqual ("E", mtc
._E_2_
, "F3-E2");
1295 Assert
.AreEqual ("E", mtc
._E_3_
, "F3-E3");
1296 Assert
.AreEqual ("F", mtc
._F_1_
, "F3-F1");
1297 Assert
.AreEqual ("ok-2", mtc
._F_2_
, "F3-F2");
1298 Assert
.AreEqual ("f", mtc
._f_3_
, "F3-F3");
1299 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "F3-A-Changes");
1300 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "F3-b-Changes");
1301 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "F3-c-Changes");
1302 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "F3-C-Changes");
1303 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "F3-D1-Changes");
1304 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "F3-d2-Changes");
1305 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "F3-d3-Changes");
1306 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "F3-E1-Changes");
1307 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "F3-E2-Changes");
1308 Assert
.AreEqual ("", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "F3-E3-Changes");
1309 Assert
.AreEqual ("", ManagedTestClass
.F_1
.ChangesToString (format
, sep
), "F3-F1-Changes");
1310 Assert
.AreEqual ("'F' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.F_2
.ChangesToString (format
, sep
), "F3-F2-Changes");
1311 Assert
.AreEqual ("", ManagedTestClass
.f_3
.ChangesToString (format
, sep
), "F3-F3-Changes");
1313 mtc
= new ManagedTestClass ("DependencyPropertyTest_ManagedTest_F4.xaml");
1314 Assert
.AreEqual ("A", mtc
._A_
, "F4-A");
1315 Assert
.AreEqual ("b", mtc
._b_
, "F4-b");
1316 Assert
.AreEqual ("c", mtc
._c_
, "F4-c");
1317 Assert
.AreEqual ("C", mtc
._C_
, "F4-C");
1318 Assert
.AreEqual ("D", mtc
._D_1_
, "F4-D1");
1319 Assert
.AreEqual ("d", mtc
._d_2_
, "F4-D2");
1320 Assert
.AreEqual ("d", mtc
._d_3_
, "F4-D3");
1321 Assert
.AreEqual ("E", mtc
._E_1_
, "F4-E1");
1322 Assert
.AreEqual ("E", mtc
._E_2_
, "F4-E2");
1323 Assert
.AreEqual ("E", mtc
._E_3_
, "F4-E3");
1324 Assert
.AreEqual ("F", mtc
._F_1_
, "F4-F1");
1325 Assert
.AreEqual ("ok-2", mtc
._F_2_
, "F4-F2");
1326 Assert
.AreEqual ("f", mtc
._f_3_
, "F4-F3");
1327 Assert
.AreEqual ("", ManagedTestClass
.A
.ChangesToString (format
, sep
), "F4-A-Changes");
1328 Assert
.AreEqual ("", ManagedTestClass
.b
.ChangesToString (format
, sep
), "F4-b-Changes");
1329 Assert
.AreEqual ("", ManagedTestClass
.c
.ChangesToString (format
, sep
), "F4-c-Changes");
1330 Assert
.AreEqual ("", ManagedTestClass
.C
.ChangesToString (format
, sep
), "F4-C-Changes");
1331 Assert
.AreEqual ("", ManagedTestClass
.D_1
.ChangesToString (format
, sep
), "F4-D1-Changes");
1332 Assert
.AreEqual ("", ManagedTestClass
.d_2
.ChangesToString (format
, sep
), "F4-d2-Changes");
1333 Assert
.AreEqual ("", ManagedTestClass
.d_3
.ChangesToString (format
, sep
), "F4-d3-Changes");
1334 Assert
.AreEqual ("", ManagedTestClass
.E_1
.ChangesToString (format
, sep
), "F4-E1-Changes");
1335 Assert
.AreEqual ("", ManagedTestClass
.E_2
.ChangesToString (format
, sep
), "F4-E2-Changes");
1336 Assert
.AreEqual ("", ManagedTestClass
.E_3
.ChangesToString (format
, sep
), "F4-E3-Changes");
1337 Assert
.AreEqual ("", ManagedTestClass
.F_1
.ChangesToString (format
, sep
), "F4-F1-Changes");
1338 Assert
.AreEqual ("'F' => 'ok-1' ; 'ok-1' => 'ok-2' ; 'ok-2' => 'ok-1' ; 'ok-1' => 'ok-2'", ManagedTestClass
.F_2
.ChangesToString (format
, sep
), "F4-F2-Changes");
1339 Assert
.AreEqual ("", ManagedTestClass
.f_3
.ChangesToString (format
, sep
), "F4-F3-Changes");
1344 public void Managed_Interfaces ()
1346 InterfaceDPs dp
= new InterfaceDPs ();
1347 dp
.IComparableProp
= 5;
1348 Assert
.AreEqual (5, (int) dp
.IComparableProp
, "#1");
1350 dp
.IComparableProp
= 1.0;
1351 Assert
.AreEqual (1.0, (double) dp
.IComparableProp
, "#2");
1353 dp
.IComparableProp
= new InterfaceDPs ();
1354 Assert
.IsInstanceOfType
<InterfaceDPs
> (dp
.IComparableProp
, "#3");
1356 dp
.IComparableProp
= new ManagedIComparable ();
1357 Assert
.IsInstanceOfType
<ManagedIComparable
> (dp
.IComparableProp
, "#4");
1359 dp
.IComparableChar
= 'c';
1360 Assert
.AreEqual ('c', dp
.IComparableChar
, "#5");
1363 // this should likely throw..
1364 dp
.IEquatableProp
= 5;
1367 dp
.IEquatableProp
= 5.0;
1368 Assert
.AreEqual (5.0, (double) dp
.IEquatableProp
, "#5");
1370 dp
.IEquatableProp
= new ManagedIEquatable ();
1371 Assert
.IsInstanceOfType
<ManagedIEquatable
> (dp
.IEquatableProp
, "#6");
1375 public void ManagedTest_GenericDPs ()
1377 GenericDPS c
= new GenericDPS ();
1378 c
.ListFloat
= new List
<float> ();
1379 Assert
.Throws
<ArgumentException
> (() => c
.ListFloat
= new List
<int> ());
1380 c
.ListInt
= new List
<int> ();
1384 public void Managed_AttachBinding ()
1386 new ManagedDPPriority ();
1387 ManagedDPPriority c
= (ManagedDPPriority
) XamlReader
.Load (@"
1388 <x:ManagedDPPriority xmlns=""http://schemas.microsoft.com/client/2007""
1389 xmlns:x=""clr-namespace:MoonTest.System.Windows;assembly=moon-unit""
1390 NormalProp=""{Binding}"" />");
1391 Assert
.IsNotNull (c
.NormalProp
, "#1");
1395 public void ManagedPriority ()
1397 new ManagedDPPriority ();
1398 ManagedDPPriority c
= (ManagedDPPriority
) XamlReader
.Load (@"
1399 <x:ManagedDPPriority xmlns=""http://schemas.microsoft.com/client/2007""
1400 xmlns:x=""clr-namespace:MoonTest.System.Windows;assembly=moon-unit""
1401 BindingProp=""{Binding}"" />");
1402 Assert
.IsNull (c
.BindingProp
, "#1");
1403 Assert
.IsNull (c
.GetValue (ManagedDPPriority
.BindingPropProperty
), "#2");
1404 Assert
.IsInstanceOfType
<Expression
> (c
.ReadLocalValue (ManagedDPPriority
.BindingPropProperty
), "#3");
1408 public void ManagedPriority2 ()
1410 ManagedDPPriority c
= new ManagedDPPriority ();
1411 c
.SetValue (ManagedDPPriority
.BindingPropProperty
, new Binding ());
1412 Assert
.IsTrue (c
.PropertyChanged
, "#1");
1417 public void ManagedSameReference ()
1420 ManagedTestClass c
= new ManagedTestClass ();
1422 Assert
.AreSame (s
, c
._A_
, "#1");
1427 public class ManagedIComparable
: IComparable { public int CompareTo (object o) { return 0; }
}
1428 public class ManagedIEquatable
: IEquatable
<double> { public bool Equals (double other) { return false; }
}
1429 public class InterfaceDPs
: Control
, IComparable
1431 public static DependencyProperty IComparablePropProperty
= DependencyProperty
.Register ("IComparableProp", typeof (IComparable
), typeof (InterfaceDPs
), null);
1432 public static DependencyProperty IComparableCharProperty
= DependencyProperty
.Register ("IComparableInt", typeof (IComparable
<char>), typeof (InterfaceDPs
), null);
1433 public static DependencyProperty IEquatablePropProperty
= DependencyProperty
.Register ("IEquatableProp", typeof (IEquatable
<double>), typeof (InterfaceDPs
), null);
1435 public IComparable IComparableProp
1437 get { return (IComparable) GetValue (IComparablePropProperty); }
1438 set { SetValue (IComparablePropProperty, value); }
1441 public IEquatable
<double> IEquatableProp
1443 get { return (IEquatable<double>) GetValue (IEquatablePropProperty); }
1444 set { SetValue (IEquatablePropProperty, value); }
1447 public IComparable
<char> IComparableChar
1449 get { return (IComparable<char>) GetValue (IComparablePropProperty); }
1450 set { SetValue (IComparablePropProperty, value); }
1453 public int CompareTo (object o
) { return 0; }
1456 public class ManagedDPPriority
: Control
1458 public static readonly DependencyProperty BindingPropProperty
;
1459 static ManagedDPPriority ()
1461 PropertyMetadata m
= new PropertyMetadata ((o
, e
) => ((ManagedDPPriority
) o
).PropertyChanged
= true);
1462 BindingPropProperty
= DependencyProperty
.Register ("BindingProp", typeof (Binding
), typeof (ManagedDPPriority
), m
);
1465 public Binding BindingProp
{
1469 public Binding NormalProp
{
1473 public bool PropertyChanged
{
1478 public class DependencyPropertyInfo
1480 public DependencyProperty Property
;
1482 public Type DeclaringType
;
1483 public Type PropertyType
;
1484 public PropertyMetadata Metadata
;
1485 public bool Attached
;
1487 public List
<ChangedInfo
> Changes
= new List
<ChangedInfo
> ();
1492 /// <param name="format">{0} = index, {1} = old value, {2} = new value</param>
1493 /// <param name="separator"></param>
1494 /// <returns></returns>
1495 public string ChangesToString (string format
, string separator
)
1497 StringBuilder result
= new StringBuilder ();
1499 for (int i
= 0; i
< Changes
.Count
; i
++) {
1500 ChangedInfo c
= Changes
[i
];
1502 result
.Append (separator
);
1503 result
.AppendFormat (format
, i
, c
.args
.OldValue
, c
.args
.NewValue
);
1506 return result
.ToString ();
1509 public DependencyPropertyInfo (string name
, Type declaring_type
, Type property_type
, bool attached
)
1512 this.DeclaringType
= declaring_type
;
1513 this.PropertyType
= property_type
;
1514 this.Metadata
= new PropertyMetadata (PropertyChanged
);
1515 this.Attached
= attached
;
1520 public DependencyPropertyInfo (string name
, Type declaring_type
, Type property_type
, bool attached
, object default_value
)
1523 this.DeclaringType
= declaring_type
;
1524 this.PropertyType
= property_type
;
1525 this.Metadata
= new PropertyMetadata (default_value
, PropertyChanged
);
1526 this.Attached
= attached
;
1531 private void Create ()
1534 Property
= DependencyProperty
.RegisterAttached (Name
, PropertyType
, DeclaringType
, Metadata
);
1536 Property
= DependencyProperty
.Register (Name
, PropertyType
, DeclaringType
, Metadata
);
1539 private string ValueToString (object val
)
1544 return val
.ToString ();
1547 private void PropertyChanged (DependencyObject obj
, DependencyPropertyChangedEventArgs args
)
1549 Tester
.WriteLine (string.Format ("DependencyPropertyInfo.PropertyChanged ({0}.{1}), old value: {2}, new value: {3}", DeclaringType
.FullName
, Name
, ValueToString (args
.OldValue
), ValueToString (args
.NewValue
)));
1550 ChangedInfo info
= new ChangedInfo ();
1556 public class ChangedInfo
1558 public DependencyObject obj
;
1559 public DependencyPropertyChangedEventArgs args
;
1562 // This class is accessed from xaml, and xaml can't access nested classes.
1563 public class ManagedTestClass
: Canvas
1565 public static DependencyPropertyInfo A
; // uppercase
1566 public static DependencyPropertyInfo b
; // lowercase
1567 public static DependencyPropertyInfo C
;
1568 public static DependencyPropertyInfo c
; // uppercase and lowercase
1569 public static DependencyPropertyInfo D_1
;
1570 public static DependencyPropertyInfo d_2
;
1571 public static DependencyPropertyInfo d_3
; // two with equal name + 1 with different case, accessed after D has been accessed
1572 public static DependencyPropertyInfo E_1
;
1573 public static DependencyPropertyInfo E_2
; // two with equal name
1574 public static DependencyPropertyInfo E_3
; // two with equal name
1575 public static DependencyPropertyInfo F_1
;
1576 public static DependencyPropertyInfo F_2
;
1577 public static DependencyPropertyInfo f_3
; // two with equal name + 1 with different name, accessed before f has been accessed
1579 public static Dictionary
<DependencyPropertyInfo
, int> Counters
= new Dictionary
<DependencyPropertyInfo
, int> ();
1580 public static Dictionary
<DependencyProperty
, DependencyPropertyInfo
> Hash
= new Dictionary
<DependencyProperty
, DependencyPropertyInfo
> ();
1582 static ManagedTestClass ()
1584 A
= new DependencyPropertyInfo ("A", typeof (ManagedTestClass
), typeof (string), false, "A");
1585 b
= new DependencyPropertyInfo ("b", typeof (ManagedTestClass
), typeof (string), false, "b");
1586 C
= new DependencyPropertyInfo ("C", typeof (ManagedTestClass
), typeof (string), false, "C");
1587 c
= new DependencyPropertyInfo ("c", typeof (ManagedTestClass
), typeof (string), false, "c");
1588 D_1
= new DependencyPropertyInfo ("D", typeof (ManagedTestClass
), typeof (string), false, "D");
1589 d_2
= new DependencyPropertyInfo ("d", typeof (ManagedTestClass
), typeof (string), false, "d");
1590 d_3
= new DependencyPropertyInfo ("d", typeof (ManagedTestClass
), typeof (string), false, "d");
1591 E_1
= new DependencyPropertyInfo ("E", typeof (ManagedTestClass
), typeof (string), false, "E");
1592 E_2
= new DependencyPropertyInfo ("E", typeof (ManagedTestClass
), typeof (string), false, "E");
1593 E_3
= new DependencyPropertyInfo ("E", typeof (ManagedTestClass
), typeof (string), false, "E");
1594 F_1
= new DependencyPropertyInfo ("F", typeof (ManagedTestClass
), typeof (string), false, "F");
1595 F_2
= new DependencyPropertyInfo ("F", typeof (ManagedTestClass
), typeof (string), false, "F");
1596 f_3
= new DependencyPropertyInfo ("f", typeof (ManagedTestClass
), typeof (string), false, "f");
1599 public ManagedTestClass ()
1604 public ManagedTestClass (string xaml_resource_file
)
1605 : this (new Uri ("/moon-unit;component/System.Windows/" + xaml_resource_file
, UriKind
.Relative
))
1609 public ManagedTestClass (Uri uri
) : this ()
1611 Application
.LoadComponent (this, uri
);
1614 public static void ClearCounters ()
1620 D_1
.Changes
.Clear ();
1621 d_2
.Changes
.Clear ();
1622 d_3
.Changes
.Clear ();
1623 E_1
.Changes
.Clear ();
1624 E_2
.Changes
.Clear ();
1625 E_3
.Changes
.Clear ();
1626 F_1
.Changes
.Clear ();
1627 F_2
.Changes
.Clear ();
1628 f_3
.Changes
.Clear ();
1631 // Weird naming to not get into any reflection-hackery SL might do.
1633 get { return (string) GetValue (A.Property); }
1634 set { SetValue (A.Property, value); }
1636 public string _b_ { get { return (string) GetValue (b.Property); }
}
1637 public string _C_ { get { return (string) GetValue (C.Property); }
}
1638 public string _c_ { get { return (string) GetValue (c.Property); }
}
1639 public string _D_1_ { get { return (string) GetValue (D_1.Property); }
}
1640 public string _d_2_ { get { return (string) GetValue (d_2.Property); }
}
1641 public string _d_3_ { get { return (string) GetValue (d_3.Property); }
}
1642 public string _E_1_ { get { return (string) GetValue (E_1.Property); }
}
1643 public string _E_2_ { get { return (string) GetValue (E_2.Property); }
}
1644 public string _E_3_ { get { return (string) GetValue (E_3.Property); }
}
1645 public string _F_1_ { get { return (string) GetValue (F_1.Property); }
}
1646 public string _F_2_ { get { return (string) GetValue (F_2.Property); }
}
1647 public string _f_3_ { get { return (string) GetValue (f_3.Property); }
}
1650 public class GenericDPS
: UserControl
1652 public static readonly DependencyProperty ListFloatProperty
= DependencyProperty
.Register ("ListFloat", typeof (List
<float>), typeof (GenericDPS
), null);
1653 public static readonly DependencyProperty ListIntProperty
= DependencyProperty
.Register ("ListInt", typeof (List
<int>), typeof (GenericDPS
), null);
1655 public object ListFloat
1657 get { return GetValue (ListFloatProperty); }
1658 set { SetValue (ListFloatProperty, value); }
1661 public object ListInt
1663 get { return GetValue (ListIntProperty); }
1664 set { SetValue (ListIntProperty, value); }
1668 public class CustomCanvas
: Canvas
1670 public static readonly DependencyProperty ChildProperty
= DependencyProperty
.Register ("Child", typeof (FrameworkElement
), typeof (CustomCanvas
), null);
1671 public static readonly DependencyProperty Child2Property
= DependencyProperty
.Register ("Child2", typeof (FrameworkElement
), typeof (CustomCanvas
), null);
1672 public FrameworkElement Child
{
1673 get { return (FrameworkElement) GetValue (ChildProperty); }
1674 set { SetValue (ChildProperty, value); }
1677 public FrameworkElement Child2
{
1678 get { return (FrameworkElement) GetValue (Child2Property); }
1679 set { SetValue (Child2Property, value); }