Exemple #1
0
        public void RenderMaterial_DefaultConstructedMaterialsGeneratesTheSameMaterialID()
        {
            RenderMaterial mat  = new RenderMaterial();
            RenderMaterial mat2 = new RenderMaterial();

            UUID matID  = RenderMaterial.GenerateMaterialID(mat);
            UUID mat2ID = RenderMaterial.GenerateMaterialID(mat2);

            Assert.That(mat, Is.EqualTo(mat2));
            Assert.That(matID, Is.EqualTo(mat2ID));
        }
Exemple #2
0
        public void RenderMaterial_CopiedMaterialGeneratesTheSameMaterialID()
        {
            RenderMaterial mat     = new RenderMaterial();
            RenderMaterial matCopy = (RenderMaterial)mat.Clone();

            UUID matID     = RenderMaterial.GenerateMaterialID(mat);
            UUID matCopyID = RenderMaterial.GenerateMaterialID(matCopy);

            Assert.That(mat, Is.EqualTo(matCopy));
            Assert.That(matID, Is.EqualTo(matCopyID));
        }
Exemple #3
0
        public void RenderMaterial_DifferentMaterialsGeneratesDifferentMaterialID()
        {
            RenderMaterial mat  = new RenderMaterial();
            RenderMaterial mat2 = new RenderMaterial();

            mat2.NormalID = UUID.Random();

            Assert.AreNotEqual(mat, mat2);
            UUID matID  = RenderMaterial.GenerateMaterialID(mat);
            UUID mat2ID = RenderMaterial.GenerateMaterialID(mat2);

            Assert.AreNotEqual(matID, mat2ID);
        }
Exemple #4
0
        public void RenderMaterial_SerializedMaterialGeneratesTheSameMaterialID()
        {
            RenderMaterial mat   = new RenderMaterial();
            UUID           matID = new UUID(mat.ComputeMD5Hash(), 0);

            byte[] matData = mat.ToBytes();

            RenderMaterial newmat   = RenderMaterial.FromBytes(matData, 0, matData.Length);
            UUID           newmatID = RenderMaterial.GenerateMaterialID(newmat);

            Assert.That(mat, Is.EqualTo(newmat));
            Assert.That(matID, Is.EqualTo(newmatID));
        }
Exemple #5
0
        public void RenderMaterial_SerializedMaterialsDataGeneratesTheSameMaterialID()
        {
            RenderMaterials materials = new RenderMaterials();
            RenderMaterial  mat       = new RenderMaterial();
            UUID            matID     = materials.AddMaterial(mat);

            byte[]          matData      = materials.ToBytes();
            RenderMaterials newMaterials = RenderMaterials.FromBytes(matData, 0, matData.Length);

            Assert.That(materials, Is.EqualTo(newMaterials));

            Assert.DoesNotThrow(() =>
            {
                RenderMaterial newmat = newMaterials.GetMaterial(matID);
                UUID newmatID         = RenderMaterial.GenerateMaterialID(newmat);
                Assert.That(mat, Is.EqualTo(newmat));
                Assert.That(matID, Is.EqualTo(newmatID));
            });
        }