public void TryFindProjectFileFromName(string name) { Assert.AreEqual(true, CodeFactory.TryFindProjectFile(name, out var projectFile)); Assert.AreEqual(name, projectFile.Name); projectFile = CodeFactory.FindProjectFile(name); Assert.AreEqual(name, projectFile.Name); }
public async Task Project() { var analyzer = new FieldNameMustNotBeginWithUnderscore(); var sln = CodeFactory.CreateSolution( CodeFactory.FindProjectFile("Gu.Roslyn.Asserts.csproj"), MetadataReferences.Transitive(typeof(Benchmark).Assembly).ToArray()); var benchmark = await Benchmark.CreateAsync(sln.Projects.Single(), analyzer).ConfigureAwait(false); CollectionAssert.IsNotEmpty(benchmark.SyntaxNodeActions); Assert.AreSame(analyzer, benchmark.Analyzer); benchmark.Run(); benchmark.Run(); }
public void SolutionFieldNameMustNotBeginWithUnderscoreDisabled(string fileName, string expected) { var sln = CodeFactory.CreateSolution(CodeFactory.FindProjectFile(fileName), new[] { new FieldNameMustNotBeginWithUnderscoreDisabled() }, AnalyzerAssert.MetadataReferences); var exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid <FieldNameMustNotBeginWithUnderscoreDisabled>(sln)); Assert.AreEqual(expected, exception.Message); exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid(typeof(FieldNameMustNotBeginWithUnderscoreDisabled), sln)); Assert.AreEqual(expected, exception.Message); exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid(new FieldNameMustNotBeginWithUnderscoreDisabled(), sln)); Assert.AreEqual(expected, exception.Message); if (Throw) { AnalyzerAssert.Valid <FieldNameMustNotBeginWithUnderscoreDisabled>(sln); } }
public void ProjectFileFieldNameMustNotBeginWithUnderscoreDisabled(string fileName, string expected) { var csproj = CodeFactory.FindProjectFile(fileName); var exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid <FieldNameMustNotBeginWithUnderscoreDisabled>(csproj)); Assert.AreEqual(expected, exception.Message); exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid(typeof(FieldNameMustNotBeginWithUnderscoreDisabled), csproj)); Assert.AreEqual(expected, exception.Message); exception = Assert.Throws <NUnit.Framework.AssertionException>(() => AnalyzerAssert.Valid(new FieldNameMustNotBeginWithUnderscoreDisabled(), csproj)); Assert.AreEqual(expected, exception.Message); if (Throw) { AnalyzerAssert.Valid <FieldNameMustNotBeginWithUnderscoreDisabled>(csproj); } }