Esempio n. 1
0
        public void ShouldGetNameForTypeElementInAssembly()
        {
            var typeElement = TypeMockUtils.MockTypeElement(
                "Full.Qualified.TypeName",
                TypeMockUtils.MockAssembly("AssemblyName", "0.9.8.7"));

            AssertName(typeElement, Names.Type("Full.Qualified.TypeName, AssemblyName, 0.9.8.7"));
        }
Esempio n. 2
0
        public void ShouldGetNameForVariableDeclaration()
        {
            var mockVariable = new Mock <ITypeOwner>();

            mockVariable.Setup(v => v.ShortName).Returns("variable");
            mockVariable.Setup(v => v.Type).Returns(TypeMockUtils.MockIType("Type", "Assembly", "1.2.3.4"));

            AssertName(mockVariable.Object, Names.LocalVariable("[Type, Assembly, 1.2.3.4] variable"));
        }
Esempio n. 3
0
        public void ShouldGetNameForEventDeclaration()
        {
            var mockEvent = new Mock <IEvent>();

            mockEvent.Setup(p => p.GetContainingType())
            .Returns(TypeMockUtils.MockTypeElement("DeclaringType", "DTA", "0.9.8.7"));
            mockEvent.Setup(p => p.Type).Returns(TypeMockUtils.MockIType("HandlerType", "HTA", "1.2.3.4"));
            mockEvent.Setup(p => p.ShortName).Returns("EventName");

            AssertName(
                mockEvent.Object,
                Names.Event("[HandlerType, HTA, 1.2.3.4] [DeclaringType, DTA, 0.9.8.7].EventName"));
        }
Esempio n. 4
0
        public void ShouldGetNameForIField()
        {
            var fieldMock = new Mock <IField>();

            fieldMock.Setup(f => f.GetContainingType())
            .Returns(TypeMockUtils.MockTypeElement("DeclaringType", "DTA", "0.9.8.7"));
            fieldMock.Setup(f => f.Type).Returns(TypeMockUtils.MockIType("ValueType", "VTA", "1.2.3.4"));
            fieldMock.Setup(f => f.ShortName).Returns("FieldName");

            AssertName(
                fieldMock.Object,
                Names.Field("[ValueType, VTA, 1.2.3.4] [DeclaringType, DTA, 0.9.8.7].FieldName"));
        }
Esempio n. 5
0
        public void ShouldGetNameForIFunction()
        {
            var functionMock = new Mock <IFunction>();

            functionMock.Setup(f => f.GetContainingType())
            .Returns(TypeMockUtils.MockTypeElement("DeclaringType", "DTA", "0.9.8.7"));
            functionMock.Setup(f => f.ReturnType).Returns(TypeMockUtils.MockIType("ReturnType", "RTA", "1.2.3.4"));
            functionMock.Setup(f => f.ShortName).Returns("MethodName");
            functionMock.Setup(f => f.Parameters).Returns(new List <IParameter>());

            AssertName(
                functionMock.Object,
                Names.Method("[ReturnType, RTA, 1.2.3.4] [DeclaringType, DTA, 0.9.8.7].MethodName()"));
        }
        private static ILookupItem MockLookupItem()
        {
            var lookupItem              = new Mock <IDeclaredElementLookupItem>();
            var typeName                = GetRandomName();
            var assemblyName            = GetRandomName();
            var declaredElementInstance =
                new DeclaredElementInstance(
                    TypeMockUtils.MockTypeElement(typeName, assemblyName, "1.2.3.4"),
                    new SubstitutionImpl());

            lookupItem.Setup(i => i.PreferredDeclaredElement).Returns(declaredElementInstance);
            lookupItem.Setup(i => i.DisplayName).Returns(new RichText(GetRandomName()));
            return(lookupItem.Object);
        }
Esempio n. 7
0
        public void ShouldGetNameForIMethodWithTypeParameters()
        {
            var method = new Mock <IMethod>();

            method.Setup(m => m.GetContainingType())
            .Returns(TypeMockUtils.MockTypeElement("DeclaringType", "DTA", "0.9.8.7"));
            method.Setup(m => m.ReturnType).Returns(TypeMockUtils.MockIType("ReturnType", "RTA", "1.2.3.4"));
            method.Setup(m => m.ShortName).Returns("MethodName");
            method.Setup(m => m.Parameters).Returns(new List <IParameter>());

            method.Setup(m => m.TypeParameters).Returns(new[] { MockTypeParameter("T"), MockTypeParameter("U") });

            AssertName(
                method.Object,
                Names.Method("[ReturnType, RTA, 1.2.3.4] [DeclaringType, DTA, 0.9.8.7].MethodName`2[[T],[U]]()"));
        }
Esempio n. 8
0
        public void ShouldGetNameForIProperty()
        {
            var propertyMock = new Mock <IProperty>();

            propertyMock.Setup(p => p.GetContainingType())
            .Returns(TypeMockUtils.MockTypeElement("DeclaringType", "DTA", "0.9.8.7"));
            propertyMock.Setup(p => p.ReturnType).Returns(TypeMockUtils.MockIType("ValueType", "VTA", "1.2.3.4"));
            propertyMock.Setup(p => p.ShortName).Returns("PropertyName");
            propertyMock.Setup(p => p.IsReadable).Returns(true);
            propertyMock.Setup(p => p.IsWritable).Returns(true);
            propertyMock.Setup(p => p.Parameters).Returns(new List <IParameter>());

            AssertName(
                propertyMock.Object,
                Names.Property("set get [ValueType, VTA, 1.2.3.4] [DeclaringType, DTA, 0.9.8.7].PropertyName()"));
        }
Esempio n. 9
0
        public void ShouldGetNameForITypeWithTwoTypeParameters()
        {
            var type = TypeMockUtils.MockIType(
                "System.Collections.IDictionary`2",
                new Dictionary <string, IType>
            {
                { "TKey", TypeMockUtils.MockIType("System.String", "mscore", "1.2.3.4") },
                { "TValue", TypeMockUtils.MockIType("System.Object", "mscore", "5.6.7.8") }
            },
                "mscore",
                "9.10.11.12");

            AssertNameIdentifier(
                type,
                "System.Collections.IDictionary`2[[TKey -> System.String, mscore, 1.2.3.4],[TValue -> System.Object, mscore, 5.6.7.8]], mscore, 9.10.11.12");
        }
Esempio n. 10
0
        public void ShouldGetNameForIParameter(string parameterName,
                                               string typeName,
                                               string assemblyName,
                                               string assemblyVersion,
                                               ParameterKind pKind,
                                               bool isOptional,
                                               bool isParameterArray,
                                               string identifier)
        {
            var paramMock = new Mock <IParameter>();

            paramMock.Setup(p => p.ShortName).Returns(parameterName);
            paramMock.Setup(p => p.Type).Returns(TypeMockUtils.MockIType(typeName, assemblyName, assemblyVersion));
            paramMock.Setup(p => p.Kind).Returns(pKind);
            paramMock.Setup(p => p.IsOptional).Returns(isOptional);
            paramMock.Setup(p => p.IsParameterArray).Returns(isParameterArray);

            AssertName(paramMock.Object, Names.Parameter(identifier));
        }
Esempio n. 11
0
        public void SouldGetQualifiedNameForTypeElementInProject()
        {
            var typeElement = TypeMockUtils.MockTypeElement("TypeName", TypeMockUtils.MockProject("Project"));

            AssertName(typeElement, Names.Type("TypeName, Project"));
        }
Esempio n. 12
0
        public void ShouldGetNameForIType(string typeFqn, string assemblyName, string assemblyVersion, string identifier)
        {
            var type = TypeMockUtils.MockIType(typeFqn, assemblyName, assemblyVersion);

            AssertNameIdentifier(type, identifier);
        }