public void can_reject_not_allowed_type_in_local_variable() { var sut = new EthSharpAllowedTypesVisitor(new HashSet <string> { typeof(string).Name }); var tree = CSharpSyntaxTree.ParseText(@" using EthSharp.ContractDevelopment; public class SimpleTest : Contract { public String Test2(String parameter) { UInt256 x; return Test() + 1; } private String Test() { return 1; } }"); Assert.Throws <Exception>(() => sut.Visit(tree.GetRoot())); }
public void can_use_allowed_types() { var sut = new EthSharpAllowedTypesVisitor(new HashSet <string> { typeof(String).Name }); var tree = CSharpSyntaxTree.ParseText(@" using EthSharp.ContractDevelopment; public class SimpleTest : Contract { private String y {get; set;} private String z; public String Test2(String parameter) { String x; return Test() + 1; } private String Test() { return 1; } }"); sut.Visit(tree.GetRoot()); }