Exemplo n.º 1
0
        public void Parse_2Entity()
        {
            CMdlFile fl = new CMdlFile(Path.Combine(Path.GetFullPath(@"..\..\input"), "test_FRME-o1o2.mdl"));

            CFrameParser.Parse(fl.Reader, out CFrame root);

            if (root == null)
            {
                Assert.Fail("Root was null");
            }

            bool eval1 =
                (root.Name == "FRMERootNode") &&
                (root.Childs.Count == 2);
            var  childs = root.Childs;
            bool eval2  =
                (childs[0].Name == "object1") &&
                (childs[0].Childs.Count == 0) &&
                (childs[1].Name == "object2") &&
                (childs[1].Childs.Count == 0);

            Assert.IsTrue(
                eval1, String.Format("Unexpected - Name: \"{0}\" Childs: {1}",
                                     root.Name,
                                     root.Childs.Count));
            Assert.IsTrue(
                eval2, String.Format("Unexpected - O1 Name: \"{0}\" O1 Childs: {1}\nO2 Name: \"{2}\" O2 Childs: {3}",
                                     childs[0].Name, childs[0].Childs.Count,
                                     childs[1].Name, childs[1].Childs.Count));
        }
Exemplo n.º 2
0
        public void LoadFile_Test_ErrorNoFile()
        {
            CMdlFile obj = new CMdlFile();

            CMdlFile.MdlFileError result = obj.LoadFile(@"c:\somePath\invalid.file");

            Assert.IsTrue(result == CMdlFile.MdlFileError.NoFileError);
        }
Exemplo n.º 3
0
        public void SetData_Test_Successful()
        {
            CMdlFile obj = Setup("BINVRSN{\r\n    1\r\n}\r\nFRMERootNode\0", out byte[] cont);

            CMdlFile.MdlFileError result = obj.SetData(cont);

            Assert.IsTrue(CMdlFile.MdlFileError.NoError == result);
        }
Exemplo n.º 4
0
        public void SetData_Test_ErrorNoContent()
        {
            CMdlFile obj = Setup("BINVRSN{\r\n    1\r\n}\r\n", out byte[] cont);

            CMdlFile.MdlFileError result = obj.SetData(cont);

            Assert.IsTrue(CMdlFile.MdlFileError.NoContentError == result);
        }
Exemplo n.º 5
0
        public void SetData_Test_ErrorIncompatible()
        {
            CMdlFile obj = Setup("BINVRSN{\r\n    2\r\n}\r\n", out byte[] cont);

            CMdlFile.MdlFileError result = obj.SetData(cont);

            Assert.IsTrue(CMdlFile.MdlFileError.IncompatibleError == result);
        }
Exemplo n.º 6
0
        public void SetData_Test_ErrorEmpty()
        {
            CMdlFile obj = new CMdlFile();

            CMdlFile.MdlFileError result = obj.SetData(new byte[0]);

            Assert.IsTrue(CMdlFile.MdlFileError.EmptyFileError == result);
        }
Exemplo n.º 7
0
        public void SetData_Test_ErrorInvalid()
        {
            CMdlFile obj = new CMdlFile();

            CMdlFile.MdlFileError result = obj.SetData(null);

            Assert.IsTrue(CMdlFile.MdlFileError.InvalidDataError == result);
        }
Exemplo n.º 8
0
        public void LoadFile_Test_Success()
        {
            CMdlFile obj      = new CMdlFile();
            string   fullPath = Path.Combine(Path.GetFullPath(@"..\..\input"), "test_root.mdl");

            CMdlFile.MdlFileError result = obj.LoadFile(fullPath);

            Assert.IsTrue(CMdlFile.MdlFileError.NoError == result, String.Format("Unexpected result ({0}) loading file {1}", ((int)result).ToString(), fullPath));
        }
Exemplo n.º 9
0
        public void HasData_Test_Negative()
        {
            CMdlFile obj = Setup("", out byte[] cont);

            obj.SetData(cont);

            bool result = obj.HasData();

            Assert.IsFalse(result);
        }
Exemplo n.º 10
0
        public void HasData_Test_Positive()
        {
            CMdlFile obj = Setup("BINVRSN{\r\n    1\r\n}\r\nFRMERootNode", out byte[] cont);

            obj.SetData(cont);

            bool result = obj.HasData();

            Assert.IsTrue(result);
        }
Exemplo n.º 11
0
        public CMdlFile Setup(string utf16content, out byte[] binary)
        {
            CMdlFile obj = new CMdlFile();

            binary = new byte[utf16content.Length];
            for (int ci = 0; ci < binary.Length; ci++)
            {
                binary[ci] = (byte)utf16content[ci];
            }
            return(obj);
        }
Exemplo n.º 12
0
        public void Parse_2Entity_1Subchild()
        {
            CMdlFile fl = new CMdlFile(Path.Combine(Path.GetFullPath(@"..\..\input"), "test_FRME-o1o2c21.mdl"));

            CFrameParser.Parse(fl.Reader, out CFrame root);

            if (root == null)
            {
                Assert.Fail("Root was null");
            }

            bool eval1 = root.Childs.Count == 2;
            bool eval2 = root.Childs[0].Childs.Count == 0;
            bool eval3 = root.Childs[1].Childs.Count == 1;

            Assert.IsTrue(
                eval1 && eval2 && eval3,
                String.Format("Results - e1: {0}, e2: {1}, e3: {2}",
                              eval1, eval2, eval3));
        }
Exemplo n.º 13
0
        public void Parse_Root()
        {
            CMdlFile fl = new CMdlFile(Path.Combine(Path.GetFullPath(@"..\..\input"), "test_root.mdl"));

            CFrameParser.Parse(fl.Reader, out CFrame root);

            if (root == null)
            {
                Assert.Fail("Root was null");
            }

            bool eval =
                (root.Name == "FRMERootNode") &&  // frame detection is omitted
                (root.Childs.Count == 0);

            Assert.IsTrue(
                eval, String.Format("Unexpected - Name: \"{0}\" Childs: {1}",
                                    root.Name,
                                    root.Childs.Count));
        }