コード例 #1
0
    static void generates <T>(string expectedFileName = null)
    {
        var entitasDir  = new DirectoryInfo(Directory.GetCurrentDirectory());
        var fixturesDir = entitasDir + "/Tests/Tests/Entitas/CodeGenerator/Fixtures/Generated/";

        expectedFileName = (expectedFileName ?? typeof(T).FullName) + "GeneratedExtension";
        var path = fixturesDir + expectedFileName + ".cs";

        var expectedFileContent = File.ReadAllText(path);
        var info = TypeReflectionProvider.GetComponentInfos(typeof(T)).Single();

        var codeGenFiles = new ComponentExtensionsGenerator().Generate(new [] { info });

        codeGenFiles.Length.should_be(1);
        var codeGenFile = codeGenFiles.Single();

        #pragma warning disable
        if (logResults)
        {
            Console.WriteLine("should:\n" + expectedFileContent);
            Console.WriteLine("was:\n" + codeGenFile.fileContent);
        }

        codeGenFile.fileName.should_be(expectedFileName);
        codeGenFile.fileContent.should_be(expectedFileContent);
    }
コード例 #2
0
    static void generates <T>(string expectedFileName = null)
    {
        var projectRoot = TestExtensions.GetProjectRoot();
        var fixturesDir = projectRoot + "/Tests/Tests/Entitas/CodeGenerator/Fixtures/Generated/";

        expectedFileName = (expectedFileName ?? typeof(T).FullName) + "GeneratedExtension";
        var path = fixturesDir + expectedFileName + ".cs";

        var expectedFileContent = File.ReadAllText(path);
        var info = TypeReflectionProvider.GetComponentInfos(typeof(T)).Single();

        var codeGenFiles = new ComponentExtensionsGenerator().Generate(new [] { info });

        codeGenFiles.Length.should_be(1);
        var codeGenFile = codeGenFiles.Single();

        #pragma warning disable
        if (logResults)
        {
            Console.WriteLine("should:\n" + expectedFileContent);
            Console.WriteLine("was:\n" + codeGenFile.fileContent);
        }

        codeGenFile.fileName.should_be(expectedFileName);
        var header = string.Format(CodeGenerator.AUTO_GENERATED_HEADER_FORMAT, typeof(ComponentExtensionsGenerator));
        (header + codeGenFile.fileContent).should_be(expectedFileContent);
    }