update MEF to preview 9
[mcs.git] / class / System.ComponentModel.Composition / Tests / ComponentModelUnitTest / System / ComponentModel / Composition / ImportAttributeTests.cs
blob2a4f46772f3af901a6a3230872814ba6b54ad0af
1 // -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
4 using System;
5 using System.ComponentModel.Composition;
6 using Microsoft.VisualStudio.TestTools.UnitTesting;
7 using System.UnitTesting;
9 namespace System.ComponentModel.Composition
11 [TestClass]
12 public class ImportAttributeTests
14 [TestMethod]
15 public void Constructor1_ShouldSetContractNamePropertyToEmptyString()
17 var attribute = new ImportAttribute();
19 Assert.IsNull(attribute.ContractName);
20 Assert.IsNull(attribute.ContractType);
23 [TestMethod]
24 public void Constructor2_NullAsContractNameArgument_ShouldSetContractNamePropertyToEmptyString()
26 var attribute = new ImportAttribute((string)null);
28 Assert.IsNull(attribute.ContractName);
29 Assert.IsNull(attribute.ContractType);
32 [TestMethod]
33 public void Constructor3_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString()
35 var attribute = new ImportAttribute((Type)null);
37 Assert.IsNull(attribute.ContractName);
38 Assert.IsNull(attribute.ContractType);
41 [TestMethod]
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);
50 [TestMethod]
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);
63 [TestMethod]
64 public void Constructor1_ShouldSetAllowDefaultPropertyToFalse()
66 var attribute = new ImportAttribute();
68 Assert.IsFalse(attribute.AllowDefault);
71 [TestMethod]
72 public void Constructor2_ShouldSetAllowDefaultPropertyToFalse()
74 var attribute = new ImportAttribute("ContractName");
76 Assert.IsFalse(attribute.AllowDefault);
79 [TestMethod]
80 public void Constructor3_ShouldSetAllowDefaultPropertyToFalse()
82 var attribute = new ImportAttribute(typeof(String));
84 Assert.IsFalse(attribute.AllowDefault);
87 [TestMethod]
88 public void Constructor1_ShouldSetAllowRecompositionPropertyToFalse()
90 var attribute = new ImportAttribute();
92 Assert.IsFalse(attribute.AllowRecomposition);
95 [TestMethod]
96 public void Constructor2_ShouldSetAllowRecompositionPropertyToFalse()
98 var attribute = new ImportAttribute("ContractName");
100 Assert.IsFalse(attribute.AllowRecomposition);
103 [TestMethod]
104 public void Constructor3_ShouldSetAllowRecompositionPropertyToFalse()
106 var attribute = new ImportAttribute(typeof(String));
108 Assert.IsFalse(attribute.AllowRecomposition);
111 [TestMethod]
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);
125 [TestMethod]
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);