Пример #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);
        }
Пример #2
0
        public static object[] createModel()
        {
            TestModelParser modelParser   = new TestModelParser();
            ModelInstance   modelInstance = modelParser.EmptyModel;

            Animals animals = modelInstance.newInstance(typeof(Animals));

            modelInstance.DocumentElement = animals;

            // add a tns namespace prefix for QName testing
            animals.DomElement.registerNamespace("tns", MODEL_NAMESPACE);

            Animal tweety = createBird(modelInstance, "tweety", Gender.Female);
            Animal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
            Animal birdo  = createBird(modelInstance, "birdo", Gender.Female);
            Animal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
            Animal fiffy  = createBird(modelInstance, "fiffy", Gender.Female);

            createBird(modelInstance, "timmy", Gender.Male);
            createBird(modelInstance, "daisy", Gender.Female);

            // create and add some relationships
            RelationshipDefinition hedwigRelationship = createRelationshipDefinition(modelInstance, hedwig, typeof(ChildRelationshipDefinition));

            addRelationshipDefinition(tweety, hedwigRelationship);
            RelationshipDefinition birdoRelationship = createRelationshipDefinition(modelInstance, birdo, typeof(ChildRelationshipDefinition));

            addRelationshipDefinition(tweety, birdoRelationship);
            RelationshipDefinition pluckyRelationship = createRelationshipDefinition(modelInstance, plucky, typeof(FriendRelationshipDefinition));

            addRelationshipDefinition(tweety, pluckyRelationship);
            RelationshipDefinition fiffyRelationship = createRelationshipDefinition(modelInstance, fiffy, typeof(FriendRelationshipDefinition));

            addRelationshipDefinition(tweety, fiffyRelationship);

            tweety.RelationshipDefinitionRefs.Add(hedwigRelationship);
            tweety.RelationshipDefinitionRefs.Add(birdoRelationship);
            tweety.RelationshipDefinitionRefs.Add(pluckyRelationship);
            tweety.RelationshipDefinitionRefs.Add(fiffyRelationship);

            tweety.BestFriends.Add(birdo);
            tweety.BestFriends.Add(plucky);

            return(new object[] { "created", modelInstance, modelParser });
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void copyModelInstance()
        public virtual void copyModelInstance()
        {
            modelInstance = cloneModelInstance();

            tweety = modelInstance.getModelElementById("tweety");
            hedwig = modelInstance.getModelElementById("hedwig");
            birdo  = modelInstance.getModelElementById("birdo");
            plucky = modelInstance.getModelElementById("plucky");
            fiffy  = modelInstance.getModelElementById("fiffy");
            timmy  = modelInstance.getModelElementById("timmy");
            daisy  = modelInstance.getModelElementById("daisy");

            hedwigRelationship = modelInstance.getModelElementById("tweety-hedwig");
            birdoRelationship  = modelInstance.getModelElementById("tweety-birdo");
            pluckyRelationship = modelInstance.getModelElementById("tweety-plucky");
            fiffyRelationship  = modelInstance.getModelElementById("tweety-fiffy");

            timmyRelationship = createRelationshipDefinition(modelInstance, timmy, typeof(FriendRelationshipDefinition));
            daisyRelationship = createRelationshipDefinition(modelInstance, daisy, typeof(ChildRelationshipDefinition));
        }