Ejemplo n.º 1
0
        public void TestMethod06_1() // no se encontraron nodos en clases
        {
            csXML model = new csXML("1.0", "UTF-8");

            model.document.references = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });
            model.document.csNamespace.name    = "Test";
            model.document.csNamespace.Classes = new List <csClass>();

            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 2
0
        public void TestMethod06() // no se encontraron nodos en referencias
        {
            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "Sample0"
                }, csArguments = argList, csLines = null
            });

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name    = "UltimateTest";
            model.document.references          = new List <csReferences>();
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                name = "clase1", partial = "false", inheritance = "false", lines = variables, constructors = constructorList, modifiers = null
            });
            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 3
0
        public void TestMethod06_2() // no se encontraron nodos en constructores
        {
            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "modifier", modifier = "public", isStatic = true, line = 1, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "isStatic", modifier = "public", isStatic = true, line = 2, value = "", type = "bool", lineCode = "", getterOrSetter = true
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            csXML model = new csXML("1.0", "UTF-8");

            model.document.references = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });

            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });
            model.document.csNamespace.name = "Test";
            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 4
0
        public void TestMethod01() // modelo de valor nulo
        {
            //var
            csXML              model    = null;
            String             Code     = ErrorAndExceptionsCatalog._701_Code;
            String             Message  = ErrorAndExceptionsCatalog._701_ModelNotFound;
            TranslateException resultEX = new TranslateException();

            //act
            try {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }
            //arrange
            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 5
0
        public void TestMethod04() // informacion incompleta
        {
            csXML model = new csXML("1.0", "UTF-8");

            model.document.references       = new List <csReferences>();
            model.document.csNamespace.name = "";
            String             Code     = ErrorAndExceptionsCatalog._704_Code;
            String             Message  = ErrorAndExceptionsCatalog._704_NotEnoughInformation;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 6
0
        public void TestMethod03() // tipo de codificación invalido
        {
            csXML model = new csXML();

            model.version  = "1.0";
            model.encoding = "ATF-42";
            String             Code     = ErrorAndExceptionsCatalog._703_Code;
            String             Message  = ErrorAndExceptionsCatalog._703_InvalidEncoding;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 7
0
        public void TestMethod02() // version incorrecta
        {
            csXML model = new csXML();

            model.version  = "2.0";
            model.encoding = "UTF-8";
            String             Code     = ErrorAndExceptionsCatalog._702_Code;
            String             Message  = ErrorAndExceptionsCatalog._702_InvalidVersionModel;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 8
0
        public void TestMethod07() // version nula
        {
            csXML model = new csXML();

            model.version  = "";
            model.encoding = "UTF-8";
            String             Code     = ErrorAndExceptionsCatalog._707_Code;
            String             Message  = ErrorAndExceptionsCatalog._707_ModelVersionNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 9
0
        public void TestMethod05() // no se creó el nodo
        {
            List <csLine> variables = new List <csLine>();

            variables.Add(null);

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(null);

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name = "UnitTest";
            model.document.references       = new List <csReferences>();
            model.document.references.Add(null);
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                name = "clase1", partial = "false", inheritance = "false", lines = variables, constructors = constructorList, modifiers = null
            });
            String             Code     = ErrorAndExceptionsCatalog._705_Code;
            String             Message  = ErrorAndExceptionsCatalog._705_NotCreatedNode;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 10
0
        public void TestMethod015() // el metodo no retorna un valor
        {
            List <csLine> methodLines = new List <csLine>();

            methodLines.Add(new csLine()
            {
                line = 0, lineCode = "var x = 5;", executeMethods = null
            });

            List <csArgument> methodsArgs = new List <csArgument>();

            methodsArgs.Add(new csArgument()
            {
                type = "string", value = "Saludo"
            });

            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csMethods()
            {
                name = "method", arguments = null, isStatic = true, isReturned = false, dataTypeReturn = "string", lines = methodLines, line = 9
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "BaseClass"
                }, csArguments = argList, csLines = null
            });

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name = "UltimateTests";
            model.document.references       = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });

            String             Code     = ErrorAndExceptionsCatalog._715_Code;
            String             Message  = ErrorAndExceptionsCatalog._715__ValueIsNotReturnedInMethod;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            List <csLine> methodLines = new List <csLine>();

            methodLines.Add(new csLine()
            {
                line = 0, lineCode = "var x = 5;", executeMethods = null
            });

            List <csArgument> methodsArgs = new List <csArgument>();

            methodsArgs.Add(new csArgument()
            {
                type = "string", value = "Saludo"
            });
            methodsArgs.Add(new csArgument()
            {
                type = "int", value = "Año"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "modifier", modifier = "public", isStatic = true, line = 1, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "isStatic", modifier = "public", isStatic = true, line = 2, value = "", type = "bool", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "value", modifier = "public", isStatic = true, line = 3, value = "", type = "object", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "type", modifier = "public", isStatic = true, line = 4, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "getter", modifier = "public", isStatic = true, line = 5, value = "", type = "csGetter", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "setter", modifier = "public", isStatic = true, line = 6, value = "", type = "csSetter", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "methods", modifier = "public", isStatic = true, line = 7, value = "", type = "List<csExecuteMethods>", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csMethods()
            {
                name = "Testing", arguments = methodsArgs, isStatic = false, isReturned = false, dataTypeReturn = "void", lines = null, line = 8
            });
            variables.Add(new csMethods()
            {
                name = "AnotherTesting", arguments = null, isStatic = true, isReturned = true, dataTypeReturn = "string", lines = methodLines, line = 9
            });

            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });
            argList.Add(new csArgument()
            {
                type = "string", value = "Nombre"
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "Sample0"
                }, csArguments = argList, csLines = null
            });

            csXML xmlModel = new csXML("1.0", "UTF-8");

            xmlModel.document.references = new List <csReferences>();
            xmlModel.document.references.Add(new csReferences {
                name = "System;"
            });
            xmlModel.document.references.Add(new csReferences {
                name = "System.Collections.Generic;"
            });
            xmlModel.document.references.Add(new csReferences()
            {
                name = "System.Text;"
            });
            xmlModel.document.csNamespace = new csNamespace()
            {
                name = "Sensato.Translate.Entities"
            };
            xmlModel.document.csNamespace.Classes = new List <csClass>();
            xmlModel.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });
            string csObject = XMLToCSharp.TranslateToCSharp(xmlModel);
        }