public void TestModels(IEnumerable <ModelNode> models) { // force XML serialiation EnsureSerializationSupport(models); _hookMap.Clear(); foreach (var model in models) { var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } else if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } else if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } else if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } else if (model.Value.GetType() == typeof(ListDefinition)) { runner.DeployListModel(model); } else { throw new SPMeta2NotImplementedException( string.Format("Runner does not support model of type: [{0}]", model.Value.GetType())); } if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } }); } }
public void TestModels(IEnumerable <ModelNode> models) { _hookMap.Clear(); foreach (var model in models) { var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; //ValidateDefinitionHostRunnerSupport<TDefinition>(runner); var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); }); } }
public ModelNode TestRandomDefinition <TDefinition>(Action <TDefinition> definitionSetup) where TDefinition : DefinitionBase, new() { _hookMap.Clear(); ModelNode result = null; var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; ValidateDefinitionHostRunnerSupport <TDefinition>(runner); var omModelType = GetRunnerType(runner); var definitionSandbox = ModelGeneratorService.GenerateModelTreeForDefinition <TDefinition>(omModelType); var additionalDefinitions = ModelGeneratorService.GetAdditionalDefinition <TDefinition>(); ModelGeneratorService.ComposeModelWithAdditionalDefinitions(definitionSandbox, additionalDefinitions, omModelType); if (definitionSetup != null) { foreach (var def in ModelGeneratorService.CurrentDefinitions) { definitionSetup(def as TDefinition); } } var hooks = GetHooks(definitionSandbox); foreach (var hook in hooks) { hook.Tag = runner.Name; } GetSerializedAndRestoredModels(definitionSandbox); allHooks.AddRange(hooks); if (definitionSandbox.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(definitionSandbox); } if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(definitionSandbox, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } result = definitionSandbox; }); return(result); }
public void TestModels(IEnumerable <ModelNode> models, bool deployOnce) { // force XML serialiation GetSerializedAndRestoredModels(models); _hookMap.Clear(); foreach (var model in models) { Trace.WriteLine(string.Format(".ToPrettyPrint() result:")); Trace.WriteLine(model.ToPrettyPrint()); Trace.WriteLine(string.Format(".ToDotGraph result:")); Trace.WriteLine(model.ToDotGraph()); if (EnableDefinitionImmutabilityValidation) { PersistDefinitionHashes(new[] { model }); } var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } else if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } else if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } else if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } else if (model.Value.GetType() == typeof(ListDefinition)) { runner.DeployListModel(model); } else { throw new SPMeta2NotImplementedException( string.Format("Runner does not support model of type: [{0}]", model.Value.GetType())); } if (!deployOnce) { if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } } }); if (!deployOnce) { if (EnableDefinitionImmutabilityValidation) { PleaseMakeSureDefinitionsWereNotChangedByModelHandlers(new[] { model }); } } } }