Ejemplo n.º 1
0
        private static object SetValue(object val)
        {
            if (val == null)
            {
                return(null);
            }

            if (val is string)
            {
                val = "'" + val + "'";
            }
            else if (val.GetType().Get() == null)
            {
                val = SerializeUtility.Serialize(val);
            }

            if (val is char)
            {
                val = "'" + val + "'";
            }

            if (val is bool)
            {
                val = val.ToString().ToLower();
            }

            if (!val.GetType().IsArray)
            {
                return(val);
            }

            var builder = new StringBuilder();

            builder.Append("{");
            dynamic array = val;

            for (var index = 0; index < array.Length; index++)
            {
                builder.Append(array[0] is string?
                               "'" + array[0] + "'" :
                               array[0]);
                if (index < array.Length - 1)
                {
                    builder.Append(",");
                }
            }

            builder.Append("}");
            val = builder.ToString();

            return(val);
        }
Ejemplo n.º 2
0
 internal static void SetTestActualOutput <T>(this ExpressionTest <T> expressionTest, object[] expressionValues)
 {
     for (var i = 0; i < expressionValues.Length; i++)
     {
         try
         {
             if (
                 SerializeUtility.Serialize(expressionTest.ExpectedOutputs[i])
                 .Equals(SerializeUtility.Serialize(Enum.Enum.Instance.NotNull)) &&
                 expressionValues[i] != null)
             {
                 expressionTest.ActualOutputs[i] = Enum.Enum.Instance.NotNull;
             }
             else if (
                 SerializeUtility.Serialize(expressionTest.ExpectedOutputs[i])
                 .Equals(SerializeUtility.Serialize(Enum.Enum.Instance.Null)) && expressionValues[i] == null)
             {
                 expressionTest.ActualOutputs[i] = Enum.Enum.Instance.Null;
             }
             else if (expressionValues[i] != null && expressionValues[i] is Type)
             {
                 expressionTest.ActualOutputs[i] = ((Type)expressionValues[i]).FullName;
             }
             else
             {
                 expressionTest.ActualOutputs[i] = expressionValues[i];
             }
         }
         catch (Exception e)
         {
             if (e.InnerException != null)
             {
                 expressionTest.ActualOutputs[i] = e.InnerException.GetType().FullName;
             }
             else
             {
                 expressionTest.ActualOutputs[i] = e.GetType().FullName;
             }
         }
     }
 }