-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
1,764 additions
and
980 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
NetFabric.CSharp.UnitTests/CodeAnalysis/ITypeSymbolExtensionsTests.IsAsyncEnumerator.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
NetFabric.CSharp.UnitTests/CodeAnalysis/ITypeSymbolExtensionsTests.IsEnumerator.cs
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
NetFabric.CSharp.UnitTests/CodeAnalysis/ITypeSymbolExtensionsTests.IsIndexable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using NetFabric.CSharp.TestData; | ||
using System; | ||
using Xunit; | ||
|
||
namespace NetFabric.CodeAnalysis.CSharp.UnitTests; | ||
|
||
public partial class ITypeSymbolExtensionsTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(IndexableDataSets.Arrays), MemberType = typeof(IndexableDataSets))] | ||
[MemberData(nameof(IndexableDataSets.Indexables), MemberType = typeof(IndexableDataSets))] | ||
public void IsIndexable_Should_ReturnTrue(Type enumerableType, IndexableDataSets.IndexableTestData testData) | ||
{ | ||
// Arrange | ||
var compilation = Utils.Compile( | ||
@"TestData/Indexables.cs" | ||
); | ||
var typeSymbol = compilation.GetTypeSymbol(enumerableType); | ||
|
||
// Act | ||
var result = typeSymbol.IsIndexable(out var indexableSymbols, out var error); | ||
|
||
// Assert | ||
Assert.True(result, error.ToString()); | ||
Assert.NotNull(indexableSymbols); | ||
Assert.Equal(IsIndexableError.None, error); | ||
|
||
//var indexer = indexableSymbols!.Indexer; | ||
//Assert.NotNull(indexer); | ||
//Assert.Equal(NameOf.Indexer, indexer.Name); | ||
//Assert.Equal(testData.IndexerDeclaringType.Name, indexer.ContainingType.MetadataName); | ||
|
||
//var countOrLength = indexableSymbols!.CountOrLength; | ||
//Assert.NotNull(countOrLength); | ||
//Assert.True(countOrLength.Name == NameOf.Count || countOrLength.Name == NameOf.Length); | ||
//Assert.Equal(testData.CountOrLengthDeclaringType.Name, countOrLength.ContainingType.MetadataName); | ||
|
||
var countOrLength = indexableSymbols!.CountOrLength; | ||
Assert.NotNull(countOrLength); | ||
Assert.True(countOrLength.Name == NameOf.Count || countOrLength.Name == NameOf.Length); | ||
|
||
var indexer = indexableSymbols!.Indexer; | ||
|
||
if (enumerableType.IsArray) | ||
{ | ||
var arrayType = compilation.GetTypeSymbol(typeof(Array)); | ||
Assert.Equal(arrayType, countOrLength.ContainingType); | ||
|
||
Assert.Null(indexer); | ||
} | ||
else | ||
{ | ||
Assert.Equal(testData.CountOrLengthDeclaringType.Name, countOrLength.ContainingType.MetadataName); | ||
|
||
Assert.NotNull(indexer); | ||
Assert.Equal(NameOf.Indexer, indexer.Name); | ||
Assert.Equal(testData.IndexerDeclaringType.Name, indexer.ContainingType.MetadataName); | ||
} | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(IndexableDataSets.InvalidIndexables), MemberType = typeof(IndexableDataSets))] | ||
public void IsIndexable_With_MissingFeatures_Should_ReturnFalse(Type enumerableType, IsIndexableError expectedError) | ||
{ | ||
// Arrange | ||
var compilation = Utils.Compile( | ||
@"TestData/Indexables.cs" | ||
); | ||
var typeSymbol = compilation.GetTypeSymbol(enumerableType); | ||
|
||
// Act | ||
var result = typeSymbol.IsIndexable(out _, out var error); | ||
|
||
// Assert | ||
Assert.False(result); | ||
Assert.Equal(expectedError, error); | ||
} | ||
} |
Oops, something went wrong.