Пример #1
0
        public void AsContractName_AndContractType_SetsContractNameAndType()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export((e) => e.AsContractName("hey").AsContractType(typeof(IFoo)));

            ExportAttribute exportAtt = GetExportAttribute(builder);

            Assert.Equal("hey", exportAtt.ContractName);
            Assert.Equal(typeof(IFoo), exportAtt.ContractType);
        }
Пример #2
0
        public void AsContractTypeOfT_SetsContractType()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export((e) => e.AsContractType <IFoo>());

            ExportAttribute exportAtt = GetExportAttribute(builder);

            Assert.Equal(typeof(IFoo), exportAtt.ContractType);
            Assert.Null(exportAtt.ContractName);
        }
Пример #3
0
        public void AddMetadataFuncVal_AddsExportMetadataAttribute()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export(e => e.AddMetadata("name", t => t.Name));

            ExportMetadataAttribute exportAtt = GetExportMetadataAttribute(builder);

            Assert.Equal("name", exportAtt.Name);
            Assert.Equal(typeof(FooImpl).Name, exportAtt.Value);
        }
Пример #4
0
        public void AddMetadata_AddsExportMetadataAttribute()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export(e => e.AddMetadata("name", "val"));

            ExportMetadataAttribute exportAtt = GetExportMetadataAttribute(builder);

            Assert.Equal("name", exportAtt.Name);
            Assert.Equal("val", exportAtt.Value);
        }
Пример #5
0
        public void AsContractName_AndContractType_ComputeContractNameFromType()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export(e => e.AsContractName(t => "Contract:" + t.FullName).AsContractType <IFoo>());

            ExportAttribute exportAtt = GetExportAttribute(builder);

            Assert.Equal("Contract:" + typeof(FooImpl).FullName, exportAtt.ContractName);
            Assert.Equal(typeof(IFoo), exportAtt.ContractType);
        }
Пример #6
0
        public void AsContractName_SetsContractName()
        {
            var builder = new ConventionBuilder();

            builder.ForTypesDerivedFrom <IFoo>().Export((e) => e.AsContractName("hey"));

            ExportAttribute exportAtt = GetExportAttribute(builder);

            Assert.AreEqual("hey", exportAtt.ContractName);
            Assert.IsNull(exportAtt.ContractType);
        }