public void RequestType( IMethodSymbol method, string requestClassName, int[] requestIndexes, string[] requestValueTypeName, string?headerClassName, int[] headerIndexes, string[]?headerValueTypeName) { var actual = new OperationDescription(method, "s1", ServiceContract.GetServiceOperationName(method)); actual.RequestType.ClassName.ShouldBe(requestClassName); actual.RequestType.Properties.ShouldBe(requestValueTypeName); actual.RequestTypeInput.ShouldBe(requestIndexes); if (headerClassName == null) { actual.HeaderRequestType.ShouldBeNull(); actual.HeaderRequestTypeInput.Length.ShouldBe(0); } else { actual.HeaderRequestType.ShouldNotBeNull(); actual.HeaderRequestType.ClassName.ShouldBe(headerClassName); actual.HeaderRequestTypeInput.ShouldBe(headerIndexes); actual.HeaderRequestType.Properties.ShouldBe(headerValueTypeName); } }
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 OperationDescription(IMethodSymbol method, string serviceName) { ServiceName = serviceName; Method = new MethodDescription(method); ValidateSignature(); OperationName = ServiceContract.GetServiceOperationName(method); (ResponseType, ResponseTypeIndex, HeaderResponseType, HeaderResponseTypeInput) = CreateResponseType(method.ReturnType); (RequestType, RequestTypeInput, HeaderRequestType, HeaderRequestTypeInput) = GetRequestType(); OperationType = GetOperationType(); ContextInput = GetContextInput(); IsAsync = SyntaxTools.IsTask(method.ReturnType); GrpcMethodName = "Method" + OperationName; GrpcMethodInputHeaderName = "MethodInputHeader" + OperationName; GrpcMethodOutputHeaderName = "MethodOutputHeader" + OperationName; }
public void ResponseType( IMethodSymbol method, string className, string?valueTypeName, string?headerClassName, int[]?headerIndexes, string[]?headerValueTypeName, int?streamIndex) { var actual = new OperationDescription(method, "s1", ServiceContract.GetServiceOperationName(method)); actual.ResponseType.ClassName.ShouldBe(className); if (valueTypeName == null) { actual.ResponseType.Properties.Length.ShouldBe(0); } else { actual.ResponseType.Properties.Length.ShouldBe(1); actual.ResponseType.Properties[0].ShouldBe(valueTypeName); } if (headerClassName == null) { actual.HeaderResponseType.ShouldBeNull(); actual.HeaderResponseTypeInput.ShouldBeEmpty(); actual.ResponseTypeIndex.ShouldBe(0); } else { actual.HeaderResponseType.ShouldNotBeNull(); actual.HeaderResponseType.ClassName.ShouldBe(headerClassName); actual.HeaderResponseType.Properties.ShouldBe(headerValueTypeName); actual.HeaderResponseTypeInput.ShouldBe(headerIndexes); actual.ResponseTypeIndex.ShouldBe(streamIndex !.Value); } }
public void OperationType(IMethodSymbol method, MethodType expectedType) { var actual = new OperationDescription(method, "s1", ServiceContract.GetServiceOperationName(method)); actual.OperationType.ShouldBe(expectedType); }
public void ContextInput(IMethodSymbol method, int[] indexes) { var actual = new OperationDescription(method, "s1", ServiceContract.GetServiceOperationName(method)); actual.ContextInput.ShouldBe(indexes); }