public void PerformTest() { using (var ad = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Mixin Visiblity Test")) { ad.DoCallBack(() => { Action a = () => { var architecture = Qi4CSArchitectureFactory.NewLayeredArchitecture(); var testPerformerLayer = architecture.GetOrCreateLayer(AbstractLayeredArchitectureInstanceTest.LAYER_NAME); var mainAssembler = testPerformerLayer.GetOrCreateModule(AbstractLayeredArchitectureInstanceTest.MODULE_NAME).CompositeAssembler; mainAssembler.NewPlainComposite().OfTypes(typeof(TestPerformer)).WithMixins(typeof(TestPerformerMixin)); this.Assemble(architecture, testPerformerLayer, mainAssembler); var model = architecture.CreateModel(); model.GenerateAndSaveAssemblies(emittingInfoCreator: Qi4CSCodeGenHelper.EmittingArgumentsCallback); var application = model.NewInstance(TestConstants.APPLICATION_NAME, TestConstants.APPLICATION_MODE, TestConstants.APPLICATION_VERSION); application.Activate(); var performer = application.FindModule(AbstractLayeredArchitectureInstanceTest.LAYER_NAME, AbstractLayeredArchitectureInstanceTest.MODULE_NAME).StructureServices.NewPlainCompositeBuilder <TestPerformer>().Instantiate(); Assert.AreEqual(TEST_1_OK, performer.Test1()); Assert.AreEqual(TEST_2_OK, performer.Test2()); }; if (this._expectedException == null) { a(); } else { Assert.Throws(this._expectedException, new TestDelegate(a)); } }); } }
public void SetUp() { _domain = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Agnosticism Test (" + this.GetType() + ")."); _domain.DoCallBack(() => { _mixinInvoked = false; _concernInvoked = false; _sideEffectInvoked = false; }); }
public void CreateAndActivateApplicationFromWithin() { this.PerformTestInAppDomain(() => { using (var ad = Qi4CSTestUtils.CreateTestAppDomain("Multiple activations test")) { var application = this.Model.NewInstance(null, null, null); try { application.Activate(); } finally { application.Passivate(); } } }); }
public void SetUp() { _appDomain = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Configuration test."); _appDomain.DoCallBack(() => { // Typical usecase scenario, first create architecture var architecture = Qi4CSArchitectureFactory.NewLayeredArchitecture(); // Add layer for all configuration composites var configLayer = architecture.GetOrCreateLayer("ConfigLayer"); // Add a module for all configuration composites var configModule = configLayer.GetOrCreateModule("ConfigModule"); // Assembler for configuration module var assembler = configModule.CompositeAssembler; var customSerializers = new List <XMLConfigurationSerializerHelper>(); // IPEndPoint is not a Qi4CS composite - add custom (de)serialization support for it customSerializers.Add(new XMLConfigurationSerializerWithCallbacks( (obj, type) => typeof(IPEndPoint).Equals(type), (obj, type, parent) => parent.Add(new XElement("Address", ((IPEndPoint)obj).Address.ToString()), new XElement("Port", ((IPEndPoint)obj).Port.ToString())), (element, type) => typeof(IPEndPoint).Equals(type), (element, type) => { var addressString = element.Element("Address").Value; IPAddress address; if (!IPAddress.TryParse(addressString, out address)) { address = Dns.GetHostEntry(addressString).AddressList[0]; } return(new IPEndPoint(address, Int32.Parse(element.Element("Port").Value))); } )); // Add serialization composite assembler.AddXMLSerializationSupport(null, customSerializers); // Add composites part of the configuration assembler .NewPlainComposite() .OfTypes(typeof(DatabaseConfiguration)); assembler .NewLayeredPlainComposite() .VisibleIn(Visibility.MODULE) .OfTypes(typeof(DatabaseSetup)); // Add support for configuration service and instances assembler.AddSupportForAllConfigurationInstancesAndManager() .WithDefaultsFor(typeof(DatabaseConfiguration)) // Set default values for DatabaseConfiguration .SerializedByXML() // Make DatabaseConfiguration (de)serialization process use XMLConfigurationSerializer .LocatedInXMLDocument(CONFIG_FILE_FULL_PATH); // Default location for DatabaseConfiguration // Add the test composite var testLayer = architecture.GetOrCreateLayer("TestLayer"); var testModule = testLayer.GetOrCreateModule("TestModule"); assembler = testModule.CompositeAssembler; assembler.NewLayeredPlainComposite().OfTypes(typeof(CompositeUsingConfiguration)).WithMixins(typeof(CompositeUsingConfigurationMixin)); testLayer.UseLayers(configLayer); var model = architecture.CreateModel(); model.GenerateAndSaveAssemblies(emittingInfoCreator: Qi4CSCodeGenHelper.EmittingArgumentsCallback); var application = model.NewInstance(TestConstants.APPLICATION_NAME, TestConstants.APPLICATION_MODE, TestConstants.APPLICATION_VERSION); _ssp = assembler.GetStructureServiceProvider(application); application.Activate(); }); //var configSSP = configModule.CompositeAssembler.GetStructureServiceProvider( application ); //var suckaObjBuilder = configSSP.NewPlainCompositeBuilder<DatabaseConfiguration>(); //suckaObjBuilder.Prototype().DatabaseSetups = new Dictionary<String, DatabaseSetup>(); //var localConnBuilder = configSSP.NewPlainCompositeBuilder<DatabaseSetup>(); //localConnBuilder.Prototype().DatabaseName = "SomeDB"; //localConnBuilder.Prototype().DatabaseConnectionInformation = new IPEndPoint( IPAddress.Loopback, 1000 ); //suckaObjBuilder.Prototype().DatabaseSetups.Add( "Local", localConnBuilder.Instantiate() ); //var sucka = new XElement( "DatabaseConfiguration" ); //configSSP.FindService<XMLSerializationService>().Service.Serialize( suckaObjBuilder.Instantiate(), sucka ); }