protected void CreateExecutionOccurenceSpecs(Interaction relevantInteraction)
        {
            ExecutionSpecification currentExecutionSpec;
            ExecutionOccurrenceSpecification executionOccurrenceSpecStart;
            ExecutionOccurrenceSpecification executionOccurrenceSpecFinish;
            XmlElement currentBehaviorExecutionSpecElement;
            XmlElement executionOccurrenceSpecFinishElement;
            XmlElement executionOccurrenceSpecStartElement;
            Point currentExecutionSpecPosition;
            Size currentExecutionSpecDimension;
            Point executionOccurrenceSpecStartPosition;
            Point executionOccurrenceSpecFinishPosition;

            string currentExecutionOccurrenceSpecStartId;
            string currentExecutionOccurrenceSpecFinishId;
            ArrayList executionSpecs =relevantInteraction.ExecutionSpecs;
            IEnumerator itrExecutionSpecs =executionSpecs.GetEnumerator();

            while(itrExecutionSpecs.MoveNext())
            {
                currentExecutionSpec=(ExecutionSpecification)itrExecutionSpecs.Current;
                currentExecutionSpecPosition=currentExecutionSpec.Position;
                currentExecutionSpecDimension=currentExecutionSpec.Dimension;
                currentBehaviorExecutionSpecElement=currentExecutionSpec.XmlRepresentation;
                currentExecutionOccurrenceSpecStartId=currentBehaviorExecutionSpecElement.GetAttribute(UmlModel.START_ATTR_COMPLETE_NAME);
                currentExecutionOccurrenceSpecFinishId=currentBehaviorExecutionSpecElement.GetAttribute(UmlModel.FINISH_ATTR_COMPLETE_NAME);

                executionOccurrenceSpecStartPosition=new Point(currentExecutionSpecPosition.X,currentExecutionSpecPosition.Y);
                executionOccurrenceSpecFinishPosition=new Point(currentExecutionSpecPosition.X,
                                                               currentExecutionSpecPosition.Y+currentExecutionSpecDimension.Height);

                executionOccurrenceSpecStartElement=
                        modelDocumentInterpreter.GetExecutionOccurrenceSpecElementForId(relevantInteraction.XmlRepresentation,
                                                                                   		currentExecutionOccurrenceSpecStartId);
                executionOccurrenceSpecFinishElement=
                        modelDocumentInterpreter.GetExecutionOccurrenceSpecElementForId(relevantInteraction.XmlRepresentation,
                                                                                   		currentExecutionOccurrenceSpecFinishId);

                executionOccurrenceSpecStart=new ExecutionOccurrenceSpecification(executionOccurrenceSpecStartPosition,
                                                                                  currentExecutionOccurrenceSpecStartId,
                                                                                  relevantInteraction.XmlRepresentation);
                executionOccurrenceSpecStart.CoveredLifeline=currentExecutionSpec.CoveredLifeline;
                executionOccurrenceSpecStart.Position=executionOccurrenceSpecStartPosition;
                executionOccurrenceSpecStart.SpecificationKind= ExecutionOccurrenceSpecKind.START;

                executionOccurrenceSpecFinish=new ExecutionOccurrenceSpecification(executionOccurrenceSpecFinishPosition,
                                                                                       currentExecutionOccurrenceSpecFinishId,
                                                                                       relevantInteraction.XmlRepresentation);
                executionOccurrenceSpecFinish.CoveredLifeline=currentExecutionSpec.CoveredLifeline;
                executionOccurrenceSpecFinish.Position=executionOccurrenceSpecFinishPosition;
                executionOccurrenceSpecFinish.SpecificationKind= ExecutionOccurrenceSpecKind.FINISH;

                relevantInteraction.ExecutionOccurrenceSpecs.Add(executionOccurrenceSpecStart);
                relevantInteraction.ExecutionOccurrenceSpecs.Add(executionOccurrenceSpecFinish);
            }
        }
        protected internal void CreateMessages(Interaction interaction,XmlElement diagramElement)
        {
            XmlElement currentMessageElement;
            Message currentMessage;
            Point currentMessagePosition;
            string currentMessageName;
            string currentMessageId;
            string currentMessageSort;
            ArrayList messages=new ArrayList();
            XmlElement interactionElement=interaction.XmlRepresentation;
            XmlNodeList messageElements=modelDocumentInterpreter.GetMessageElements(interactionElement);
            IEnumerator itrMessageElements=messageElements.GetEnumerator();

            while(itrMessageElements.MoveNext())
            {
                currentMessageElement=(XmlElement)itrMessageElements.Current;
                currentMessagePosition=diDocumentInterpreter.GetMessageGraphNodePosition(diagramElement,currentMessageElement);
                currentMessageId=currentMessageElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
                currentMessageName=currentMessageElement.GetAttribute(UmlModel.NAME_ATTR_NAME);
                currentMessageSort=currentMessageElement.GetAttribute(UmlModel.MESSAGE_SORT_ATTR_NAME);
                currentMessage=new Message(currentMessagePosition,currentMessageId,currentMessageElement);
                currentMessage.Name=currentMessageName;
                AddMessageSort(currentMessage, currentMessageSort);
                messages.Add(currentMessage);
            }

            messages=SortListForVerticalPosition(messages);
            interaction.Messages=messages;
        }
        protected internal Message GetMessageForMessageElement(XmlElement relevantMessageElement,Interaction interaction)
        {
            Message relevantMessage=null;
            ArrayList messages=interaction.Messages;
            IEnumerator itrMessages=messages.GetEnumerator();
            XmlElement currentMessageElement;
            Message currentMessage;
            bool messageNotFound=true;

            while((itrMessages.MoveNext())&&(messageNotFound))
            {
                currentMessage=(Message)itrMessages.Current;
                currentMessageElement=currentMessage.XmlRepresentation;

                if(currentMessageElement==relevantMessageElement)
                {
                    relevantMessage=currentMessage;
                    messageNotFound=false;
                }
            }
            return relevantMessage;
        }
        /*
        protected internal void CreateFormalGates(Interaction relevantInteraction,XmlElement diagramElement)
        {
            XmlElement currentFormalGateElement;
            XmlElement currentConnectedMessageElement;

            string currentConnectedMessageElementId;
            Point currentFormalGatePosition;

            MessageEndKind messageEndKind;
            string strMessageEndKind;
            string currentFormalGateId;
            FormalGate currentFormalGate;

            XmlElement interactionElement=relevantInteraction.XmlRepresentation;
            XmlNodeList formalGateElements=modelDocumentInterpreter.GetFormalGateElements(interactionElement);
            IEnumerator itrFormalGateElements=formalGateElements.GetEnumerator();

            while(itrFormalGateElements.MoveNext())
            {
                currentFormalGateElement=(XmlElement)itrFormalGateElements.Current;
                currentFormalGateId=currentFormalGateElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
                currentConnectedMessageElementId=currentFormalGateElement.GetAttribute(UmlModel.MESSAGE_ATTR_NAME);
                currentConnectedMessageElement=modelDocumentInterpreter.GetMessageElementForId(diagramElement,currentConnectedMessageElementId);
                strMessageEndKind =modelDocumentInterpreter.GetEventKindForFormalGateXmlElement(currentFormalGateElement,currentConnectedMessageElement);

                if (strMessageEndKind.Equals(MessageEndKind.destinationEnd))
                {
                    messageEndKind= MessageEndKind.destinationEnd;
                    currentFormalGatePosition=diDocumentInterpreter.GetFormalGateGraphNodePosition(diagramElement,currentFormalGateElement,messageEndKind);
                }
                else if(strMessageEndKind.Equals(MessageEndKind.sourceEnd))
                {
                    messageEndKind= MessageEndKind.sourceEnd;
                    currentFormalGatePosition=diDocumentInterpreter.GetFormalGateGraphNodePosition(diagramElement,currentFormalGateElement,messageEndKind);
                }

                currentFormalGate= new FormalGate(currentFormalGatePosition,currentFormalGateId ,currentFormalGateElement);
                currentFormalGate.MessageEndKind=messageEndKind;

            }
        }*/
        protected internal void CreateMessageEndsForLifeline(Lifeline lifeline,XmlElement diagramElement,Interaction interaction)
        {
            ArrayList relevantMessageEnds;
            XmlElement currentMessageEndElement;
            MessageEnd currentMessageEnd;
            ExecutionSpecification currentBehaviorExecutionSpec;
            string currentMessageEndId;
            Point currentMessageEndPosition;
            relevantMessageEnds=new ArrayList();
            XmlElement lifelineElement=lifeline.XmlRepresentation;
            XmlElement interactionElement=(XmlElement)lifelineElement.ParentNode;
            XmlNodeList messageOccurrenceSpecElements=
                modelDocumentInterpreter.GetMessageOccurrenceSpecElementsForLifeline(lifelineElement);
            IEnumerator itrMessageOccurrenceSpecElements=messageOccurrenceSpecElements.GetEnumerator();

            while(itrMessageOccurrenceSpecElements.MoveNext())
            {
                currentMessageEndElement=(XmlElement)itrMessageOccurrenceSpecElements.Current;
                currentMessageEndId=currentMessageEndElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
                currentMessageEndPosition=
                    diDocumentInterpreter.GetMessageOccurrenceSpecGraphNodePosition(diagramElement,currentMessageEndElement);
                currentMessageEnd=new MessageEnd(currentMessageEndPosition,currentMessageEndId,currentMessageEndElement);
                currentMessageEnd.CoveredLifeline=lifeline;
                currentBehaviorExecutionSpec=currentMessageEnd.GetExecutionForMessageEnd();

                if(currentBehaviorExecutionSpec!=null)
                {
                    currentBehaviorExecutionSpec.MessageSourceEnds.Add(currentMessageEnd);
                }

                relevantMessageEnds.Add(currentMessageEnd);
            }

            relevantMessageEnds=SortListForVerticalPosition(relevantMessageEnds);
            lifeline.MessageEnds=relevantMessageEnds;

            if(relevantMessageEnds.Count >0)
            {
                interaction.MessageOccurrenceSpecs.AddRange(relevantMessageEnds);
            }
        }
        protected internal void CreateMessageEndsForLifelines(ArrayList lifelines,XmlElement diagramElement,Interaction interaction)
        {
            IEnumerator itrLifelines=lifelines.GetEnumerator();
            Lifeline currentLifeline;

            while(itrLifelines.MoveNext())
            {
                currentLifeline=(Lifeline)itrLifelines.Current;
                CreateMessageEndsForLifeline(currentLifeline,diagramElement,interaction);
            }
        }
        protected internal void InterpretOccurrenceSpecifications(Interaction relevantInteraction)
        {
            SequenceChartElement currentOccurrenceSpec;
            SequenceChartElement nextOccurrenceSpec;
            ArrayList occurrenceSpecifications;
            int occurrenceSpecificationsCount;

            occurrenceSpecifications=GetOccurrenceSpecificationsOfInteraction(relevantInteraction);
            occurrenceSpecifications=sorter.SortOccurrenceSpecifications(occurrenceSpecifications);
            occurrenceSpecificationsCount=occurrenceSpecifications.Count;

            for(int count=0;count<occurrenceSpecificationsCount;count++)
            {
                currentOccurrenceSpec=(SequenceChartElement)occurrenceSpecifications[count];
                nextOccurrenceSpec=null;

                if(count<occurrenceSpecificationsCount-1)
                {
                    nextOccurrenceSpec=	(SequenceChartElement)occurrenceSpecifications[count+1];
                }

                if(currentOccurrenceSpec is MessageEnd)
                {
                    if(((MessageEnd)currentOccurrenceSpec).MessageEndKind == MessageEndKind.sourceEnd)
                    {
                        this.InterpretMessageOccurrenceSpec((MessageEnd)currentOccurrenceSpec);
                    }
                }
                else if(currentOccurrenceSpec is ExecutionOccurrenceSpecification)
                {
                    this.InterpretExecutionOccurrenceSpecification((ExecutionOccurrenceSpecification)currentOccurrenceSpec,nextOccurrenceSpec);
                }
            }
        }
        public void GetMessageForMessageElementThreeElementsTest()
        {
            XmlElement firstMessageElement=MessageElementStub.CreateMessageElementStub(xmiDocument);
            XmlElement secondMessageElement=MessageElementStub.CreateMessageElementStub(xmiDocument);
            XmlElement thirdMessageElement=MessageElementStub.CreateMessageElementStub(xmiDocument);
            Message firstMessage=new Message(ZERO_POSITION,"",firstMessageElement);
            Message secondMessage=new Message(ZERO_POSITION,"",secondMessageElement);
            Message thirdMessage=new Message(ZERO_POSITION,"",thirdMessageElement);
            Interaction interaction=new Interaction(ZERO_POSITION,"",null);
            interaction.Messages.Add(firstMessage);
            interaction.Messages.Add(secondMessage);
            interaction.Messages.Add(thirdMessage);

            Message actualFirstMessage=sequenceChartModelCreator.GetMessageForMessageElement(firstMessageElement,interaction);
            Assert.IsNotNull(actualFirstMessage);
            Assert.AreEqual(firstMessage,actualFirstMessage);

            Message actualSecondMessage=sequenceChartModelCreator.GetMessageForMessageElement(secondMessageElement,interaction);
            Assert.IsNotNull(actualFirstMessage);
            Assert.AreEqual(secondMessage,actualSecondMessage);

            Message actualThirdMessage=sequenceChartModelCreator.GetMessageForMessageElement(thirdMessageElement,interaction);
            Assert.IsNotNull(actualThirdMessage);
            Assert.AreEqual(thirdMessage,actualThirdMessage);
        }
        protected internal void ConnectMessageEndsToMessage(ArrayList relevantLifelines,Interaction interaction)
        {
            IEnumerator itrRelevantLifelines=relevantLifelines.GetEnumerator();
            Lifeline currentLifeline;
            ArrayList currentMessageEnds;

            while(itrRelevantLifelines.MoveNext())
            {
                currentLifeline=(Lifeline)itrRelevantLifelines.Current;
                currentMessageEnds=currentLifeline.MessageEnds;
                IEnumerator itrRelevantMessageEnds=currentMessageEnds.GetEnumerator();

                MessageEnd currentMessageEnd;
                XmlElement currentMessageEndElement;
                XmlElement currentMessageElement;
                Message currentMessage;

                while(itrRelevantMessageEnds.MoveNext())
                {
                    currentMessageEnd=(MessageEnd)itrRelevantMessageEnds.Current;
                    currentMessageEndElement=currentMessageEnd.XmlRepresentation;
                    currentMessageElement=
                        modelDocumentInterpreter.GetMessageElementForMessageOccurrenceSpec(currentMessageEndElement);
                    currentMessage=GetMessageForMessageElement(currentMessageElement,interaction);
                    ConnectMessageEndToMessage(currentMessageEnd,currentMessage);
                }
            }
        }
        protected internal void CreateExecutionsForLifeline(Lifeline lifeline,Interaction interaction, XmlElement diagramElement)
        {
            string lifelineId=lifeline.XmiId;
            XmlElement lifelineElement=lifeline.XmlRepresentation;
            XmlElement interactionElement=(XmlElement)lifelineElement.ParentNode;
            ArrayList executions=new ArrayList();
            ArrayList executionElements=modelDocumentInterpreter.GetExecutionSpecElementsForLifeline(lifelineElement);
            IEnumerator itrExecutionElements=executionElements.GetEnumerator();
            XmlElement currentExecutionElement;
            ExecutionSpecification currentNewExecution;
            Point currentExecutionPosition;
            Size currentExecutionDimension;
            string currentExecutionId;

            while(itrExecutionElements.MoveNext())
            {
                currentExecutionElement=(XmlElement)itrExecutionElements.Current;
                currentExecutionPosition=diDocumentInterpreter.GetExecutionSpecPosition(diagramElement,currentExecutionElement);
                currentExecutionDimension=diDocumentInterpreter.GetExecutionSpecDimension(diagramElement,currentExecutionElement);
                currentExecutionId=currentExecutionElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
                currentNewExecution=new ExecutionSpecification(currentExecutionPosition,currentExecutionId,currentExecutionElement);
                currentNewExecution.Dimension=currentExecutionDimension;
                currentNewExecution.CoveredLifeline=lifeline;
                executions.Add(currentNewExecution);
            }

            executions=SortListForVerticalPosition(executions);
            lifeline.ExecutionSpecifications=executions;

            if(executions.Count>0)
            {
                interaction.ExecutionSpecs.AddRange(executions);
            }
        }
        public void CreateMessageEndsForLifelineTwoMessageOccurrenceSpecTest()
        {
            string interactionElementContent = "<message xmi:id='1' xmlns:xmi='http://www.omg.org/XMI' />"+
                                    "<lifeline xmi:id='5' xmlns:xmi='http://www.omg.org/XMI' />"+
                                    "<lifeline xmi:id='6' xmlns:xmi='http://www.omg.org/XMI' />"+
                                    "<fragment xmi:type='uml:MessageOccurrenceSpecification' xmlns:xmi='http://www.omg.org/XMI' xmi:id='25' message='1' covered='5' event='42'/>"+
             									"<fragment xmi:type='uml:MessageOccurrenceSpecification' xmlns:xmi='http://www.omg.org/XMI' xmi:id='26' message='1' covered='6' event='43'/>";
            interactionElement.InnerXml=interactionElementContent;

            string diagramElementContent="<contained>" +
                                         "<contained xsi:type='di2:GraphNode' position='650:673' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' >"+
                                         	"<semanticModel>"+
                                         		"<element xsi:type='uml:Lifeline' href='TheTestModel.uml#5'/>"+
                                         	"</semanticModel>"+
                                            "<anchorage position='2608:2793' graphEdge='/0/@contained.1'/>"+
                                         "</contained>"+
                                         "<contained xsi:type='di2:GraphNode' position='703:723' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>"+
                                         	"<semanticModel>"+
                                         		"<element xsi:type='uml:Lifeline' href='TheTestModel.uml#6'/>"+
                                         	"</semanticModel>"+
                                            "<anchorage position='2804:2857' graphEdge='/0/@contained.1'/>"+
                                         "</contained>"+
                                         "</contained>"+
                                         "<contained xsi:type='di2:GraphEdge' position='34:97' anchor='/1/@contained.0/@contained.0/@anchorage.0 /1/@contained.0/@contained.1/@anchorage.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>"+
                                         	"<semanticModel>"+
                                         		"<element xsi:type='uml:Message' href='TheTestModel.uml#1'/>"+
                                         	"</semanticModel>"+
                                         "</contained>";

            diagramElement.InnerXml=diagramElementContent;

            XmlElement firstSendOperationEventElement=
                    SendOperationEventElementStub.CreateSendOperationEventElementStub(xmiDocument,FIRST_SEND_OPERATION_EVENT_ELEMENT_ID,"");
            XmlElement firstReceiveOperationEventElement=
                    ReceiveOperationEventElementStub.CreateReceiveOperationEventElementStub(xmiDocument,FIRST_RECEIVE_OPERATION_EVENT_ELEMENT_ID,"");

            modelElement.AppendChild(interactionElement);
            modelElement.AppendChild(firstSendOperationEventElement);
            modelElement.AppendChild(firstReceiveOperationEventElement);

            Interaction interaction=new Interaction(ZERO_POSITION,"",interactionElement);

            XmlElement lifelineElement=(XmlElement)interactionElement.SelectSingleNode("//lifeline[@xmi:id='5']",this.namespaceManager);;
            Lifeline lifeline=new Lifeline(ZERO_POSITION,"",lifelineElement);

            sequenceChartModelCreator.CreateMessageEndsForLifeline(lifeline,diagramElement,interaction);

            ArrayList messageOccurrenceSpecs=lifeline.MessageEnds;
            int messageOccurrenceSpecsCount=messageOccurrenceSpecs.Count;
            Assert.IsTrue(messageOccurrenceSpecsCount==1);

            MessageEnd firstActualMessageEnd=(MessageEnd)messageOccurrenceSpecs[0];
            this.AssertXmiId(firstActualMessageEnd,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            this.AssertPosition(firstActualMessageEnd,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_X,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_Y);
            this.AssertIdOfXmiRepresentation(firstActualMessageEnd,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            EventKind firstMessageEndEventKind=firstActualMessageEnd.AssociatedEventKind;
            Assert.IsTrue(firstMessageEndEventKind==EventKind.sendOperationEvent);

            XmlElement secondLifelineElement=(XmlElement)interactionElement.SelectSingleNode("//lifeline[@xmi:id='6']",this.namespaceManager);;
            Lifeline secondLifeline=new Lifeline(ZERO_POSITION,"",secondLifelineElement);

            sequenceChartModelCreator.CreateMessageEndsForLifeline(secondLifeline,diagramElement,interaction);

            messageOccurrenceSpecs=secondLifeline.MessageEnds;
            messageOccurrenceSpecsCount=messageOccurrenceSpecs.Count;
            Assert.IsTrue(messageOccurrenceSpecsCount==1);
            MessageEnd secondActualMessageEnd=(MessageEnd)messageOccurrenceSpecs[0];
            this.AssertXmiId(secondActualMessageEnd,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            this.AssertPosition(secondActualMessageEnd,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_X,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_Y);
            this.AssertIdOfXmiRepresentation(secondActualMessageEnd,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            EventKind secondMessageEndEventKind=secondActualMessageEnd.AssociatedEventKind;
            Assert.IsTrue(secondMessageEndEventKind==EventKind.receiveOperationEvent);
        }
        protected internal void ConnectMessageEndsToBehaviorExecutionSpecs(Interaction relevantInteraction)
        {
            ArrayList currentExecutionSpecs;
            IEnumerator itrCurrentExecutionSpecs;
            IEnumerator itrLifelines;
            Lifeline currentLifeline;
            ExecutionSpecification currentExecutionSpec;
            ArrayList lifelines=relevantInteraction.Lifelines;
            itrLifelines=lifelines.GetEnumerator();

            while(itrLifelines.MoveNext())
            {
                currentLifeline=(Lifeline)itrLifelines.Current;
                currentExecutionSpecs=currentLifeline.ExecutionSpecifications;
                itrCurrentExecutionSpecs=currentExecutionSpecs.GetEnumerator();

                while(itrCurrentExecutionSpecs.MoveNext())
                {
                    currentExecutionSpec=(ExecutionSpecification)itrCurrentExecutionSpecs.Current;
                    ConnectMessageEndsToBehaviorExecutionSpec(currentExecutionSpec);
                }
            }
        }
        public void CreateMessageEndsForLifelineNoMessageOccurrenceSpecTest()
        {
            string interactionElementContent = "<lifeline xmi:id='5' xmlns:xmi='http://www.omg.org/XMI' />";
            interactionElement.InnerXml=interactionElementContent;

            string diagramElementContent="<contained>" +
                                         "</contained>";
            diagramElement.InnerXml=diagramElementContent;

            XmlElement lifelineElement=(XmlElement)interactionElement.FirstChild;
            Lifeline lifeline=new Lifeline(ZERO_POSITION,"",lifelineElement);
            Interaction interaction=new Interaction(ZERO_POSITION,"",interactionElement);

            sequenceChartModelCreator.CreateMessageEndsForLifeline(lifeline,diagramElement,interaction);

            ArrayList messageOccurrenceSpecs=lifeline.MessageEnds;
            int messageOccurrenceSpecsCount=messageOccurrenceSpecs.Count;
            Assert.IsTrue(messageOccurrenceSpecsCount==0);
        }
        public void ConnectMessageEndToMessagesTest()
        {
            XmlElement firstMessageElement =MessageElementStub.CreateMessageElementStub(xmiDocument,FIRST_MESSAGE_ELEMENT_ID);
            firstMessageElement.SetAttribute(UmlModelElements.SEND_EVENT_ATTR_NAME,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            firstMessageElement.SetAttribute(UmlModelElements.RECEIVE_EVENT_ATTR_NAME,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            Message firstMessage =new Message(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,firstMessageElement);

            XmlElement firstSourceMessageEndElement=
                MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            firstSourceMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,FIRST_MESSAGE_ELEMENT_ID);
            MessageEnd firstSourceMessageEnd=new MessageEnd(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,firstSourceMessageEndElement);

            XmlElement firstDestinationMessageEndElement=
                    MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            firstDestinationMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,FIRST_MESSAGE_ELEMENT_ID);
            MessageEnd firstDestinationMessageEnd=new MessageEnd(ZERO_POSITION,FOURTH_MESSAGE_ELEMENT_ID,firstDestinationMessageEndElement);

            XmlElement secondMessageElement =MessageElementStub.CreateMessageElementStub(xmiDocument,SECOND_MESSAGE_ELEMENT_ID);
            secondMessageElement.SetAttribute(UmlModelElements.SEND_EVENT_ATTR_NAME,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            secondMessageElement.SetAttribute(UmlModelElements.RECEIVE_EVENT_ATTR_NAME,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            Message secondMessage =new Message(ZERO_POSITION,SECOND_MESSAGE_ELEMENT_ID,secondMessageElement);

            XmlElement secondSourceMessageEndElement=
                MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            secondSourceMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,SECOND_MESSAGE_ELEMENT_ID);
            MessageEnd secondSourceMessageEnd=new MessageEnd(ZERO_POSITION,SECOND_MESSAGE_ELEMENT_ID,secondSourceMessageEndElement);

            XmlElement secondDestinationMessageEndElement=
                    MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID);
            secondDestinationMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,SECOND_MESSAGE_ELEMENT_ID);
            MessageEnd secondDestinationMessageEnd=new MessageEnd(ZERO_POSITION,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID,secondDestinationMessageEndElement);

            Lifeline firstLifeline=new Lifeline(ZERO_POSITION,"",null);
            firstLifeline.MessageEnds.Add(firstSourceMessageEnd);
            firstLifeline.MessageEnds.Add(secondSourceMessageEnd);

            Lifeline secondLifeline=new Lifeline(ZERO_POSITION,"",null);
            secondLifeline.MessageEnds.Add(firstDestinationMessageEnd);
            secondLifeline.MessageEnds.Add(secondDestinationMessageEnd);

            interactionElement.AppendChild(firstMessageElement);
            interactionElement.AppendChild(secondMessageElement);
            interactionElement.AppendChild(firstSourceMessageEndElement);
            interactionElement.AppendChild(firstDestinationMessageEndElement);
            interactionElement.AppendChild(secondSourceMessageEndElement);
            interactionElement.AppendChild(secondDestinationMessageEndElement);

            Interaction interaction=new Interaction(ZERO_POSITION,"",null);
            interaction.Messages.Add(firstMessage);
            interaction.Messages.Add(secondMessage);

            ArrayList relevantMessageEnds=new ArrayList();
            relevantMessageEnds.Add(firstSourceMessageEnd);
            relevantMessageEnds.Add(firstDestinationMessageEnd);
            relevantMessageEnds.Add(secondSourceMessageEnd);
            relevantMessageEnds.Add(secondDestinationMessageEnd);

            ArrayList relevantLifelines=new ArrayList();
            relevantLifelines.Add(firstLifeline);
            relevantLifelines.Add(secondLifeline);

            sequenceChartModelCreator.ConnectMessageEndsToMessage(relevantLifelines,interaction);

            MessageEnd firstActualSoureMessageEnd=firstMessage.SourceMessageEnd;
            Assert.IsNotNull(firstActualSoureMessageEnd);
            Assert.AreEqual(firstSourceMessageEnd,firstActualSoureMessageEnd);
            MessageEnd firstActualDestinationMessageEnd=firstMessage.DestinationMessageEnd;
            Assert.IsNotNull(firstActualDestinationMessageEnd);
            Assert.AreEqual(firstActualDestinationMessageEnd,firstActualDestinationMessageEnd);

            MessageEnd secondActualSoureMessageEnd=secondMessage.SourceMessageEnd;
            Assert.IsNotNull(secondActualSoureMessageEnd);
            Assert.AreEqual(secondSourceMessageEnd,secondActualSoureMessageEnd);
            MessageEnd secondActualDestinationMessageEnd=secondMessage.DestinationMessageEnd;
            Assert.IsNotNull(secondActualDestinationMessageEnd);
            Assert.AreEqual(secondActualDestinationMessageEnd,secondActualDestinationMessageEnd);
        }
        public void Init()
        {
            xmiDocument= new XmlDocument();
            modelDocumentInterpreter=new XmiModelDocumentInterpreter();
            dIDocumentInterpreter=new PapyrusXmiDIDocumentInterpreter(MODEL_DOCUMENT_NAME);
            sequenceChartModelCreator=new SequenceChartModelCreator(modelDocumentInterpreter,dIDocumentInterpreter);
            namespaceManager=new XmlNamespaceManager(xmiDocument.NameTable);
            namespaceManager.AddNamespace(XmiElements.UML_NAMESPACE_PREFIX,XmiElements.UML_NAMESPACE_URI);
            namespaceManager.AddNamespace(XmiElements.XMI_NAMESPACE_PREFIX,XmiElements.XMI_NAMESPACE_URI);

            firstConsideredLifelineHorizontal=
                    new Lifeline(POSITION_CONSIDERED_FIRST_ELEMENT_HORIZONTAL,EMPTY_STRING,null);
            secondConsideredLifelineHorizontal=
                    new Lifeline(POSITION_CONSIDERED_SECOND_ELEMENT_HORIZONTAL,EMPTY_STRING,null);
            thirdConsideredLifelineHorizontal=
                    new Lifeline(POSITION_CONSIDERED_THIRD_ELEMENT_HORIZONTAL,EMPTY_STRING,null);
            fourthConsideredLifelineHorizontal=
                    new Lifeline(POSITION_CONSIDERED_FOURTH_ELEMENT_HORIZONTAL,EMPTY_STRING,null);
            fifthConsideredLifelineHorizontal=
                    new Lifeline(POSITION_CONSIDERED_FIFTH_ELEMENT_HORIZONTAL,EMPTY_STRING,null);

            firstConsideredLifelineVertical=
                    new Lifeline(POSITION_CONSIDERED_FIRST_ELEMENT_VERTICAL,EMPTY_STRING,null);
            secondConsideredLifelineVertical=
                    new Lifeline(POSITION_CONSIDERED_SECOND_ELEMENT_VERTICAL,EMPTY_STRING,null);
            thirdConsideredLifelineVertical=
                    new Lifeline(POSITION_CONSIDERED_THIRD_ELEMENT_VERTICAL,EMPTY_STRING,null);
            fourthConsideredLifelineVertical=
                    new Lifeline(POSITION_CONSIDERED_FOURTH_ELEMENT_VERTICAL,EMPTY_STRING,null);
            fifthConsideredLifelineVertical=
                    new Lifeline(POSITION_CONSIDERED_FIFTH_ELEMENT_VERTICAL,EMPTY_STRING,null);

            interactionElement=InteractionElementStub.CreateInteractionElementStub(xmiDocument);
            modelElement=ModelElementStub.CreateModelElementStub(xmiDocument);
            interaction= new Interaction(ZERO_POSITION,EMPTY_STRING,interactionElement);
            diagramElement =DiagramElementStub.CreateDiagramElementStub(xmiDocument);
        }
 public ArrayList InterpretSequenceChartModel(Interaction toInterpretInteraction)
 {
     ArrayList interactionEditorEntry;
     this.toInterpretInteraction=toInterpretInteraction;
     InterpretInteraction(toInterpretInteraction);
     ArrayList lifelines=this.toInterpretInteraction.Lifelines;
     InterpretLifelines(lifelines);
     //InterpretElementsOfLifelines(lifelines);
     interactionEditorEntry=this.entryCreator.EditorContent;
     InterpretOccurrenceSpecifications(toInterpretInteraction);
     InterpretDestructionEvents(lifelines);
     return interactionEditorEntry;
 }
        protected internal void CreateExecutionsForLifelines(Interaction interaction, XmlElement diagramElement)
        {
            Lifeline currentLifeline;
            ArrayList lifelines=interaction.Lifelines;
            IEnumerator itrLifelines=lifelines.GetEnumerator();

            while(itrLifelines.MoveNext())
            {
                currentLifeline=(Lifeline)itrLifelines.Current;
                CreateExecutionsForLifeline(currentLifeline,interaction,diagramElement);

            }
        }
 protected internal void InterpretInteraction(Interaction interaction)
 {
     string interactionName=interaction.Name;
     this.entryCreator.InitEditorContent(interactionName);
 }
 protected internal Interaction CreateInteraction(XmlElement diagramElement)
 {
     string interactionName=diagramElement.GetAttribute(UmlModel.NAME_ATTR_NAME);
     string interactionId=diagramElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
     Interaction newInteraction=new Interaction(ZERO_POSITION,interactionId,diagramElement);
     newInteraction.Name=interactionName;
     return newInteraction;
 }
        //ändern
        /*protected internal void InterpretElementsOfLifelines(ArrayList lifelines)
        {

            //Sorts the Elements that cover the Lifeline after there appearing in the Diagram
            ArrayList elementsOfLifelines=sorter.SortElementsOfLifelines(lifelines);
            IEnumerator itrElementsOfLifelines=elementsOfLifelines.GetEnumerator();
            SequenceChartElement currentElement;
            BehaviorExecutionSpecification currentExecutionSpec;
            MessageEnd currentMessageEnd;
            MessageEndKind currentMessageEndKind;
            Lifeline currentLifeline;

            //Debug
            int index=0;
            Message currentMessage;
            string currentMessageName;

            while(itrElementsOfLifelines.MoveNext())
            {
                currentElement=(SequenceChartElement)itrElementsOfLifelines.Current;

                if(currentElement is BehaviorExecutionSpecification)
                {
                    currentExecutionSpec =(BehaviorExecutionSpecification)currentElement;

                    if(!(this.workedExecutionSpecs.Contains(currentExecutionSpec)))
                    {
                        currentLifeline=currentExecutionSpec.CoveredLifeline;
                        InterpretSourceMessageEndsOfExecution(currentExecutionSpec,currentLifeline);
                    }
                }
                else if(currentElement is MessageEnd)
                {
                    currentMessageEnd=(MessageEnd)currentElement;
                    currentMessageEndKind= currentMessageEnd.MessageEndKind;

                    //Debug
                    currentMessage=currentMessageEnd.CorrespondingMessage;
                    currentMessageName=currentMessage.Name;

                    if(currentMessageEndKind.Equals(MessageEndKind.sourceEnd) && !(this.workedMessageEnds.Contains(currentMessageEnd)))
                    {
                        currentLifeline=currentMessageEnd.CoveredLifeline;
                        InterpretMessageSourceEnd(currentMessageEnd,currentLifeline);
                    }
                }
                index++;
            }
        }*/
        private ArrayList GetOccurrenceSpecificationsOfInteraction(Interaction relevantInteraction)
        {
            ArrayList occurrenceSpecifications= new ArrayList();
            IEnumerator itrMessageOccurrenceSpecs;
            MessageEnd  currentMessageEnd;

            if(relevantInteraction.ExecutionOccurrenceSpecs.Count>0)
            {
                occurrenceSpecifications.AddRange(relevantInteraction.ExecutionOccurrenceSpecs);
            }

            if(relevantInteraction.MessageOccurrenceSpecs.Count>0)
            {
                itrMessageOccurrenceSpecs=relevantInteraction.MessageOccurrenceSpecs.GetEnumerator();

                while(itrMessageOccurrenceSpecs.MoveNext())
                {
                    currentMessageEnd=(MessageEnd)itrMessageOccurrenceSpecs.Current;

                    if(currentMessageEnd.MessageEndKind == MessageEndKind.sourceEnd)
                    {
                        occurrenceSpecifications.Add(currentMessageEnd);
                    }
                }
            }
            return occurrenceSpecifications;
        }
 public void GetMessageForMessageElementNoElementTest()
 {
     Interaction interaction=new Interaction(ZERO_POSITION,"",null);
     Message actualFirstMessage=sequenceChartModelCreator.GetMessageForMessageElement(null,interaction);
     Assert.IsNull(actualFirstMessage);
 }