1 // -----------------------------------------------------------------------
\r
2 // Copyright (c) Microsoft Corporation. All rights reserved.
\r
3 // -----------------------------------------------------------------------
\r
5 using System.ComponentModel.Composition;
\r
6 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
7 using System.UnitTesting;
\r
9 namespace System.ComponentModel.Composition
\r
12 public class ImportAttributeTests
\r
15 public void Constructor1_ShouldSetContractNamePropertyToEmptyString()
\r
17 var attribute = new ImportAttribute();
\r
19 Assert.IsNull(attribute.ContractName);
\r
20 Assert.IsNull(attribute.ContractType);
\r
24 public void Constructor2_NullAsContractNameArgument_ShouldSetContractNamePropertyToEmptyString()
\r
26 var attribute = new ImportAttribute((string)null);
\r
28 Assert.IsNull(attribute.ContractName);
\r
29 Assert.IsNull(attribute.ContractType);
\r
33 public void Constructor3_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString()
\r
35 var attribute = new ImportAttribute((Type)null);
\r
37 Assert.IsNull(attribute.ContractName);
\r
38 Assert.IsNull(attribute.ContractType);
\r
42 public void Constructor4_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString()
\r
44 var attribute = new ImportAttribute((string)null, (Type)null);
\r
46 Assert.IsNull(attribute.ContractName);
\r
47 Assert.IsNull(attribute.ContractType);
\r
51 public void Constructor2_ValueAsContractNameArgument_ShouldSetContractNameProperty()
\r
53 var expectations = Expectations.GetContractNamesWithEmpty();
\r
55 foreach (var e in expectations)
\r
57 var attribute = new ImportAttribute(e);
\r
59 Assert.AreEqual(e, attribute.ContractName);
\r
64 public void Constructor1_ShouldSetAllowDefaultPropertyToFalse()
\r
66 var attribute = new ImportAttribute();
\r
68 Assert.IsFalse(attribute.AllowDefault);
\r
72 public void Constructor2_ShouldSetAllowDefaultPropertyToFalse()
\r
74 var attribute = new ImportAttribute("ContractName");
\r
76 Assert.IsFalse(attribute.AllowDefault);
\r
80 public void Constructor3_ShouldSetAllowDefaultPropertyToFalse()
\r
82 var attribute = new ImportAttribute(typeof(String));
\r
84 Assert.IsFalse(attribute.AllowDefault);
\r
88 public void Constructor1_ShouldSetAllowRecompositionPropertyToFalse()
\r
90 var attribute = new ImportAttribute();
\r
92 Assert.IsFalse(attribute.AllowRecomposition);
\r
96 public void Constructor2_ShouldSetAllowRecompositionPropertyToFalse()
\r
98 var attribute = new ImportAttribute("ContractName");
\r
100 Assert.IsFalse(attribute.AllowRecomposition);
\r
104 public void Constructor3_ShouldSetAllowRecompositionPropertyToFalse()
\r
106 var attribute = new ImportAttribute(typeof(String));
\r
108 Assert.IsFalse(attribute.AllowRecomposition);
\r
112 public void AllowDefault_ValueAsValueArgument_ShouldSetProperty()
\r
114 var expectations = Expectations.GetBooleans();
\r
116 var attribute = new ImportAttribute();
\r
118 foreach (var e in expectations)
\r
120 attribute.AllowDefault = e;
\r
121 Assert.AreEqual(e, attribute.AllowDefault);
\r
126 public void AllowRecomposition_ValueAsValueArgument_ShouldSetProperty()
\r
128 var expectations = Expectations.GetBooleans();
\r
130 var attribute = new ImportAttribute();
\r
132 foreach (var e in expectations)
\r
134 attribute.AllowRecomposition = e;
\r
135 Assert.AreEqual(e, attribute.AllowRecomposition);
\r