public void ShouldReturnExpectedIdentificationOfInterfaceWhenCalledMultipleTimesWithSdcb() { // Given var interfaceIdentifierString = "ExampleInterface"; var sourceFile = "interface.ts"; var source = File.ReadAllText($"./SourceFiles/{sourceFile}"); var ast = new Sdcb_TypeScriptASTWrapper(source); // When var cachedInterfaceIdentifier = new InterfaceResponseTypeIdentifierCached(); // First Identify cachedInterfaceIdentifier.Identify( interfaceIdentifierString, ast ).Should() // Then .BeTrue(); // Second Identify cachedInterfaceIdentifier.Identify( interfaceIdentifierString, ast ).Should() // Then .BeTrue(); }
public void ShouldValidateAgainstCacheWhenDeclarationTypeIsUsed( string declarationType, bool found ) { // Given var expected = 1; var identifierString = "identifier-string"; var mockNode = new NodeMock { IdentifierStr = identifierString, }; var astMock = new Mock <AbstractSyntaxTree>(); var rootNodeMock = new Mock <Node>(); astMock.Setup( mock => mock.RootNode ).Returns( rootNodeMock.Object ); rootNodeMock.Setup( mock => mock.OfKind( declarationType ) ).Returns( new List <Node> { mockNode } ); // When var alias = new InterfaceResponseTypeIdentifierCached(); var actual = alias.Identify( identifierString, astMock.Object ); actual.Should().Be(found); actual = alias.Identify( identifierString, astMock.Object ); // Then actual.Should().Be(found); rootNodeMock.Verify( mock => mock.OfKind( declarationType ), Times.Exactly(expected) ); }
public void ShouldReturnExpectedIdentificationOfInterfaceWhenUsingCachedInstanceWithSdcb() { // Given var expected = true; var interfaceIdentifierString = "ExampleInterface"; var sourceFile = "interface.ts"; var source = File.ReadAllText($"./SourceFiles/{sourceFile}"); var ast = new Sdcb_TypeScriptASTWrapper(source); // When var cachedInterfaceIdentifier = new InterfaceResponseTypeIdentifierCached(); var actual = cachedInterfaceIdentifier.Identify( interfaceIdentifierString, ast ); // Then actual.Should() .Be(expected); }
public void ShouldReturnExpectedIdentificationWhenTypeStatementIsUsedWithNodeJS( string typeName, string genericName, bool isModifier, bool isArray, bool isNullable, bool expected ) { // Given var type = new TypeStatement { Name = typeName, IsModifier = isModifier, IsArray = isArray, IsNullable = isNullable, GenericTypes = new List <TypeStatement> { new TypeStatement { Name = genericName } } }; var sourceFile = "interface.ts"; var source = File.ReadAllText($"./SourceFiles/{sourceFile}"); var ast = new NodeJS_ASTWrapper(source); // When var cachedInterfaceIdentifier = new InterfaceResponseTypeIdentifierCached(); var actual = cachedInterfaceIdentifier.Identify( type, ast ); // Then actual.Should() .Be(expected); }