public string GetInstantiation(Type type, bool interestingValue)
        {
            var dictTypes = GetDictionaryType(type);

            var keyTypeName   = m_RootHandler.GetNameForCSharp(dictTypes.key);
            var valueTypeName = m_RootHandler.GetNameForCSharp(dictTypes.value);

            var keyTypeValue   = m_RootHandler.GetInstantiation(dictTypes.key, true);
            var valueTypeValue = m_RootHandler.GetInstantiation(dictTypes.value, true);

            var invocationSuffix = interestingValue
                ? $"{{ {{ {keyTypeValue} , {valueTypeValue} }} }}"
                : "()";

            m_RootHandler.GetNamespaceTracker().RecordNamespace("System.Collections.Generic");

            return($"new Dictionary<{keyTypeName},{valueTypeName}>{invocationSuffix}");
        }
Ejemplo n.º 2
0
        public string GetInstantiation(Type type, bool interestingValue)
        {
            if (type == typeof(byte[]))
            {
                if (interestingValue)
                {
                    m_RootHandler.GetNamespaceTracker().RecordNamespace("System.Text");
                    return("Encoding.UTF8.GetBytes(\"{}\")");
                }
                return("new byte[0]");
            }
            if (type == typeof(Type[]))
            {
                return(interestingValue ? "new Type[] { typeof(string) }" : "Type.EmptyTypes");
            }

            var eType = GetArrayElementType(type);

            return(!interestingValue
                ? $"new {m_RootHandler.GetNameForCSharp(eType)}[0]"
                : $"new {m_RootHandler.GetNameForCSharp(eType)}[] {{ {m_RootHandler.GetInstantiation(eType, true)} }}");
        }
 public string GetInstantiation(Type type, bool interestingValue)
 {
     m_RootHandler.GetNamespaceTracker().RecordNamespace("Rhino.Mocks");
     m_RootHandler.GetNamespaceTracker().RecordNamespace("static Rhino.Mocks.MockRepository");
     return($"GenerateStub<{m_RootHandler.GetNameForCSharp(type)}>()");
 }
Ejemplo n.º 4
0
 public INamespaceTracker GetNamespaceTracker()
 {
     return(m_InnerTypeHandler.GetNamespaceTracker());
 }
Ejemplo n.º 5
0
 public INamespaceTracker GetNamespaceTracker()
 {
     return(m_RootHandler.GetNamespaceTracker());
 }
Ejemplo n.º 6
0
 public string GetMockInstance(Type interfaceType)
 {
     m_TypeHandler.GetNamespaceTracker().RecordNamespace("Rhino.Mocks");
     m_TypeHandler.GetNamespaceTracker().RecordNamespace("static Rhino.Mocks.MockRepository");
     return($"GenerateMock<{GetNameForCSharp(interfaceType)}>()");
 }