Пример #1
0
        public void ImportOnPropertyWithFunc()
        {
            var id = TypeIdentity.CreateDefinition(typeof(ImportOnPropertyWithFunc));

            Assert.IsTrue(s_Types.Exists(s => s.Identity.Equals(id)));

            var plugins = s_Parts.Where(p => p.Identity.Equals(id));

            Assert.IsTrue(plugins.Count() == 1);

            var plugin = plugins.First();

            Assert.AreEqual(1, plugin.Imports.Count());

            var import = plugin.Imports.First() as PropertyBasedImportDefinition;

            Assert.IsNotNull(import);
            Assert.AreEqual("ContractName", import.ContractName);
            Assert.AreEqual(id, import.DeclaringType);
            Assert.AreEqual(TypeIdentity.CreateDefinition(typeof(Func <IExportingInterface>)), import.RequiredTypeIdentity);
            Assert.AreEqual(
                PropertyDefinition.CreateDefinition(
                    typeof(ImportOnPropertyWithFunc).GetProperty("ImportingProperty")),
                import.Property);
        }
Пример #2
0
        public void ExportOnProperty()
        {
            var id = TypeIdentity.CreateDefinition(typeof(ExportOnProperty));

            Assert.IsTrue(s_Types.Exists(s => s.Identity.Equals(id)));

            var plugins = s_Parts.Where(p => p.Identity.Equals(id));

            Assert.IsTrue(plugins.Count() == 1);

            var plugin = plugins.First();

            Assert.IsFalse(plugin.Imports.Any());
            Assert.AreEqual(1, plugin.Exports.Count());

            var export = plugin.Exports.First() as PropertyBasedExportDefinition;

            Assert.IsNotNull(export);
            Assert.AreEqual(typeof(IExportingInterface).FullName, export.ContractName);
            Assert.AreEqual(id, export.DeclaringType);
            Assert.AreEqual(
                PropertyDefinition.CreateDefinition(
                    typeof(ExportOnProperty).GetProperty("ExportingProperty")),
                export.Property);
        }
Пример #3
0
        public void ConditionOnProperty()
        {
            var id = TypeIdentity.CreateDefinition(typeof(ConditionOnProperty));

            Assert.IsTrue(s_Types.Exists(s => s.Identity.Equals(id)));

            var plugins = s_Parts.Where(p => p.Identity.Equals(id));

            Assert.IsTrue(plugins.Count() == 1);

            var plugin = plugins.First();

            Assert.AreEqual(1, plugin.Conditions.Count());

            var condition = plugin.Conditions.First() as PropertyBasedScheduleConditionDefinition;

            Assert.IsNotNull(condition);
            Assert.AreEqual("OnProperty", condition.ContractName);
            Assert.AreEqual(
                PropertyDefinition.CreateDefinition(
                    typeof(ConditionOnProperty).GetProperty("ConditionProperty")),
                condition.Property);
        }