示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddUnknownAnimal()
        public virtual void testAddUnknownAnimal()
        {
            ModelInstanceImpl modelInstanceImpl = (ModelInstanceImpl)modelInstance;
            ModelElementType  unknownAnimalType = modelInstanceImpl.registerGenericType(MODEL_NAMESPACE, "unknownAnimal");
            ModelElementType  animalsType       = modelInstance.Model.getType(typeof(Animals));
            ModelElementType  animalType        = modelInstance.Model.getType(typeof(Animal));

            ModelElementInstance unknownAnimal = modelInstance.newInstance(unknownAnimalType);

            assertThat(unknownAnimal).NotNull;
            unknownAnimal.setAttributeValue("id", "new-animal", true);
            unknownAnimal.setAttributeValue("gender", "Unknown");
            unknownAnimal.setAttributeValue("species", "unknown");

            ModelElementInstance         animals             = modelInstance.getModelElementsByType(animalsType).GetEnumerator().next();
            IList <ModelElementInstance> childElementsByType = new List <ModelElementInstance>(animals.getChildElementsByType(animalType));

            animals.insertElementAfter(unknownAnimal, childElementsByType[2]);
            assertThat(animals.getChildElementsByType(unknownAnimalType)).hasSize(3);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetUnknownAnimalByType()
        public virtual void testGetUnknownAnimalByType()
        {
            ModelInstanceImpl            modelInstanceImpl = (ModelInstanceImpl)modelInstance;
            ModelElementType             unknownAnimalType = modelInstanceImpl.registerGenericType(MODEL_NAMESPACE, "unknownAnimal");
            IList <ModelElementInstance> unknownAnimals    = new List <ModelElementInstance>(modelInstance.getModelElementsByType(unknownAnimalType));

            assertThat(unknownAnimals).hasSize(2);

            ModelElementInstance wanda = unknownAnimals[0];

            assertThat(wanda.getAttributeValue("id")).isEqualTo("wanda");
            assertThat(wanda.getAttributeValue("gender")).isEqualTo("Female");
            assertThat(wanda.getAttributeValue("species")).isEqualTo("fish");

            ModelElementInstance flipper = unknownAnimals[1];

            assertThat(flipper.getAttributeValue("id")).isEqualTo("flipper");
            assertThat(flipper.getAttributeValue("gender")).isEqualTo("Male");
            assertThat(flipper.getAttributeValue("species")).isEqualTo("dolphin");
        }
示例#3
0
        protected internal static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, string namespaceUri)
        {
            string localName = domElement.LocalName;
            ModelElementTypeImpl modelType = (ModelElementTypeImpl)modelInstance.Model.getTypeForName(namespaceUri, localName);

            if (modelType == null)
            {
                Model  model = modelInstance.Model;
                string actualNamespaceUri = model.getActualNamespace(namespaceUri);

                if (!string.ReferenceEquals(actualNamespaceUri, null))
                {
                    modelType = getModelElement(domElement, modelInstance, actualNamespaceUri);
                }
                else
                {
                    modelType = (ModelElementTypeImpl)modelInstance.registerGenericType(namespaceUri, localName);
                }
            }
            return(modelType);
        }