-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Analyzer for finding index candidates, listing configured indices
- Loading branch information
Showing
25 changed files
with
651 additions
and
72 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
75 changes: 75 additions & 0 deletions
75
src/Marten.AnalyzerTool.Tests/Analyzers/IndexCandidateAnalyserTests.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,75 @@ | ||
using System.Linq; | ||
using Marten.AnalyzerTool.Analyzers; | ||
using Marten.AnalyzerTool.Tests.Infrastructure; | ||
using Xunit; | ||
|
||
namespace Marten.AnalyzerTool.Tests.Analyzers | ||
{ | ||
public sealed class IndexCandidateAnalyserTests | ||
{ | ||
[Fact] | ||
public async void CanIdentifyIndexCandidates() | ||
{ | ||
var analyzer = new IndexCandidateAnalyser(); | ||
await TestHelper.GetDiagnosticsAsync(analyzer, | ||
@"using System; | ||
using System.Linq; | ||
using Marten; | ||
using Marten.Schema; | ||
class TestClass | ||
{ | ||
void TestMethod() | ||
{ | ||
var store = DocumentStore.For(c => | ||
{ | ||
c.Schema.For<Item>().Index(x => x.AnotherMember); | ||
c.Schema.For<Item2>().GinIndexJsonData(); | ||
}); | ||
var item = new Item(); | ||
using (var s = store.OpenSession()) | ||
{ | ||
s.Query<Item>().Where(x => x.SomeMember == """") | ||
.Where(x => x.ThirdMember == """"); | ||
//s.Query<Item>().Where(x => x.Id > 0).First(); | ||
//s.Query<Item>().Where(x => x.SomeMember == """" && x.ThirdMember == item.ThirdMember).Where(x => x.SomeMember == ""abc"").First(); | ||
//s.Query<Item>().Where(x => x.SomeMember == """").First(); | ||
//s.Query<Item>().Where(x => x.SomeMember == """").First(); | ||
//s.Query<Item>().Where(x => x.AnotherMember == """").First(); | ||
//s.Query<Item>().Where(x => x.AnotherMember == """").First(); | ||
//s.Query<Item>().Where(x => x.AnotherMember == """").First(); | ||
//s.Query<Item2>().Where(x => x.SomeMember == """").First(); | ||
//s.Query<Item2>().Where(x => x.SomeMember == """").First(); | ||
//s.Query<Item2>().Where(x => x.SomeMember == """").First(); | ||
//s.Query<Item2>().Where(x => x.Identity == 0).First(); | ||
} | ||
} | ||
public sealed class Item | ||
{ | ||
public int Id { get; set; } | ||
public string SomeMember { get; set; } | ||
public string AnotherMember { get; set; } | ||
public string ThirdMember { get; set; } | ||
} | ||
public sealed class Item2 | ||
{ | ||
[Identity] | ||
public int Identity { get; set; } | ||
public string SomeMember { get; set; } | ||
} | ||
}"); | ||
|
||
var indices = analyzer.GetIndices().Select(x => x.ToString()).ToArray(); | ||
var candidates = analyzer.GetIndexCandidates().Select(x => x.Property.ToDisplayString()).ToArray(); | ||
|
||
Assert.Contains("TestClass.Item.AnotherMember", indices); | ||
Assert.Contains("TestClass.Item.SomeMember", candidates); | ||
Assert.DoesNotContain("TestClass.Item.AnotherMember", candidates); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.