Exemple #1
0
        public void TestGroupSerializationDeserialization()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });

            CompareObjects comp = new CompareObjects();

            comp.CompareStaticFields     = false;
            comp.CompareStaticProperties = false;
            comp.ElementsToIgnore        = PrimCompareIgnoreList;

            Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString);
        }
Exemple #2
0
        public void TestNullMediaEntryIsNotAnError()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            sop1.Shape.Media    = new PrimitiveBaseShape.PrimMedia(3);
            sop1.Shape.Media[0] = null;
            sop1.Shape.Media[1] = new MediaEntry();
            sop1.Shape.Media[2] = null;

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });
        }
Exemple #3
0
        public void TestRenderMaterialsSerialization()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            var mat1 = new RenderMaterial(UUID.Random(), UUID.Random());
            var mat2 = new RenderMaterial(UUID.Random(), UUID.Random());

            sop1.Shape.RenderMaterials.AddMaterial(mat1);
            sop2.Shape.RenderMaterials.AddMaterial(mat2);

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });

            var newsop1 = deserGroup.GetChildPart(1);
            var newsop2 = deserGroup.GetChildPart(2);
            var newsop3 = deserGroup.GetChildPart(3);

            Assert.That(sop1.Shape.RenderMaterials, Is.EqualTo(newsop1.Shape.RenderMaterials));
            Assert.That(sop2.Shape.RenderMaterials, Is.EqualTo(newsop2.Shape.RenderMaterials));
            Assert.That(sop3.Shape.RenderMaterials, Is.EqualTo(newsop3.Shape.RenderMaterials));
        }