Example #1
0
        public bool Run()
        {
            AssetData assetdata;
            Gesture   gestureserialized;
            Gesture   gesture;

            var theCreator = new UGUIWithName
            {
                ID        = UUID.Random,
                HomeURI   = new Uri("http://example.com/"),
                FirstName = "The",
                LastName  = "Creator"
            };
            UUID animID  = UUID.Random;
            UUID soundID = UUID.Random;

            gesture = new Gesture();
            gesture.Sequence.Add(new Gesture.StepAnimation {
                Name = "Animation", AssetID = animID, AnimationStart = true
            });
            gesture.Sequence.Add(new Gesture.StepChat {
                Text = "Hello"
            });
            gesture.Sequence.Add(new Gesture.StepSound {
                Name = "Sound", AssetID = soundID
            });
            gesture.Sequence.Add(new Gesture.StepWait {
                WaitTime = 1, WaitForTime = true, WaitForAnimation = true
            });
            gesture.Sequence.Add(new Gesture.StepEndOfGesture());

            assetdata         = gesture.Asset();
            gestureserialized = new Gesture(assetdata);

            if (gesture.Sequence.Count != gestureserialized.Sequence.Count)
            {
                m_Log.FatalFormat("Gesture sequence count not identical ({0} != {1})", gesture.Sequence.Count, gestureserialized.Sequence.Count);
                return(false);
            }

            for (int i = 0; i < gesture.Sequence.Count; ++i)
            {
                if (gesture.Sequence[i].GetType() != gestureserialized.Sequence[i].GetType())
                {
                    m_Log.Fatal("Gesture sequence item not identical");
                    return(false);
                }

                if (gesture.Sequence[i] is Gesture.StepAnimation)
                {
                    var anim1 = (Gesture.StepAnimation)gesture.Sequence[i];
                    var anim2 = (Gesture.StepAnimation)gestureserialized.Sequence[i];
                    if (anim1.AnimationStart != anim2.AnimationStart)
                    {
                        m_Log.Fatal("Gesture sequence item Animation not identical");
                        return(false);
                    }
                    if (anim1.AssetID != anim2.AssetID)
                    {
                        m_Log.Fatal("Gesture sequence item Animation not identical");
                        return(false);
                    }
                    if (anim1.Name != anim2.Name)
                    {
                        m_Log.Fatal("Gesture sequence item Animation not identical");
                        return(false);
                    }
                }
                if (gesture.Sequence[i] is Gesture.StepChat)
                {
                    var chat1 = (Gesture.StepChat)gesture.Sequence[i];
                    var chat2 = (Gesture.StepChat)gestureserialized.Sequence[i];

                    if (chat1.Text != chat2.Text)
                    {
                        m_Log.Fatal("Gesture sequence item Chat not identical");
                        return(false);
                    }
                }
                if (gesture.Sequence[i] is Gesture.StepSound)
                {
                    var sound1 = (Gesture.StepSound)gesture.Sequence[i];
                    var sound2 = (Gesture.StepSound)gestureserialized.Sequence[i];

                    if (sound1.AssetID != sound2.AssetID)
                    {
                        m_Log.Fatal("Gesture sequence item Sound not identical");
                        return(false);
                    }
                    if (sound1.Name != sound2.Name)
                    {
                        m_Log.Fatal("Gesture sequence item Sound not identical");
                        return(false);
                    }
                }
                if (gesture.Sequence[i] is Gesture.StepWait)
                {
                    var wait1 = (Gesture.StepWait)gesture.Sequence[i];
                    var wait2 = (Gesture.StepWait)gestureserialized.Sequence[i];

                    if (wait1.WaitTime != wait2.WaitTime)
                    {
                        m_Log.Fatal("Gesture sequence item Wait not identical");
                        return(false);
                    }
                    if (wait1.WaitForTime != wait2.WaitForTime)
                    {
                        m_Log.Fatal("Gesture sequence item Wait not identical");
                        return(false);
                    }
                    if (wait1.WaitForAnimation != wait2.WaitForAnimation)
                    {
                        m_Log.Fatal("Gesture sequence item Wait not identical");
                        return(false);
                    }
                }
            }

            m_Log.Info("Testing references");
            List <UUID> refs = gestureserialized.References;

            if (refs.Count != 2)
            {
                m_Log.Fatal("Gesture Item Reference count is wrong");
                return(false);
            }

            if (!refs.Contains(soundID))
            {
                m_Log.FatalFormat("Gesture Inventory Item AssetID {0} is not referenced", soundID);
                return(false);
            }

            if (!refs.Contains(animID))
            {
                m_Log.FatalFormat("Gesture Inventory Item AssetID {0} is not referenced", animID);
                return(false);
            }

            return(true);
        }