public void Resolve_CalledTwiceFirstCallResolvesTypeNameSecondCallDoesNotResolve_ReturnsNull() { string code = "a = Class1()"; PythonLocalVariableResolver resolver = CreateResolver(); resolver.Resolve("a", code); string typeName = resolver.Resolve("b", code); Assert.IsNull(typeName); }
public void Resolve_FieldHasNoReturnType_DoesNotThrowNullReferenceException() { MockProjectContent projectContent = new MockProjectContent(); UnitTestingUtils.MockClass c = new UnitTestingUtils.MockClass(projectContent, "Test"); projectContent.SetClassToReturnFromGetClass("self", c); DefaultField field = c.AddField("randomNumber"); field.ReturnType = null; ParseInformation parseInfo = new ParseInformation(c.CompilationUnit); ExpressionResult expression = new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default); PythonClassResolver classResolver = new PythonClassResolver(); PythonLocalVariableResolver localVariableResolver = new PythonLocalVariableResolver(classResolver); PythonMemberResolver resolver = new PythonMemberResolver(classResolver, localVariableResolver); PythonResolverContext context = new PythonResolverContext(parseInfo, expression, "class Test:\r\npass"); Assert.DoesNotThrow(delegate { resolver.Resolve(context); }); }
void Resolve(string variableName, string code) { PythonLocalVariableResolver resolver = CreateResolver(); typeName = resolver.Resolve(variableName, code); }