Exemplo n.º 1
0
 public void TearDown()
 {
     _appDomain.DoCallBack(() =>
     {
         _ssp.Application.Passivate();
     });
     _appDomain.Dispose();
     _appDomain = null;
 }
Exemplo n.º 2
0
 public void SetUp()
 {
     _domain = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Agnosticism Test (" + this.GetType() + ").");
     _domain.DoCallBack(() =>
     {
         _mixinInvoked      = false;
         _concernInvoked    = false;
         _sideEffectInvoked = false;
     });
 }
Exemplo n.º 3
0
        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 );
        }
Exemplo n.º 4
0
 public void TearDown()
 {
     _domain.Dispose();
     _domain = null;
 }