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