public SpecificationProperty(ISpecificationModel model, string name, string propertyType, bool required) { this.model = model; this.name = name; this.propertyType = propertyType; this.required = required; string common = this.name.Substring(1, this.name.Length - 1); this._default = null; this.isEnumeration = false; this.instanceName = this.name.Length <= 2 ? this.name.ToLower() : this.name.Substring(0, 1).ToLower() + common; this.name = this.name.Substring(0, 1).ToUpper() + common; if (this.instanceName.EndsWith("y")) { this.listInstanceName = this.instanceName.Substring(0, this.instanceName.Length - 1) + "ies"; } else if (this.instanceName.EndsWith("ss")) { this.listInstanceName = this.instanceName + "es"; } else if (this.instanceName.EndsWith("s")) { this.listInstanceName = this.instanceName; } else { this.listInstanceName = this.instanceName + "s"; } this.relationship = null; }
public SpecificationKey(ISpecificationModel model, string name) { this.model = model; this.name = name; this.specificationProperties = new List <ISpecificationProperty>(); }
public IList <ISpecificationModel> FindAffectedModels(IList <ISpecificationModel> modelsAlreadyChecked) { Dictionary <string, ISpecificationModel> affectedModels = new Dictionary <string, ISpecificationModel>(); modelsAlreadyChecked.Add(this); foreach (IRelationship relationship in this.Relationships) { ISpecificationModel relatedModel = relationship.RelatedModel; if (!modelsAlreadyChecked.Contains(relatedModel) && !affectedModels.ContainsKey(relatedModel.Variable.VariableType.Name) && (relationship is IAdmire || relationship is IAdoptedChild || relationship is IAdoptingParent || relationship is IBiologicalChild || relationship is IBiologicalParent || relationship is IFriend || relationship is IIllegitimateChild )) { foreach (ISpecificationModel dependantModel in relatedModel.FindAffectedModels(modelsAlreadyChecked)) { affectedModels[dependantModel.Variable.VariableType.Name] = dependantModel; } affectedModels[relatedModel.Variable.VariableType.Name] = relatedModel; } } return(affectedModels.Values.ToList()); }
public IList <ISpecificationModel> FindGuardians(IList <ISpecificationModel> modelsAlreadyChecked) { Dictionary <string, ISpecificationModel> dependantModels = new Dictionary <string, ISpecificationModel>(); modelsAlreadyChecked.Add(this); foreach (IRelationship relationship in this.Relationships) { ISpecificationModel relatedModel = relationship.RelatedModel; if (!modelsAlreadyChecked.Contains(relatedModel) && !dependantModels.ContainsKey(relatedModel.Variable.VariableType.Name) && (relationship is IBiologicalChild || relationship is IBiologicalParent)) { foreach (ISpecificationModel dependantModel in relatedModel.FindGuardians(modelsAlreadyChecked)) { dependantModels[dependantModel.Variable.VariableType.Name] = dependantModel; } dependantModels[relatedModel.Variable.VariableType.Name] = relatedModel; } } return(dependantModels.Values.ToList()); }
public BiologicalChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel) : base(referencingProperty, relatedModel) { this.father = this.model; this.mother = this.relatedModel; this.sibling = null; }
public SignificantOther(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationModel child) : base(model, relatedModel) { this.relationshipType = RelationshipType.Marriage; this.child = child; }
public SignificantOther(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty, ISpecificationModel child) : base(model, externallyReferencingProperty) { this.relationshipType = RelationshipType.Marriage; this.child = child; }
public SignificantOther(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel, ISpecificationModel child) : base(referencingProperty, relatedModel) { this.relationshipType = RelationshipType.Marriage; this.child = child; }
public void SetupSiblingRelationship(ISpecificationModel relatedModel) { ISibling sibling = this.testingFactory.GenerateSibling(this, relatedModel); this.siblings.Add(sibling); this.relationships.Add(sibling); }
public Relationship(ISpecificationModel model, ISpecificationModel relatedModel) { this.model = model; this.relatedModel = relatedModel; this.externallyReferencingProperty = null; this.referencingProperty = null; }
public Relationship(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel) { this.relatedModel = relatedModel; this.referencingProperty = referencingProperty; this.externallyReferencingProperty = null; this.model = this.referencingProperty.Model; this.referencingProperty.Relationship = this; }
public static string ListOutKeyProperties(string prefix, ISpecificationModel model) { string propertiesListed = string.Empty; if (model != null && model.Key != null) { propertiesListed = TestingHelper.ListOutKeyProperties(prefix, model.Key); } return(propertiesListed); }
public Relationship(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty) { this.externallyReferencingProperty = externallyReferencingProperty; this.model = model; this.referencingProperty = null; if (this.externallyReferencingProperty != null) { this.relatedModel = this.externallyReferencingProperty.Model; } }
public static string MockOutProperty(ISpecification specification, ISpecificationModel modelUnderTest, ModelComponent component, string variable, ISpecificationProperty specificationProperty, string referenceName) { string _value = null; if (component == ModelComponent.Model && specificationProperty.PropertyType == modelUnderTest.Interface.VariableType.Name) { _value = RandomValue(specification, specificationProperty, false, false); } else { _value = RandomValue(specification, specificationProperty, true, false); } if (specificationProperty.Relationship != null) { return(MockOutProperty(variable, specificationProperty.Name, referenceName, specificationProperty.PropertyType, "() => { return " + _value + "; }")); } return(MockOutProperty(variable, specificationProperty.Name, referenceName, specificationProperty.PropertyType, _value)); }
public static IList <string> DebugSpecificationModel(ISpecificationModel model) { IList <string> linesToWrite = new List <string>(); linesToWrite.Add(string.Empty); linesToWrite.Add("//SpecificationModel: " + model.Interface.VariableType.Name + " " + model.Variable.InstanceName + " = new " + model.Variable.VariableType.Name + "();"); linesToWrite.Add("// Repository: " + model.RepositoryInterface.VariableType.Name + " " + model.RepositoryVariable.InstanceName + " = new " + model.RepositoryVariable.VariableType.Name + "();"); linesToWrite.Add("// Service: " + model.ServiceInterface.VariableType.Name + " " + model.ServiceVariable.InstanceName + " = new " + model.ServiceVariable.VariableType.Name + "();"); linesToWrite.Add("//"); linesToWrite.Add("//Properties"); foreach (ISpecificationProperty property in model.SpecificationProperties.Values) { foreach (string line in DebugProperty(property)) { linesToWrite.Add(" " + line); } } return(linesToWrite); }
public void SetupReciprocatedRelationship(ISpecificationModel relatedModel, IRelationship reciprocatedRelationship) { if (reciprocatedRelationship is IAdmire) { IEnemy enemy = this.testingFactory.GenerateEnemy(this, relatedModel, reciprocatedRelationship.ReferencingProperty); this.associates.Add(enemy); this.enemies.Add(enemy); this.relationships.Add(enemy); } else if (reciprocatedRelationship is IGodchild) { IGodfather godfather = this.testingFactory.GenerateGodfather(this, relatedModel, reciprocatedRelationship.ReferencingProperty); this.godfathers.Add(godfather); this.parents.Add(godfather); this.relationships.Add(godfather); } else if (reciprocatedRelationship is IGrandchild) { IGrandparent grandparent = this.testingFactory.GenerateGrandparent(this, relatedModel, reciprocatedRelationship.ReferencingProperty); this.grandparents.Add(grandparent); this.parents.Add(grandparent); this.relationships.Add(grandparent); } else if (reciprocatedRelationship is IUnfitParent) { ICustodiedChild custodiedChild = this.testingFactory.GenerateCustodiedChild(this, relatedModel, reciprocatedRelationship.ReferencingProperty); this.children.Add(custodiedChild); this.custodiedChildren.Add(custodiedChild); this.relationships.Add(custodiedChild); } else { throw new NotImplementedException(new StringBuilder("Setup ").Append(relatedModel.Variable.VariableType.Name).Append("'s reciprocated relationship for property ").Append(reciprocatedRelationship.ReferencingProperty.Name).ToString()); } }
public Grandparent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel) : base(specificationProperty, relatedModel) { }
public Grandparent(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty) : base(model, externallyReferencingProperty) { }
public CustodiedChild(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty) : base(model, externallyReferencingProperty) { }
public IllegitimateChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel) : base(referencingProperty, relatedModel) { }
public Sibling(ISpecificationModel model, ISpecificationModel relatedModel) : base(model, relatedModel) { }
public OnlyChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel) : base(referencingProperty, relatedModel) { }
public Divorce(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationModel child) : base(model, relatedModel, child) { }
public Friend(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty) : base(model, externallyReferencingProperty) { }
public IIllegitimateParent GenerateIllegitimateParent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel) { return(new IllegitimateParent(specificationProperty, relatedModel)); }
public IGrandparent GenerateGrandparent(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationProperty externallyReferencingProperty) { return(new Grandparent(model, externallyReferencingProperty)); }
public IGrandparent GenerateGrandparent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel) { return(new Grandparent(specificationProperty, relatedModel)); }
public UnfitParent(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel) : base(referencingProperty, relatedModel) { }
public Godfather(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty) : base(model, externallyReferencingProperty) { }
public IAdoptedChild GenerateAdoptedChild(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel) { return(new AdoptedChild(specificationProperty, relatedModel)); }