public void CanAddConstantFromGuid()
        {
            var constantManager = new ConstantManager(new NamingRulesManager(), A.Fake <IDocumentationLinker>());
            var guid            = Guid.NewGuid();
            var macro           = new CppGuid
            {
                Name = "Macro",
                Guid = guid
            };
            var csTypeName   = "MyClass";
            var constantName = "Constant";

            constantManager.AddConstantFromMacroToCSharpType(new CppElementFinder(macro), "Macro", csTypeName, "int", constantName, "$1", null, "namespace");
            var csStructure = new CsStruct
            {
                Name = csTypeName
            };

            constantManager.AttachConstants(csStructure);

            Assert.Single(csStructure.Items);
            var variable = (CsVariable)csStructure.Items[0];

            Assert.Equal(guid.ToString(), variable.Value.ToString());
            Assert.Equal(constantName, variable.Name);
        }
Beispiel #2
0
    public void CanAddConstantFromCppConstant()
    {
        var value        = "1";
        var macro        = new CppConstant("Macro", "int", value);
        var csTypeName   = "MyClass";
        var constantName = "Constant";

        constantManager.AddConstantFromMacroToCSharpType(new CppElementFinder(macro), "Macro", csTypeName, "int", constantName, "$1", null, "namespace", false);
        var csStructure = new CsStruct(null, csTypeName);

        constantManager.AttachConstants(csStructure);

        Assert.Single(csStructure.Items);
        var variable = (CsExpressionConstant)csStructure.Items.First();

        Assert.Equal(value, variable.Value);
        Assert.Equal(constantName, variable.Name);
    }
        public void CanAddConstantFromCppConstant()
        {
            var constantManager = new ConstantManager(new NamingRulesManager(), A.Fake <IDocumentationLinker>());
            var value           = "1";
            var macro           = new CppConstant("Macro", value);
            var csTypeName      = "MyClass";
            var constantName    = "Constant";

            constantManager.AddConstantFromMacroToCSharpType(new CppElementFinder(macro), "Macro", csTypeName, "int", constantName, "$1", null, "namespace");
            var csStructure = new CsStruct(null, csTypeName);

            constantManager.AttachConstants(csStructure);

            Assert.Single(csStructure.Items);
            var variable = (CsVariable)csStructure.Items.First();

            Assert.Equal(value, variable.Value);
            Assert.Equal(constantName, variable.Name);
        }