Skip to content

Commit 431d430

Browse files
committed
Fix tests.
1 parent eb0ce84 commit 431d430

7 files changed

Lines changed: 12 additions & 15 deletions

File tree

AspNetCoreAnalyzers.Tests/ASP001ParameterNameTests/CodeFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
1+
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
22
{
33
using Gu.Roslyn.Asserts;
44
using Microsoft.CodeAnalysis.CodeFixes;

AspNetCoreAnalyzers.Tests/ASP001ParameterNameTests/Diagnostics.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
1+
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
22
{
33
using Gu.Roslyn.Asserts;
44
using Microsoft.CodeAnalysis.Diagnostics;
@@ -15,14 +15,13 @@ public static void BothParameters()
1515
var code = @"
1616
namespace AspBox
1717
{
18-
using System.Threading.Tasks;
1918
using Microsoft.AspNetCore.Mvc;
2019
2120
[ApiController]
2221
public class OrdersController : Controller
2322
{
2423
[HttpGet(""api/orders/{orderId}/items/{itemId}"")]
25-
public async Task<IActionResult> GetOrder↓(int wrong1, int wrong2)
24+
public IActionResult GetOrder↓(int wrong1, int wrong2)
2625
{
2726
return this.Ok(wrong1 * wrong2);
2827
}

AspNetCoreAnalyzers.Tests/ASP001ParameterNameTests/Valid.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
1+
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
22
{
33
using Gu.Roslyn.Asserts;
44
using Microsoft.CodeAnalysis;
@@ -68,9 +68,7 @@ public static void ImplicitFromRoute()
6868
var code = @"
6969
namespace AspBox
7070
{
71-
using System.Threading.Tasks;
7271
using Microsoft.AspNetCore.Mvc;
73-
using Microsoft.EntityFrameworkCore;
7472
7573
[ApiController]
7674
public class OrdersController : Controller
@@ -125,7 +123,7 @@ public class OrdersController : Controller
125123
[HttpGet(""api/orders/{id:int}"")]
126124
public IActionResult Get(int id)
127125
{
128-
if (id == null)
126+
if (id < 0)
129127
{
130128
return this.NotFound();
131129
}

AspNetCoreAnalyzers.Tests/ASP002RouteParameterNameTests/Valid.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP002RouteParameterNameTests
1+
namespace AspNetCoreAnalyzers.Tests.ASP002RouteParameterNameTests
22
{
33
using Gu.Roslyn.Asserts;
44
using Microsoft.CodeAnalysis.Diagnostics;
@@ -20,9 +20,7 @@ public static void WhenHttpGet(string after)
2020
var code = @"
2121
namespace AspBox
2222
{
23-
using System.Threading.Tasks;
2423
using Microsoft.AspNetCore.Mvc;
25-
using Microsoft.EntityFrameworkCore;
2624
2725
[ApiController]
2826
public class OrdersController : Controller

AspNetCoreAnalyzers.Tests/ASP003ParameterSymbolTypeTests/Valid.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,13 @@ public static void ExplicitType(string constraint, string type)
142142
var code = @"
143143
namespace AspBox
144144
{
145-
using System.Threading.Tasks;
146145
using Microsoft.AspNetCore.Mvc;
147-
using Microsoft.EntityFrameworkCore;
148146
149147
[ApiController]
150148
public class OrdersController : Controller
151149
{
152150
[HttpGet(""api/{value}"")]
153-
public async Task<int> GetOrder(int value)
151+
public int GetOrder(int value)
154152
{
155153
return value;
156154
}

AspNetCoreAnalyzers.Tests/AspNetCoreAnalyzers.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<PackageReference Include="Gu.Roslyn.Asserts.Analyzers" Version="4.0.0" PrivateAssets="all" />
2626
<PackageReference Include="IDisposableAnalyzers" Version="4.0.0" PrivateAssets="all" />
2727
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
28+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
2829
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
2930
<PackageReference Include="NUnit" Version="3.13.2" />
3031
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" PrivateAssets="all" />

AspNetCoreAnalyzers.Tests/ModuleInitializer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ internal static void Initialize()
1010
{
1111
Settings.Default = Settings.Default.WithMetadataReferences(
1212
MetadataReferences.Transitive(
13-
typeof(ModuleInitializer)));
13+
typeof(Microsoft.EntityFrameworkCore.DbContext),
14+
typeof(Microsoft.Extensions.Hosting.GenericHostBuilderExtensions),
15+
typeof(Microsoft.AspNetCore.Mvc.Controller),
16+
typeof(Microsoft.AspNetCore.Mvc.HttpGetAttribute)));
1417
}
1518
}
1619
}

0 commit comments

Comments
 (0)