public void GetInterfaceImplementation() { var i1Symbol = Compilation.GetTypeByMetadataName(typeof(I1)); foreach (var method in SyntaxTools.GetInstanceMethods(i1Symbol)) { i1Symbol.GetInterfaceImplementation(method).ShouldNotBeNull(); } }
public void GetServiceOperationName(Type type, string methodName, string expected) { var symbol = _compilation.GetTypeByMetadataName(type); symbol.ShouldNotBeNull(); var method = SyntaxTools.GetInstanceMethods(symbol).First(i => i.Name == methodName); ServiceContract.GetServiceOperationName(method).ShouldBe(expected); }
public void GetInstanceMethods() { var i1Symbol = Compilation.GetTypeByMetadataName(typeof(I1)); i1Symbol.ShouldNotBeNull(); var methods = SyntaxTools.GetInstanceMethods(i1Symbol).ToList(); methods.Count.ShouldBe(2); }
private static IEnumerable <TestCaseData> GetFullNameCases() { var type = Compilation.GetTypeByMetadataName(typeof(FullNameCases)); type.ShouldNotBeNull(); foreach (var method in SyntaxTools.GetInstanceMethods(type)) { var attribute = SyntaxTools.GetCustomAttribute(method, typeof(DisplayNameAttribute).FullName !); var expected = (string)attribute !.ConstructorArguments[0].Value !; expected.ShouldNotBeNull(); yield return(new TestCaseData(method.ReturnType, expected) { TestName = "FullName." + method.Name }); } }
private static IEnumerable <TestCaseData> GetResponseTypeCases() { var type = Compilation.GetTypeByMetadataName(typeof(ResponseTypeCases)); type.ShouldNotBeNull(); foreach (var method in SyntaxTools.GetInstanceMethods(type)) { var response = method.GetAttributes().First(i => i.AttributeClass !.Name == nameof(ResponseTypeAttribute)); var responseHeader = method.GetAttributes().FirstOrDefault(i => i.AttributeClass !.Name == nameof(HeaderResponseTypeAttribute)); yield return(new TestCaseData( method, response.ConstructorArguments[0].Value, response.ConstructorArguments[1].Value, responseHeader?.ConstructorArguments[0].Value, responseHeader?.ConstructorArguments[1].Values.Select(i => (int)i.Value !).ToArray(), responseHeader?.ConstructorArguments[2].Values.Select(i => (string)i.Value !).ToArray(), responseHeader?.ConstructorArguments[3].Value) { TestName = "ResponseType." + method.Name });