public void FunctionsFieldsAndProperties2_WithCatalog()
        {
            var container = ContainerFactory.CreateWithDefaultAttributedCatalog();

            ConsumerOfMultiple c     = new ConsumerOfMultiple();
            CompositionBatch   batch = new CompositionBatch();

            batch.AddPart(c);
            container.Compose(batch);

            foreach (var export in c.opInfo)
            {
                if ((string)export.Metadata["Var1"] == "add")
                {
                    Assert.AreEqual(3, export.Value(1, 2), "1 + 2 == 3");
                }
                else if ((string)export.Metadata["Var1"] == "sub")
                {
                    Assert.AreEqual(-1, export.Value(1, 2), "1 - 2 == -1");
                }
                else
                {
                    Assert.Fail("Unexpected value");
                }
            }
        }
Ejemplo n.º 2
0
        public void FunctionsFieldsAndProperties2_WithCatalog()
        {
            var container = ContainerFactory.CreateWithDefaultAttributedCatalog();

            ConsumerOfMultiple c     = new ConsumerOfMultiple();
            CompositionBatch   batch = new CompositionBatch();

            batch.AddPart(c);
            container.Compose(batch);

            foreach (Lazy <Func <int, int, int>, IDictionary <string, object> > export in c.opInfo)
            {
                if ((string)export.Metadata["Var1"] == "add")
                {
                    Assert.Equal(3, export.Value(1, 2));
                }
                else if ((string)export.Metadata["Var1"] == "sub")
                {
                    Assert.Equal(-1, export.Value(1, 2));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }