Beispiel #1
0
    public void TestGenerateInterface()
    {
        var gen          = new CodeUnitGenerator("TestCodeGen");
        var interfaceGen = new InterfaceGenerator("IMyInterface");
        var method       = new MethodGenerator("MyInterfaceMethod")
                           .AddParameter(new CodeTypeReference(typeof(bool)), "arg");

        interfaceGen.AddMember(method.Method);
        gen.AddType(interfaceGen);
        var ccu = gen.GenerateCompileUnit();

        var output = StringCompiler.CompileToString(ccu);

        Debug.Log(output);
        Assert.IsTrue(output.Contains("interface IMyInterface"));
        Assert.IsTrue(output.Contains("void MyInterfaceMethod(bool arg);"));
    }