Пример #1
0
        public void PrintPrimitives(TextWriter w)
        {
            foreach (Type t in this.plansByType.Keys)
            {
                if (!t.IsPrimitive && !t.Equals(typeof(string)))
                {
                    continue;
                }

                w.WriteLine("========== " + t.ToString());
                int count = 0;
                foreach (Plan p in this.plansByType[t])
                {
                    PrimitiveValueTransformer tr = p.transformer as PrimitiveValueTransformer;
                    Util.Assert(t != null);
                    if (count > 0)
                    {
                        w.Write(", ");
                    }
                    w.Write(tr.fvalue);
                    count++;
                }
                w.WriteLine();
            }
        }
Пример #2
0
        public static PrimitiveValueTransformer Get(Type type, object value)
        {
            //if (ReflectionUtils.IsStaticClass(type))
            //{
            //    throw new ArgumentException("Type is static class: " + type.ToString());
            //}

            TypeValuePair p = new TypeValuePair(type, value);
            PrimitiveValueTransformer t;
            cachedTransformers.TryGetValue(p, out t);
            if (t == null)
                cachedTransformers[p] = t = new PrimitiveValueTransformer(type, value);

            return t;
        }
Пример #3
0
        public static PrimitiveValueTransformer Get(Type type, object value)
        {
            //if (ReflectionUtils.IsStaticClass(type))
            //{
            //    throw new ArgumentException("Type is static class: " + type.ToString());
            //}

            TypeValuePair             p = new TypeValuePair(type, value);
            PrimitiveValueTransformer t;

            cachedTransformers.TryGetValue(p, out t);
            if (t == null)
            {
                cachedTransformers[p] = t = new PrimitiveValueTransformer(type, value);
            }

            return(t);
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            PrimitiveValueTransformer p = obj as PrimitiveValueTransformer;

            if (p == null)
            {
                return(false);
            }
            if (!this.ftype.Equals(p.ftype))
            {
                return(false);
            }
            if (fvalue == null)
            {
                if (p.fvalue == null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    return(fvalue.Equals(p.fvalue));
                }
                catch (Exception)
                {
                    // Execution of code under test led to an exception.
                    return(false);
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Creates a plan that represents a constant value.
 /// </summary>
 /// <param name="t"></param>
 /// <param name="constantValue"></param>
 /// <returns></returns>
 public static Plan Constant(Type t, object constantValue)
 {
     return(new Plan(PrimitiveValueTransformer.Get(t, constantValue), new Plan[0], new ParameterChooser[0]));
 }