Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddRelationshipDefinitionToUnknownAnimal()
        public virtual void testAddRelationshipDefinitionToUnknownAnimal()
        {
            RelationshipDefinition friendRelationshipDefinition = modelInstance.newInstance(typeof(FriendRelationshipDefinition));

            friendRelationshipDefinition.Id = "friend-relationship";
            friendRelationshipDefinition.setAttributeValue("animalRef", flipper.getAttributeValue("id"));

            try
            {
                wanda.addChildElement(friendRelationshipDefinition);
                fail("Cannot add relationship definition to UnknownAnimal cause no child types are defined");
            }
            catch (Exception e)
            {
                assertThat(e).isInstanceOf(typeof(ModelException));
            }

            wanda.insertElementAfter(friendRelationshipDefinition, null);

            Animal tweety = modelInstance.getModelElementById("tweety");
            RelationshipDefinition childRelationshipDefinition = modelInstance.newInstance(typeof(ChildRelationshipDefinition));

            childRelationshipDefinition.Id     = "child-relationship";
            childRelationshipDefinition.Animal = tweety;

            wanda.insertElementAfter(childRelationshipDefinition, friendRelationshipDefinition);
        }
Example #2
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);
        }