Esempio n. 1
0
        public void MaterialGroup_Elements_Can_Be_Retrieved_By_Id()
        {
            var primitive = new Primitive();

            var mGroupIdOne = new MaterialGroup();
            mGroupIdOne.Id = 1;

            var mGroupIdTwo = new MaterialGroup();
            mGroupIdTwo.Id = 2;

            var mGroupIdDefault = new MaterialGroup();
            mGroupIdDefault.Id = -1;

            primitive.Add(mGroupIdDefault);
            primitive.Add(mGroupIdTwo);
            primitive.Add(mGroupIdOne);

            Assert.NotNull(primitive.GetMaterialGroup(-1));
            Assert.NotNull(primitive.GetMaterialGroup(1));
            Assert.NotNull(primitive.GetMaterialGroup(2));
        }
Esempio n. 2
0
        public void Physics_Element_Can_Be_Retrieved_When_It_Is_Present()
        {
            var primitive = new Primitive();
            var physics = new Physics();
            physics.Enabled = true;
            physics.Movable = true;
            physics.Weight = 1234;

            primitive.Add(physics);

            Assert.NotNull(primitive.GetPhysics());
            Assert.Equal(physics.Weight, primitive.GetPhysics().Weight);
        }
Esempio n. 3
0
        public void Material_Elements_Can_Be_Retrieved_From_A_MaterialGroup()
        {
            var primitive = new Primitive();

            var mGroupIdOne = new MaterialGroup();
            mGroupIdOne.Id = 1;

            mGroupIdOne.Add(Material.Default);
            primitive.Add(mGroupIdOne);

            Assert.NotNull(primitive.GetMaterialGroup(1));
            Assert.Equal(Material.Default.ToString(), primitive.GetMaterialGroup(1).GetMaterial().ToString());
        }
Esempio n. 4
0
        public void Network_Element_Can_Be_Retrieved_When_It_Is_Present()
        {
            var primitive = new Primitive();
            var network = new Network();
            network.Enabled = true;
            network.Owner = Guid.NewGuid().ToString();

            primitive.Add(network);

            Assert.NotNull(primitive.GetNetwork());
            Assert.Equal(network.Enabled, primitive.GetNetwork().Enabled);
            Assert.Equal(network.Owner, primitive.GetNetwork().Owner);
        }
Esempio n. 5
0
        public void Texture_Elements_Can_Be_Retrieved_From_A_MaterialGroup()
        {
            var primitive = new Primitive();

            var mGroupIdOne = new MaterialGroup();
            mGroupIdOne.Id = 1;

            var texture = new Texture { Source = Guid.NewGuid().ToString() };
            mGroupIdOne.Add(texture);
            primitive.Add(mGroupIdOne);

            Assert.NotNull(primitive.GetMaterialGroup(1));
            Assert.Equal(texture.Source, primitive.GetMaterialGroup(1).GetTexture().Source);
        }
Esempio n. 6
0
        public void Interaction_Settings_Can_Be_Retrieved_From_A_Physics_Element()
        {
            var primitive = new Primitive();
            var physics = new Physics();

            var interaction = new Interaction();
            interaction.Element = Guid.NewGuid().ToString();

            physics.Add(interaction);
            primitive.Add(physics);

            Assert.NotEmpty(primitive.GetPhysics().GetInteractions());
            Assert.Equal(1, primitive.GetPhysics().GetInteractions().Count);
            Assert.Equal(interaction.Element, primitive.GetPhysics().GetInteractions().First().Element);
        }
Esempio n. 7
0
        public void Filter_Settings_Can_Be_Retrieved_From_A_Network_Element()
        {
            var primitive = new Primitive();
            var network = new Network();

            var filter = new Filter();
            filter.Target = Guid.NewGuid().ToString();

            network.Add(filter);
            primitive.Add(network);

            Assert.NotEmpty(primitive.GetNetwork().GetFilters());
            Assert.Equal(1, primitive.GetNetwork().GetFilters().Count);
            Assert.Equal(filter.Target, primitive.GetNetwork().GetFilters().First().Target);
        }
Esempio n. 8
0
        public void Web_Elements_Can_Be_Retrieved_From_A_MaterialGroup()
        {
            var primitive = new Primitive();

            var mGroupIdOne = new MaterialGroup();
            mGroupIdOne.Id = 1;

            var web = new Web { Source = Guid.NewGuid().ToString() };
            mGroupIdOne.Add(web);
            primitive.Add(mGroupIdOne);

            Assert.NotNull(primitive.GetMaterialGroup(1));
            Assert.Equal(web.Source, primitive.GetMaterialGroup(1).GetWeb().Source);
        }
Esempio n. 9
0
        public void Video_Elements_Can_Be_Retrieved_From_A_MaterialGroup()
        {
            var primitive = new Primitive();

            var mGroupIdOne = new MaterialGroup();
            mGroupIdOne.Id = 1;

            var video = new Video { Source = Guid.NewGuid().ToString() };
            mGroupIdOne.Add(video);
            primitive.Add(mGroupIdOne);

            Assert.NotNull(primitive.GetMaterialGroup(1));
            Assert.Equal(video.Source, primitive.GetMaterialGroup(1).GetVideo().Source);
        }
Esempio n. 10
0
        public void Serialiser_Can_Write_A_Simple_Nested_Hierarchy_To_A_String()
        {
            var immlDocument = new ImmlDocument();
            immlDocument.Author = Guid.NewGuid().ToString();

            var model = new Model();
            model.Name = Guid.NewGuid().ToString();
            model.Source = string.Format("http://{0}", Guid.NewGuid().ToString());

            var primitive = new Primitive();
            primitive.Name = Guid.NewGuid().ToString();

            var camera = new Camera();
            camera.Name = Guid.NewGuid().ToString();

            primitive.Add(camera);
            model.Add(primitive);
            immlDocument.Add(model);

            var immlSerialiser = new ImmlSerialiser();
            var immlString = immlSerialiser.Write(immlDocument);

            var textReader = new StringReader(immlString);
            var xDoc = XDocument.Load(textReader);

            //verify the model is in the correct place
            var xElementModel = xDoc.Descendants(XName.Get("Model", immlSerialiser.Namespace)).Where(e => e.Attribute(XName.Get("Name")).Value == model.Name).FirstOrDefault();
            Assert.NotNull(xElementModel);
            Assert.Equal(immlDocument.Name, xElementModel.Parent.Attribute(XName.Get("Name")).Value);

            //verify the primitive is in the correct place
            var xElementPrimitive = xDoc.Descendants(XName.Get("Primitive", immlSerialiser.Namespace)).Where(e => e.Attribute(XName.Get("Name")).Value == primitive.Name).FirstOrDefault();
            Assert.NotNull(xElementPrimitive);
            Assert.Equal(model.Name, xElementPrimitive.Parent.Attribute(XName.Get("Name")).Value);

            //verify the camera is in the correct place
            var xElementCamera = xDoc.Descendants(XName.Get("Camera", immlSerialiser.Namespace)).Where(e => e.Attribute(XName.Get("Name")).Value == camera.Name).FirstOrDefault();
            Assert.NotNull(xElementCamera);
            Assert.Equal(primitive.Name, xElementCamera.Parent.Attribute(XName.Get("Name")).Value);
        }
Esempio n. 11
0
        public void Nested_Element_Parent_Property_Should_Be_Equal_To_The_Parent_Element()
        {
            var parent = new Primitive();
            var child = new Primitive();

            parent.Add(child);

            Assert.Equal(parent, child.Parent);
        }