protected void PerformTest(Int32 injectionErrors, Int32 structureErrors, Int32 internalErrors)
        {
            using (var ad = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Model Test"))
            {
                this._injErrors      = injectionErrors;
                this._structErrors   = structureErrors;
                this._internalErrors = internalErrors;

                ad.DoCallBack(() =>
                {
                    var model  = this.CreateApplicationArchitecture().CreateModel();
                    var result = model.ValidationResult;
                    Assert.AreEqual(this._injErrors, result.CompositeValidationResults.Values.SelectMany(cResult => cResult.InjectionValidationErrors).Count() + result.InjectionValidationErrors.Count, "Injection errors: " + this.ToString(result.InjectionValidationErrors));
                    Assert.AreEqual(this._structErrors, result.CompositeValidationResults.Values.SelectMany(cResult => cResult.StructureValidationErrors).Count() + result.StructureValidationErrors.Count, "Structural errors: " + this.ToString(result.StructureValidationErrors));
                    Assert.AreEqual(this._internalErrors, result.CompositeValidationResults.Values.SelectMany(cResult => cResult.InternalValidationErrors).Count() + result.InternalValidationErrors.Count, "Internal errors: " + this.ToString(result.InternalValidationErrors));

                    if (this._injErrors > 0 || this._structErrors > 0 || this._internalErrors > 0)
                    {
                        Assert.Throws <InvalidApplicationModelException>(new TestDelegate(() => model.GenerateAndSaveAssemblies(emittingInfoCreator: Qi4CSCodeGenHelper.EmittingArgumentsCallback)));
                        Assert.Throws <InvalidApplicationModelException>(new TestDelegate(() => model.NewInstance(null, null, null)));
                    }
                    else
                    {
                        model.GenerateAndSaveAssemblies(emittingInfoCreator: Qi4CSCodeGenHelper.EmittingArgumentsCallback);
                        model.NewInstance(null, null, null);
                    }
                });
            }
        }
 public virtual void SetUp()
 {
     _appDomain = Qi4CSTestUtils.CreateTestAppDomain("Qi4CS Instance Test");
     _appDomain.DoCallBack(() =>
     {
         ArchitectureType architecture = this.CreateArchitecture();
         this.SetUpArchitecture(architecture);
         var ass = ReflectionHelper.QI4CS_ASSEMBLY;
         _model  = this.CreateModel(architecture);
         _model.GenerateAndSaveAssemblies(emittingInfoCreator: Qi4CSCodeGenHelper.EmittingArgumentsCallback);
         _application       = _model.NewInstance(TestConstants.APPLICATION_NAME, TestConstants.APPLICATION_MODE, TestConstants.APPLICATION_VERSION);
         _structureServices = this.GetStructureProvider(_application);
         _application.Activate();
     });
 }