예제 #1
0
        public void OptConfigProvided()
        {
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.RequiredAndOptionalInitPoint.Xmls.OptConfigProvided.xml");

            var c = _context.GetComponent <ComponentWithOptionalConfig>();

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.SomeConfig);
            Assert.AreEqual(c.SomeConfig, "SomeConfigValue");
        }
예제 #2
0
        public void ReqConfigProvided()
        {
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.RequiredAndOptionalInitPoint.Xmls.ReqConfigProvided.xml");

            var c = _context.GetComponent <ComponentWithRequiredConfig>();

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.SomeConfig);
            Assert.AreEqual(c.SomeConfig, "SomeConfigValue");
        }
예제 #3
0
        static void Main()
        {
            var context = new ComponentContext();

            context.ProcessCompositionXmlFromResource("Compositional.Composer.Samples.Basic.CalculatorComposition.xml");

            context.GetComponent <IProgramRunner>().Run();
        }
예제 #4
0
        public void ReqNamedPlugRedirectedUponRegistration()
        {
            _context.Register("someOtherName", typeof(PluggedComponent));
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.RequiredAndOptionalInitPoint.Xmls.ReqNamedPlugRedirected.xml");

            var c = _context.GetComponent <ComponentWithRequiredNamedPlug>();

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.PluggedContract);
        }
예제 #5
0
        public void BooleanAttributeNumeric()
        {
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.XmlValueParser.Xmls.ABool.xml");

            var o0 = _context.GetVariable("bool0");
            var o1 = _context.GetVariable("bool1");

            Assert.IsNotNull(o0);
            Assert.IsNotNull(o1);

            Assert.IsInstanceOfType(o0, typeof(bool));
            Assert.IsInstanceOfType(o1, typeof(bool));

            var b0 = (bool)o0;
            var b1 = (bool)o1;

            Assert.AreEqual(b0, false);
            Assert.AreEqual(b1, true);
        }
        public void OptNamedPlugRedirectedUponRegistration()
        {
            _context.Register("someOtherName", typeof(PluggedComponent));
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.RequiredAndOptionalInitPoint.Xmls.OptNamedPlugRedirected.xml");

            var c = _context.GetComponent <ComponentWithOptionalNamedPlug>();

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.PluggedContract);
        }
예제 #7
0
        public void DoubleAttribute()
        {
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.XmlValueParser.Xmls.ADouble.xml");

            var o = _context.GetVariable("doublepi");

            Assert.IsNotNull(o);

            Assert.IsInstanceOfType(o, typeof(double));

            var d = (double)o;

            Assert.AreEqual(d, 3.14159265358979);
        }
예제 #8
0
        public void SingleAttribute()
        {
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.XmlValueParser.Xmls.ASingle.xml");

            var o = _context.GetVariable("singlepi");

            Assert.IsNotNull(o);

            Assert.IsInstanceOfType(o, typeof(float));

            var d = (float)o;

            Assert.AreEqual(d, (float)3.141593);
        }
예제 #9
0
        private static void RunCompositionXml(ComponentContext composer, string assemblyName,
                                              string manifestResourceName, string path)
        {
            if (!string.IsNullOrEmpty(path))
            {
                composer.ProcessCompositionXml(HostingEnvironment.MapPath(path));
                return;
            }

            var assembly = Assembly.Load(assemblyName);

            composer.ProcessCompositionXmlFromResource(assembly, manifestResourceName);
        }
예제 #10
0
        static void Main()
        {
            var context = new ComponentContext();

            context.ProcessCompositionXmlFromResource("Compositional.Composer.Samples.Basic.CalculatorComposition.xml");

            var classEmitter = context.GetComponent <IClassEmitter>();
            IEmittedTypeHandler emittedTypeHandler = new TestEmittedTypeHandler();

            context.Register(new PreInitializedComponentFactory(classEmitter.EmitInterfaceInstance(emittedTypeHandler, typeof(IAdder))));
            context.Register(new PreInitializedComponentFactory(classEmitter.EmitInterfaceInstance(emittedTypeHandler, typeof(IMultiplier))));
            context.Register(new PreInitializedComponentFactory(classEmitter.EmitInterfaceInstance(emittedTypeHandler, typeof(IDivider))));

            context.GetComponent <IProgramRunner>().Run();
        }
예제 #11
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.CompositionNotification.Xmls.Composition.xml");
 }
예제 #12
0
		public void AttributeEmptyIntArray()
		{
			_context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.XmlValueParser.Xmls.ACollection.xml");

			var o = _context.GetVariable("emptyIntArray");

			Assert.IsNotNull(o);
			Assert.IsInstanceOfType(o, typeof(int[]));

			var iArray = (int[]) o;

			Assert.AreEqual(iArray.Length, 0);
		}
        public void AttributeSimpleObject()
        {
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.XmlValueParser.Xmls.AObject.xml");

            var o = _context.GetVariable("simpleObject");

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(SampleClass));

            var sc = (SampleClass)o;

            Assert.IsNull(sc.Field);
            Assert.IsNull(sc.Property);
            Assert.IsNull(sc.ConstructorArg);
            Assert.IsNull(sc.SampleContract);
        }
예제 #14
0
 public static void ProcessCompositionXmlFromResource(this ComponentContext context, string configurationResourceName)
 {
     context.ProcessCompositionXmlFromResource(Assembly.GetCallingAssembly(), configurationResourceName);
 }
예제 #15
0
        public void AttributeByteMax()
        {
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.XmlValueParser.Xmls.AUInt.xml");

            var o = _context.GetVariable("bytemax");

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(byte));

            var i = (byte)o;

            Assert.AreEqual(i, 255);
        }
예제 #16
0
        public void AttributeCharA()
        {
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.XmlValueParser.Xmls.AOtherSimple.xml");

            var o = _context.GetVariable("charA");

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(char));

            var c = (char)o;

            Assert.AreEqual(c, 'A');
        }
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                "ComposerCore.Tests.InitializePlugs.Xmls.Composition.xml");
 }
예제 #18
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.InitializationPointVariety.Xmls.ResourceComposition.xml");
 }
        public void AttributeTimeSpanString()
        {
            _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                       "ComposerCore.Tests.XmlValueParser.Xmls.ATimeSpan.xml");

            var o = _context.GetVariable("timeSpanString");

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(TimeSpan));
            Assert.AreEqual(o, TimeSpan.Parse("1:00:00"));
        }
예제 #20
0
        public void AttributeSignedByteMax()
        {
            _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.XmlValueParser.Xmls.AInt.xml");

            var o = _context.GetVariable("sbytemax");

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(sbyte));

            var i = (sbyte)o;

            Assert.AreEqual(i, 127);
        }