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")); }
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")); }
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")); }
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")); }
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); }
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]]()")); }
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()")); }
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"); }
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)); }
public void SouldGetQualifiedNameForTypeElementInProject() { var typeElement = TypeMockUtils.MockTypeElement("TypeName", TypeMockUtils.MockProject("Project")); AssertName(typeElement, Names.Type("TypeName, Project")); }
public void ShouldGetNameForIType(string typeFqn, string assemblyName, string assemblyVersion, string identifier) { var type = TypeMockUtils.MockIType(typeFqn, assemblyName, assemblyVersion); AssertNameIdentifier(type, identifier); }