1 // (c) Copyright Microsoft Corporation.
2 // This source is subject to the Microsoft Public License (Ms-PL).
3 // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
4 // All other rights reserved.
6 // https://silverlight.svn.codeplex.com/svn/Release/Silverlight4/Source/RiaClient.Tests/System.ComponentModel.DataAnnotations/FilterUIHintAttributeTest.cs
11 using System.ComponentModel;
12 using System.ComponentModel.DataAnnotations;
14 using NUnit.Framework;
16 namespace MonoTests.System.ComponentModel.DataAnnotations
19 public class FilterUIHintAttributeTest {
21 [Description("Simple ctors set expected properties.")]
22 public void FilterUIHintAttribute_Simple_Ctors_Set_Properties() {
23 var attr = new FilterUIHintAttribute(null, null);
24 Assert.IsNull(attr.FilterUIHint);
25 Assert.IsNull(attr.PresentationLayer);
26 Assert.AreEqual(0, attr.ControlParameters.Count);
28 attr = new FilterUIHintAttribute(string.Empty, string.Empty);
29 Assert.AreEqual(string.Empty, attr.FilterUIHint);
30 Assert.AreEqual(string.Empty, attr.PresentationLayer);
31 Assert.AreEqual(0, attr.ControlParameters.Count);
33 attr = new FilterUIHintAttribute("theHint");
34 Assert.AreEqual("theHint", attr.FilterUIHint);
35 Assert.IsNull(attr.PresentationLayer);
36 Assert.AreEqual(0, attr.ControlParameters.Count);
38 attr = new FilterUIHintAttribute("theHint", "theLayer");
39 Assert.AreEqual("theHint", attr.FilterUIHint);
40 Assert.AreEqual("theLayer", attr.PresentationLayer);
41 Assert.AreEqual(0, attr.ControlParameters.Count);
45 public void ConstructorControlParameters() {
46 Assert.AreEqual(2, new FilterUIHintAttribute("", "", "a", 1, "b", 2).ControlParameters.Keys.Count);
50 public void ConstructorControlParameters_NoParams() {
51 Assert.AreEqual(0, new FilterUIHintAttribute("", "", new object[0]).ControlParameters.Keys.Count);
52 Assert.AreEqual(0, new FilterUIHintAttribute("", "", (object[])null).ControlParameters.Keys.Count);
53 Assert.AreEqual(0, new FilterUIHintAttribute("", "").ControlParameters.Keys.Count);
54 Assert.AreEqual(0, new FilterUIHintAttribute("").ControlParameters.Keys.Count);
58 [ExpectedException (typeof (InvalidOperationException))]
59 public void ConstructorControlParameters_UnevenNumber() {
60 var attr = new FilterUIHintAttribute("", "", "");
61 var v = attr.ControlParameters;
65 [ExpectedException (typeof (InvalidOperationException))]
66 public void ConstructorControlParameters_NonStringKey() {
67 var attr = new FilterUIHintAttribute("", "", 1, "value");
68 var v = attr.ControlParameters;
72 [ExpectedException (typeof (InvalidOperationException))]
73 public void ConstructorControlParameters_NullKey() {
74 var attr = new FilterUIHintAttribute("", "", null, "value");
75 var v = attr.ControlParameters;
79 [ExpectedException (typeof (InvalidOperationException))]
80 public void ConstructorControlParameters_DuplicateKey() {
81 var attr = new FilterUIHintAttribute("", "", "key", "value1", "key", "value2");
82 var v = attr.ControlParameters;
87 public void TypeId_ReturnsDifferentValuesForDifferentInstances() {
88 Assert.AreNotEqual(new FilterUIHintAttribute("foo").TypeId, new FilterUIHintAttribute("bar").TypeId);