Exemplo n.º 1
0
        public static Model getTestModel()
        {
            if (model == null)
            {
                ModelBuilder modelBuilder = ModelBuilder;

                Animals.registerType(modelBuilder);
                Animal.registerType(modelBuilder);
                AnimalReference.registerType(modelBuilder);
                Bird.registerType(modelBuilder);
                ChildRelationshipDefinition.registerType(modelBuilder);
                Description.registerType(modelBuilder);
                FlightPartnerRef.registerType(modelBuilder);
                FlyingAnimal.registerType(modelBuilder);
                Guardian.registerType(modelBuilder);
                GuardEgg.registerType(modelBuilder);
                Mother.registerType(modelBuilder);
                SpouseRef.registerType(modelBuilder);
                FriendRelationshipDefinition.registerType(modelBuilder);
                RelationshipDefinition.registerType(modelBuilder);
                RelationshipDefinitionRef.registerType(modelBuilder);
                Egg.registerType(modelBuilder);
                FlightInstructor.registerType(modelBuilder);

                Wings.registerType(modelBuilder);

                model = modelBuilder.build();
            }

            return(model);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before @SuppressWarnings("unchecked") public void copyModelInstance()
        public virtual void copyModelInstance()
        {
            modelInstance = cloneModelInstance();

            tweety = modelInstance.getModelElementById("tweety");
            daffy  = modelInstance.getModelElementById("daffy");
            daisy  = modelInstance.getModelElementById("daisy");
            plucky = modelInstance.getModelElementById("plucky");
            birdo  = modelInstance.getModelElementById("birdo");

            animalType = modelInstance.Model.getType(typeof(Animal));

            // QName attribute reference
            fatherReference = (QNameAttributeReferenceImpl <Animal>)animalType.getAttribute("father").OutgoingReferences.GetEnumerator().next();

            // ID attribute reference
            motherReference = (AttributeReferenceImpl <Animal>)animalType.getAttribute("mother").OutgoingReferences.GetEnumerator().next();

            // ID element reference
            flightPartnerRefsColl = FlyingAnimal.flightPartnerRefsColl;

            ModelElementType flightPartnerRefType = modelInstance.Model.getType(typeof(FlightPartnerRef));

            flightPartnerRef = (FlightPartnerRef)modelInstance.getModelElementsByType(flightPartnerRefType).GetEnumerator().next();
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testChildElementsCollection()
        public virtual void testChildElementsCollection()
        {
            ICollection <FlightPartnerRef> flightPartnerRefs = flightPartnerRefCollection.get(tweety);

            IEnumerator <FlightPartnerRef> iterator = flightPartnerRefs.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            FlightPartnerRef daisyRef = iterator.next();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            FlightPartnerRef pluckyRef = iterator.next();

            assertThat(daisyRef.TextContent).isEqualTo(daisy.Id);
            assertThat(pluckyRef.TextContent).isEqualTo(plucky.Id);

            FlightPartnerRef birdoRef = modelInstance.newInstance(typeof(FlightPartnerRef));

            birdoRef.TextContent = birdo.Id;

            ICollection <FlightPartnerRef> flightPartners = Arrays.asList(birdoRef, daisyRef, pluckyRef);

            // directly test collection methods and not use the appropriate assertion methods
            assertThat(flightPartnerRefs.Count).isEqualTo(2);
            assertThat(flightPartnerRefs.Count == 0).False;
            assertThat(flightPartnerRefs.Contains(daisyRef));
            assertThat(flightPartnerRefs.ToArray()).isEqualTo(new object[] { daisyRef, pluckyRef });
            assertThat(flightPartnerRefs.toArray(new FlightPartnerRef[1])).isEqualTo(new FlightPartnerRef[] { daisyRef, pluckyRef });

            assertThat(flightPartnerRefs.Add(birdoRef)).True;
            assertThat(flightPartnerRefs).hasSize(3).containsOnly(birdoRef, daisyRef, pluckyRef);

            assertThat(flightPartnerRefs.remove(daisyRef)).True;
            assertThat(flightPartnerRefs).hasSize(2).containsOnly(birdoRef, pluckyRef);

            assertThat(flightPartnerRefs.addAll(flightPartners)).True;
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
            assertThat(flightPartnerRefs.containsAll(flightPartners)).True;
            assertThat(flightPartnerRefs).hasSize(3).containsOnly(birdoRef, daisyRef, pluckyRef);

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method:
            assertThat(flightPartnerRefs.removeAll(flightPartners)).True;
            assertThat(flightPartnerRefs).Empty;

            try
            {
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'retainAll' method:
                flightPartnerRefs.retainAll(flightPartners);
                fail("retainAll method is not implemented");
            }
            catch (Exception e)
            {
                assertThat(e).isInstanceOf(typeof(UnsupportedModelOperationException));
            }

            flightPartnerRefs.addAll(flightPartners);
            assertThat(flightPartnerRefs).NotEmpty;
            flightPartnerRefs.Clear();
            assertThat(flightPartnerRefs).Empty;
        }