Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public SpecificationKey(ISpecificationModel model, string name)
        {
            this.model = model;
            this.name  = name;

            this.specificationProperties = new List <ISpecificationProperty>();
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
 public BiologicalChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel)
     : base(referencingProperty, relatedModel)
 {
     this.father  = this.model;
     this.mother  = this.relatedModel;
     this.sibling = null;
 }
Ejemplo n.º 6
0
        public SignificantOther(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationModel child)
            : base(model, relatedModel)
        {
            this.relationshipType = RelationshipType.Marriage;

            this.child = child;
        }
Ejemplo n.º 7
0
        public SignificantOther(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty, ISpecificationModel child)
            : base(model, externallyReferencingProperty)
        {
            this.relationshipType = RelationshipType.Marriage;

            this.child = child;
        }
Ejemplo n.º 8
0
        public SignificantOther(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel, ISpecificationModel child)
            : base(referencingProperty, relatedModel)
        {
            this.relationshipType = RelationshipType.Marriage;

            this.child = child;
        }
Ejemplo n.º 9
0
        public void SetupSiblingRelationship(ISpecificationModel relatedModel)
        {
            ISibling sibling = this.testingFactory.GenerateSibling(this, relatedModel);

            this.siblings.Add(sibling);
            this.relationships.Add(sibling);
        }
Ejemplo n.º 10
0
        public Relationship(ISpecificationModel model, ISpecificationModel relatedModel)
        {
            this.model        = model;
            this.relatedModel = relatedModel;

            this.externallyReferencingProperty = null;
            this.referencingProperty           = null;
        }
Ejemplo n.º 11
0
        public Relationship(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel)
        {
            this.relatedModel        = relatedModel;
            this.referencingProperty = referencingProperty;

            this.externallyReferencingProperty = null;

            this.model = this.referencingProperty.Model;
            this.referencingProperty.Relationship = this;
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        public Relationship(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty)
        {
            this.externallyReferencingProperty = externallyReferencingProperty;
            this.model = model;

            this.referencingProperty = null;

            if (this.externallyReferencingProperty != null)
            {
                this.relatedModel = this.externallyReferencingProperty.Model;
            }
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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());
            }
        }
Ejemplo n.º 17
0
 public Grandparent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel)
     : base(specificationProperty, relatedModel)
 {
 }
Ejemplo n.º 18
0
 public Grandparent(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty)
     : base(model, externallyReferencingProperty)
 {
 }
Ejemplo n.º 19
0
 public CustodiedChild(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty)
     : base(model, externallyReferencingProperty)
 {
 }
Ejemplo n.º 20
0
 public IllegitimateChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel)
     : base(referencingProperty, relatedModel)
 {
 }
Ejemplo n.º 21
0
 public Sibling(ISpecificationModel model, ISpecificationModel relatedModel)
     : base(model, relatedModel)
 {
 }
Ejemplo n.º 22
0
 public OnlyChild(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel)
     : base(referencingProperty, relatedModel)
 {
 }
Ejemplo n.º 23
0
 public Divorce(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationModel child)
     : base(model, relatedModel, child)
 {
 }
Ejemplo n.º 24
0
 public Friend(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty)
     : base(model, externallyReferencingProperty)
 {
 }
Ejemplo n.º 25
0
 public IIllegitimateParent GenerateIllegitimateParent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel)
 {
     return(new IllegitimateParent(specificationProperty, relatedModel));
 }
Ejemplo n.º 26
0
 public IGrandparent GenerateGrandparent(ISpecificationModel model, ISpecificationModel relatedModel, ISpecificationProperty externallyReferencingProperty)
 {
     return(new Grandparent(model, externallyReferencingProperty));
 }
Ejemplo n.º 27
0
 public IGrandparent GenerateGrandparent(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel)
 {
     return(new Grandparent(specificationProperty, relatedModel));
 }
Ejemplo n.º 28
0
 public UnfitParent(ISpecificationProperty referencingProperty, ISpecificationModel relatedModel)
     : base(referencingProperty, relatedModel)
 {
 }
Ejemplo n.º 29
0
 public Godfather(ISpecificationModel model, ISpecificationProperty externallyReferencingProperty)
     : base(model, externallyReferencingProperty)
 {
 }
Ejemplo n.º 30
0
 public IAdoptedChild GenerateAdoptedChild(ISpecificationProperty specificationProperty, ISpecificationModel relatedModel)
 {
     return(new AdoptedChild(specificationProperty, relatedModel));
 }