public void ValidateGenerateStrings(
            string path,
            string sourceFile,
            string expectedFile,
            string classIdentifier = "ExampleClass"
            )
        {
            // Given
            ReadInteropTemplates.SetReadTemplates();
            GenerateSource.DisableCache();
            var sourcePath = Path.Combine(
                ".",
                "GenerateClassStatementStringTests",
                path
                );
            string expected = File.ReadAllText(Path.Combine(
                                                   sourcePath,
                                                   expectedFile
                                                   ));
            var source = File.ReadAllText(Path.Combine(
                                              sourcePath,
                                              sourceFile
                                              ));
            var ast = new TypeScriptAST(
                source,
                sourceFile
                );
            var typeOverrideMap = new Dictionary <string, string>();

            // When
            var generated = GenerateInteropClassStatement.Generate(
                "ProjectAssembly",
                classIdentifier,
                ast,
                typeOverrideMap
                );
            var actual = GenerateClassStatementString.Generate(
                generated,
                new NoFormattingTextFormatter()
                );

            // Then
            actual.Should().Be(
                expected
                );
        }
예제 #2
0
        public void ValidateGenerateWithTypeOverrideStrings(
            string path,
            string sourceFile,
            IDictionary <string, string> typeOverrideMap,
            string expectedFile,
            ASTParserType parserType = ASTParserType.Sdcb
            )
        {
            // Given
            GenerateSource.DisableCache();
            var sourcePath = Path.Combine(
                ".",
                "GenerateClassStatementStringTests",
                path
                );
            string expected = File.ReadAllText(Path.Combine(
                                                   sourcePath,
                                                   expectedFile
                                                   ));
            var source = File.ReadAllText(Path.Combine(
                                              sourcePath,
                                              sourceFile
                                              ));
            var ast = CreateParser(
                parserType,
                source
                );

            // When
            var generated = GenerateInteropClassStatement.Generate(
                "ProjectAssembly",
                "ExampleClass",
                ast,
                typeOverrideMap
                );
            var actual = GenerateClassStatementString.Generate(
                generated,
                new NoFormattingTextFormatter()
                );

            // Then
            actual.Should().Be(
                expected
                );
        }