Skip to content

Commit 91ae098

Browse files
authored
Merge pull request #17 from faddiv/TargetNetcoreapp3_0
Target netcoreapp2.1 and netcoreapp3.0
2 parents f818f7f + 2cdcb13 commit 91ae098

File tree

51 files changed

+698
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+698
-172
lines changed

.gitattributes

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto eol=crlf
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
*.cs text diff=csharp
14+
15+
###############################################################################
16+
# diff behavior for common document formats
17+
#
18+
# Convert binary document formats to text before diffing them. This feature
19+
# is only available from the command line. Turn it on by uncommenting the
20+
# entries below.
21+
###############################################################################
22+
*.doc diff=astextplain
23+
*.DOC diff=astextplain
24+
*.docx diff=astextplain
25+
*.DOCX diff=astextplain
26+
*.dot diff=astextplain
27+
*.DOT diff=astextplain
28+
*.pdf diff=astextplain
29+
*.PDF diff=astextplain
30+
*.rtf diff=astextplain
31+
*.RTF diff=astextplain

FluentAssertions.AspNetCore.Mvc.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A4C33565
1616
EndProject
1717
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.AspNetCore.Mvc", "src\FluentAssertions.AspNetCore.Mvc\FluentAssertions.AspNetCore.Mvc.csproj", "{EA71D220-089E-4CB1-B187-D9BB4DFD8624}"
1818
EndProject
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.AspNetCore.Mvc.Ref", "src\FluentAssertions.AspNetCore.Mvc.Ref\FluentAssertions.AspNetCore.Mvc.Ref.csproj", "{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}"
20+
EndProject
1921
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.AspNetCore.Mvc.Tests", "tests\FluentAssertions.AspNetCore.Mvc.Tests\FluentAssertions.AspNetCore.Mvc.Tests.csproj", "{A4962D4A-A99A-4F96-8F76-C5A2F1D06577}"
2022
EndProject
2123
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.AspNetCore.Mvc.Sample.Tests", "samples\FluentAssertions.AspNetCore.Mvc.Sample.Tests\FluentAssertions.AspNetCore.Mvc.Sample.Tests.csproj", "{BCFB2639-D0CC-4E81-B431-8CB37F66480F}"
@@ -44,6 +46,18 @@ Global
4446
{EA71D220-089E-4CB1-B187-D9BB4DFD8624}.Release|Mixed Platforms.Build.0 = Release|Any CPU
4547
{EA71D220-089E-4CB1-B187-D9BB4DFD8624}.Release|x86.ActiveCfg = Release|Any CPU
4648
{EA71D220-089E-4CB1-B187-D9BB4DFD8624}.Release|x86.Build.0 = Release|Any CPU
49+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
52+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
53+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|x86.ActiveCfg = Debug|Any CPU
54+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Debug|x86.Build.0 = Debug|Any CPU
55+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|Any CPU.Build.0 = Release|Any CPU
57+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
58+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
59+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|x86.ActiveCfg = Release|Any CPU
60+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF}.Release|x86.Build.0 = Release|Any CPU
4761
{A4962D4A-A99A-4F96-8F76-C5A2F1D06577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4862
{A4962D4A-A99A-4F96-8F76-C5A2F1D06577}.Debug|Any CPU.Build.0 = Debug|Any CPU
4963
{A4962D4A-A99A-4F96-8F76-C5A2F1D06577}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -86,6 +100,7 @@ Global
86100
EndGlobalSection
87101
GlobalSection(NestedProjects) = preSolution
88102
{EA71D220-089E-4CB1-B187-D9BB4DFD8624} = {89B09C65-4F1E-4B5A-AD58-E244113F2C02}
103+
{BA15EEA1-7305-42D3-A60E-3BDEC8CBECAF} = {89B09C65-4F1E-4B5A-AD58-E244113F2C02}
89104
{A4962D4A-A99A-4F96-8F76-C5A2F1D06577} = {A4C33565-1E6E-4AE7-8F02-1911DBA00263}
90105
{BCFB2639-D0CC-4E81-B431-8CB37F66480F} = {4E91D524-3DC0-4E08-82FE-6FDAEB89212B}
91106
{263F58EE-CF19-4974-AEBB-2A0E6C3F9054} = {4E91D524-3DC0-4E08-82FE-6FDAEB89212B}

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '{build}'
2-
image: Visual Studio 2017
2+
image: Visual Studio 2019
33
configuration: Release
44

55
before_build:

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"msbuild-sdks": {
3+
"MSBuild.Sdk.Extras": "2.0.54"
4+
}
5+
}

samples/FluentAssertions.AspNetCore.Mvc.Sample.Tests/ApiController_Tests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Net.Mime;
4-
using System.Security.Claims;
5-
using FluentAssertions.AspNetCore.Mvc.Sample.Controllers;
1+
using FluentAssertions.AspNetCore.Mvc.Sample.Controllers;
62
using Microsoft.AspNetCore.Authentication;
73
using Microsoft.AspNetCore.Mvc.ModelBinding;
8-
using Microsoft.AspNetCore.Routing;
9-
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
104
using Microsoft.Extensions.Primitives;
115
using Microsoft.Net.Http.Headers;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Security.Claims;
129
using Xunit;
1310

1411
namespace FluentAssertions.AspNetCore.Mvc.Sample.Tests

samples/FluentAssertions.AspNetCore.Mvc.Sample.Tests/FluentAssertions.AspNetCore.Mvc.Sample.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

samples/FluentAssertions.AspNetCore.Mvc.Sample.Tests/ProductController_Tests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using FluentAssertions.AspNetCore.Mvc.Sample.Controllers;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System;
24
using Xunit;
35

46
namespace FluentAssertions.AspNetCore.Mvc.Sample.Tests
@@ -13,5 +15,34 @@ public void List_ShouldReturnView()
1315
.BeViewResult()
1416
.WithViewName("Index");
1517
}
18+
19+
[Fact]
20+
public void GetActionResultOfT_OnFalse_Returns_Data()
21+
{
22+
var controller = new ProductController();
23+
var model = new Models.ProductViewModel { Id = 1, Name = "Text" };
24+
var returnError = false;
25+
26+
var result = controller.GetActionResultOfT(model, returnError);
27+
28+
result.Should().BeConvertibleTo<ObjectResult>()
29+
.And.Value.Should().BeSameAs(model);
30+
}
31+
32+
[Fact]
33+
public void GetActionResultOfT_OnTrue_Returns_BadRequest()
34+
{
35+
var controller = new ProductController();
36+
var model = new Models.ProductViewModel { Id = 1, Name = "Text" };
37+
var returnError = true;
38+
39+
var result = controller.GetActionResultOfT(model, returnError);
40+
41+
result.Should().BeConvertibleTo<BadRequestObjectResult>()
42+
.Which.Value.Should().BeSameAs(model);
43+
44+
result.Should().BeConvertibleTo<BadRequestObjectResult>()
45+
.Which.Should().BeBadRequestObjectResult();
46+
}
1647
}
1748
}

samples/FluentAssertions.AspNetCore.Mvc.Sample/Controllers/ProductController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using FluentAssertions.AspNetCore.Mvc.Sample.Models;
2+
using Microsoft.AspNetCore.Mvc;
23

34
namespace FluentAssertions.AspNetCore.Mvc.Sample.Controllers
45
{
@@ -9,5 +10,18 @@ public IActionResult List()
910
{
1011
return View("Index");
1112
}
13+
14+
#region ActionResult<T>
15+
[HttpGet]
16+
public ActionResult<ProductViewModel> GetActionResultOfT(
17+
ProductViewModel data, bool error)
18+
{
19+
if (error)
20+
{
21+
return BadRequest(data);
22+
}
23+
return data;
24+
}
25+
#endregion
1226
}
1327
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
55
</PropertyGroup>
66

7-
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
7+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
8+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" />
99
</ItemGroup>
1010

11+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
12+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
13+
</ItemGroup>
14+
1115
</Project>

samples/FluentAssertions.AspNetCore.Mvc.Sample/Startup.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore.Builder;
62
using Microsoft.AspNetCore.Hosting;
73
using Microsoft.Extensions.Configuration;
84
using Microsoft.Extensions.DependencyInjection;
@@ -28,24 +24,38 @@ public Startup(IHostingEnvironment env)
2824
public void ConfigureServices(IServiceCollection services)
2925
{
3026
// Add framework services.
31-
services.AddMvc();
27+
services.AddMvc(options =>
28+
{
29+
#if NETCOREAPP3_0
30+
options.EnableEndpointRouting = false;
31+
#endif
32+
});
33+
34+
services.AddLogging(configure =>
35+
{
36+
configure.AddConsole();
37+
configure.AddDebug();
38+
});
3239
}
3340

3441
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3542
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
3643
{
37-
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
38-
loggerFactory.AddDebug();
39-
4044
if (env.IsDevelopment())
4145
{
4246
app.UseDeveloperExceptionPage();
47+
#if NETCOREAPP2_1
4348
app.UseBrowserLink();
49+
#endif
4450
}
4551
else
4652
{
4753
app.UseExceptionHandler("/Home/Error");
4854
}
55+
#if NETCOREAPP2_1
56+
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
57+
loggerFactory.AddDebug();
58+
#endif
4959

5060
app.UseStaticFiles();
5161

0 commit comments

Comments
 (0)