public void ShouldCallWriterWithGeneratedClassStatement()
        {
            // Given
            var projectAssembly = "ProjectAssembly";
            var sourceDirectory = "";
            var sourceFileName  = "MultipleGeneration.d.ts";
            var sourceFile      = Path.Combine(
                ".",
                "SourceFiles",
                sourceFileName
                );
            var sourceFiles = new List <string>
            {
                sourceFile
            };
            var generationList = new List <string>
            {
                "Vector3",
            };
            var typeOverrideMap = new Dictionary <string, string>();

            var writerMock = new Mock <IWriter>();

            // When
            var generateSource = new GenerateSource();
            var actual         = default(IList <GeneratedStatement>);

            writerMock.Setup(
                mock => mock.Write(
                    It.IsAny <IList <GeneratedStatement> >()
                    )
                ).Callback <IList <GeneratedStatement> >(
                (generatedStatement) =>
            {
                actual = generatedStatement;
            }
                );

            generateSource.Run(
                projectAssembly,
                sourceDirectory,
                sourceFiles,
                generationList,
                writerMock.Object,
                new NoFormattingTextFormatter(),
                typeOverrideMap
                );


            // Then
            actual.Should().NotBeNull();
            actual.Should().HaveCount(5);
        }
        public void ShouldGenerateSourceForEverythingDefinition()
        {
            // Given
            ReadInteropTemplates.SetReadTemplates();
            var projectAssembly = "ProjectAssembly";
            var sourceDirectory = "";
            var sourceFileName  = "MultipleGeneration.d.ts";
            var sourceFile      = Path.Combine(
                ".",
                "SourceFiles",
                sourceFileName
                );
            var sourceFiles = new List <string>
            {
                sourceFile
            };
            var generationList = new List <string>
            {
                "Mesh",
                "Mesh",
                "Engine",
                "Vector3",
            };
            var typeOverrideMap = new Dictionary <string, string>();

            var writerMock = new Mock <IWriter>();

            // When
            var generateSource = new GenerateSource();
            var actual         = generateSource.Run(
                projectAssembly,
                sourceDirectory,
                sourceFiles,
                generationList,
                writerMock.Object,
                new NoFormattingTextFormatter(),
                typeOverrideMap
                );


            // Then
            actual.Should().BeTrue();
        }
Beispiel #3
0
        public void ShouldGenerateSourceForEverythingDefinitionWhenUsingTheNodeJS_AST()
        {
            // Given
            var projectAssembly = "ProjectAssembly";
            var sourceDirectory = "";
            var sourceFileName  = "Everything.ts";
            var sourceFile      = Path.Combine(
                ".",
                "SourceFiles",
                sourceFileName
                );
            var sourceFiles = new List <string>
            {
                sourceFile
            };
            var generationList = new List <string>
            {
                "Everything",
            };
            var typeOverrideMap = new Dictionary <string, string>();

            var writerMock = new Mock <IWriter>();

            // When
            var generateSource = new GenerateSource();
            var actual         = generateSource.Run(
                projectAssembly,
                sourceDirectory,
                sourceFiles,
                generationList,
                writerMock.Object,
                new NoFormattingTextFormatter(),
                typeOverrideMap,
                ASTParserType.NodeJS
                );

            // Then
            actual.Should().BeTrue();
        }