private void AddMethodTestAct(BaseMethodInfo methodInfo)
        {
            if (methodInfo.ReturnTypeName != "void")
            {
                AppendFormat("{0} actual = ", methodInfo.ReturnTypeName);
                AppendNoIndent(_testObjectVarName + "." + methodInfo.Name + "(");
            }
            else
            {
                AppendFormat("{0}", _testObjectVarName + "." + methodInfo.Name + "(");
            }

            var paramPairs = methodInfo.ParamTypeNamesByParamName;

            for (var i = 0; i < paramPairs.Count - 1; i++)
            {
                AppendNoIndent(paramPairs[i].Key + ", ");
            }

            if (paramPairs.Count > 0)
            {
                AppendNoIndent(paramPairs[paramPairs.Count - 1].Key);
            }

            AppendNoIndent(");\n");

            AppendLine();
        }
Ejemplo n.º 2
0
        //QUESTION: [MethodImpl(MethodImplOptions.AggressiveInlining)] is evil?
        private void AddMethodTestAct(BaseMethodInfo mi)
        {
            if (mi.ReturnTypeName != "void")
            {
                AppendFormat("{0} actual = ", mi.ReturnTypeName);
                AppendNoIndent(TestObjectVarName + "." + mi.Name + "(");
            }
            else
            {
                AppendFormat("{0}", TestObjectVarName + "." + mi.Name + "(");
            }

            List <KeyValuePair <string, string> > paramPairs = mi.ParamTypeNamesByParamName;

            for (int i = 0; i < paramPairs.Count - 1; i++)
            {
                AppendNoIndent(paramPairs[i].Key + ", ");
            }
            if (paramPairs.Count > 0)
            {
                AppendNoIndent(paramPairs[paramPairs.Count - 1].Key);
            }
            AppendNoIndent(");\n");

            AppendLine();
        }
Ejemplo n.º 3
0
        private void AddMethodTest(BaseMethodInfo mi)
        {
            AppendLine("[Test]");
            AppendFormat("public void {0}Test()\n", mi.Name);

            AppendLine("{");
            AddMethodTestArrange(mi);
            AddMethodTestAct(mi);
            AddMethodTestAssert(mi);
            AppendLine("}");

            AppendLine();
        }
Ejemplo n.º 4
0
        private void AddMethodTestAssert(BaseMethodInfo mi)
        {
            if (mi.ReturnTypeName != "void")
            {
                string      fullTypeName = mi.ReturnTypeName.GetFullTypeName();
                System.Type type         = System.Type.GetType(fullTypeName);
                object      defaultValue = type?.GetDefault();

                AppendFormat("{0} expected = {1};\n", mi.ReturnTypeName, defaultValue);
                AppendLine("Assert.That(actual, Is.EqualTo(expected));");
            }

            AppendLine("Assert.Fail(\"autogenerated\");");
        }
Ejemplo n.º 5
0
 private void AddMethodTestArrange(BaseMethodInfo mi)
 {
     foreach (var kvp in mi.ParamTypeNamesByParamName)
     {
         string      fullTypeName = kvp.Value.GetFullTypeName();
         System.Type type         = System.Type.GetType(fullTypeName);
         object      defaultValue = type?.GetDefault();
         AppendFormat("{0} {1} = {2};\n",
                      kvp.Value,
                      kvp.Key,
                      defaultValue ?? "null");
     }
     AppendLine();
 }
        private void AddMethodTestAssert(BaseMethodInfo methodInfo)
        {
            if (methodInfo.ReturnTypeName != "void")
            {
                var fullTypeName = StringUtil.GetFullTypeName(methodInfo.ReturnTypeName);
                var type         = Type.GetType(fullTypeName);
                var defaultValue = TypeUtil.GetDefault(type);

                AppendFormat("{0} expected = {1};\n", methodInfo.ReturnTypeName, defaultValue);
                AppendLine("Assert.That(actual, Is.EqualTo(expected));");
            }

            AppendLine("Assert.Fail(\"autogenerated\");");
        }
        private void AddMethodTestArrange(BaseMethodInfo methodInfo)
        {
            foreach (var(key, value) in methodInfo.ParamTypeNamesByParamName)
            {
                var fullTypeName = StringUtil.GetFullTypeName(value);
                var type         = Type.GetType(fullTypeName);
                var defaultValue = TypeUtil.GetDefault(type);

                AppendFormat("{0} {1} = {2};\n",
                             value,
                             key,
                             defaultValue ?? "null");
            }

            AppendLine();
        }
Ejemplo n.º 8
0
 private void AddMethodTestBody(BaseMethodInfo mi)
 {
 }