Ejemplo n.º 1
0
        public void Constructor4_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString()
        {
            var attribute = new ExportAttribute((string)null, (Type)null);

            Assert.IsNull(attribute.ContractName);
            Assert.IsNull(attribute.ContractType);
        }
Ejemplo n.º 2
0
        public void Constructor1_ShouldSetContractNamePropertyToEmptyString()
        {
            var attribute = new ExportAttribute();

            Assert.IsNull(attribute.ContractName);
            Assert.IsNull(attribute.ContractType);
        }
Ejemplo n.º 3
0
        public void Constructor2_ValueAsContractNameArgument_ShouldSetContractNameProperty()
        {
            var expectations = Expectations.GetContractNamesWithEmpty();
            
            foreach (var e in expectations)
            {
                var attribute = new ExportAttribute(e);

                Assert.AreEqual(e, attribute.ContractName);
            }
        }
Ejemplo n.º 4
0
        public AttributedExportDefinition(AttributedPartCreationInfo partCreationInfo, MemberInfo member, ExportAttribute exportAttribute)
            : base(member.GetContractNameFromExport(exportAttribute), (IDictionary<string, object>)null)
        {
            Assumes.NotNull(partCreationInfo);
            Assumes.NotNull(member);
            Assumes.NotNull(exportAttribute);

            this._partCreationInfo = partCreationInfo;
            this._member = member;
            this._exportAttribute = exportAttribute;
        }
Ejemplo n.º 5
0
        public void Constructor2_ValueAsContractNameArgument_ShouldSetContractNameProperty()
        {
            var expectations = Expectations.GetContractNamesWithEmpty();

            foreach (var e in expectations)
            {
                var attribute = new ExportAttribute(e);

                Assert.AreEqual(e, attribute.ContractName);
            }
        }
Ejemplo n.º 6
0
        public AttributedExportDefinition(AttributedPartCreationInfo partCreationInfo, MemberInfo member, ExportAttribute exportAttribute, Type typeIdentityType, string contractName)
            : base(contractName, (IDictionary<string, object>)null)
        {
            Assumes.NotNull(partCreationInfo);
            Assumes.NotNull(member);
            Assumes.NotNull(exportAttribute);

            this._partCreationInfo = partCreationInfo;
            this._member = member;
            this._exportAttribute = exportAttribute;
            this._typeIdentityType = typeIdentityType;
        }
Ejemplo n.º 7
0
        public void AsContractName_AndContractType_SetsContractNameAndType()
        {
            var builder = new ExportBuilder();

            builder.AsContractName("hey");
            builder.AsContractType(typeof(IFoo));

            ExportAttribute exportAtt = GetExportAttribute(builder);

            Assert.AreEqual("hey", exportAtt.ContractName);
            Assert.AreEqual(typeof(IFoo), exportAtt.ContractType);
        }
Ejemplo n.º 8
0
        Type GetTypeFromContractNameAsILayoutItem(ExportAttribute attribute)
        {
            if (attribute == null)
                return null;

            string typeName;
            if ((typeName = attribute.ContractName) == null)
                return null;

            var type = Type.GetType(typeName);
            if (type == null || !typeof(ILayoutItem).IsInstanceOfType(type))
                return null;
            return type;
        }
 public void ShouldExportTheGameSystem()
 {
     var exportAsGameSystem = new ExportAttribute(typeof (GameSystem));
     typeof (Model.SenseOfWonder).GetCustomAttributes(typeof (ExportAttribute), false)
         .Should().Equal(exportAsGameSystem);
 }