Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET 8 support; Fix tests #97

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/dotnet-core-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal

7 changes: 3 additions & 4 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: .NET 6 & 7
name: .NET 6, 7 & 8

on:
push:
Expand All @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
Expand All @@ -23,11 +23,10 @@ jobs:
- name: Build solution and generate NuGet package
run: |
cd src\DotNetEd.CoreAdmin
dotnet pack -c Release -o out
dotnet pack -c Release -o out
- name: Setup nuget
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
- name: Push generated package to Nuget
run: nuget push src\DotNetEd.CoreAdmin\out\*.nupkg -SkipDuplicate -NoSymbols -Source https://api.nuget.org/v3/index.json

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -18,12 +18,14 @@

<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />

</ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DotNetEd.CoreAdmin\DotNetEd.CoreAdmin.csproj" />
<ProjectReference Condition="'$(TargetFramework)' == 'net6.0'" Include="..\DotNetEd.CoreAdmin\DotNetEd.CoreAdmin.csproj" />
<ProjectReference Condition="'$(TargetFramework)' == 'net7.0'" Include="..\DotNetEd.CoreAdmin\DotNetEd.CoreAdmin.csproj" />
<ProjectReference Condition="'$(TargetFramework)' == 'net8.0'" Include="..\DotNetEd.CoreAdmin\DotNetEd.CoreAdmin.csproj" />
</ItemGroup>

</Project>
10 changes: 6 additions & 4 deletions src/DotNetEd.CoreAdmin/DotNetEd.CoreAdmin.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PreserveCompilationContext>false</PreserveCompilationContext>
<SuppressDependenciesWhenPacking>false</SuppressDependenciesWhenPacking>
<PackageId>CoreAdmin</PackageId>
<PackageVersion>2.7.1</PackageVersion>
<Description>Automagically add an Admin Panel to your .NET 6 or .NET 7 web app.</Description>
<Description>Automagically add an Admin Panel to your .NET 6, .NET 7 or .NET 8 web app.</Description>
<Title>Core Admin Panel for ASP.NET Core</Title>
<Authors>edandersen</Authors>
<Copyright>Copyright ©2022 Ed Andersen</Copyright>
<Copyright>Copyright © 2022 Ed Andersen</Copyright>
<PackageProjectUrl>https://github.com/edandersen/core-admin</PackageProjectUrl>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<Nullable>disable</Nullable>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -46,7 +47,8 @@
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="NonFactors.Grid.Core.Mvc6" Version="7.1.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="NonFactors.Grid.Core.Mvc6" Version="7.2.0" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down

This file was deleted.

66 changes: 43 additions & 23 deletions tests/DotNetEd.CoreAdmin.IntegrationTestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DotNetEd.CoreAdmin.IntegrationTests.TestApp;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using DotNetEd.CoreAdmin.Controllers;
using DotNetEd.CoreAdmin.IntegrationTestApp.Middleware;

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace DotNetEd.CoreAdmin.IntegrationTestApp


var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllersWithViews().AddApplicationPart(typeof(CoreAdminDataController).Assembly);


var app = builder.Build();

app.UseMiddleware<FakeUserMiddleware>();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<IntegrationTestStartup>();
});
}
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
// app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>

Check warning on line 36 in tests/DotNetEd.CoreAdmin.IntegrationTestApp/Program.cs

View workflow job for this annotation

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)

Check warning on line 36 in tests/DotNetEd.CoreAdmin.IntegrationTestApp/Program.cs

View workflow job for this annotation

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)

Check warning on line 36 in tests/DotNetEd.CoreAdmin.IntegrationTestApp/Program.cs

View workflow job for this annotation

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)

Check warning on line 36 in tests/DotNetEd.CoreAdmin.IntegrationTestApp/Program.cs

View workflow job for this annotation

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});

app.Run();



public partial class Program { }
38 changes: 23 additions & 15 deletions tests/DotNetEd.CoreAdmin.IntegrationTests/BasicTests.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using DotNetEd.CoreAdmin.IntegrationTests.TestApp;
using System;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using Xunit;

using DotNetEd.CoreAdmin.IntegrationTests.TestApp;


namespace DotNetEd.CoreAdmin.IntegrationTests
{
public class BasicTests : IClassFixture<IntegrationTestsWebHostFactory<IntegrationTestStartup>>
public class BasicTests : IClassFixture<TestAppFixture>
{
private readonly IntegrationTestsWebHostFactory<IntegrationTestStartup> _factory;
private readonly TestAppFixture _fixture;

public BasicTests(IntegrationTestsWebHostFactory<IntegrationTestStartup> factory)
public BasicTests(TestAppFixture fixture)
{
_factory = factory;
_fixture = fixture;
}

static void ConfigureTestServices(IServiceCollection services) { }
Expand All @@ -23,7 +26,7 @@ static void ConfigureTestServices(IServiceCollection services) { }
public async Task ShowsTestEntitiesOnScreenOnAdminScreen()
{
// Arrange
var client = _factory.WithWebHostBuilder(builder => {
var client = _fixture.Factory.WithWebHostBuilder(builder => {
builder.UseEnvironment("Development");
builder.ConfigureTestServices(ConfigureTestServices);
}).CreateClient();
Expand All @@ -45,21 +48,26 @@ public async Task ShowsTestEntitiesOnScreenOnAdminScreen()
[Fact]
public async Task ShowDataInDbSetOnScreen()
{
var dbContext = _factory.Services.GetService<IntegrationTestDbContext>();
var idGuid = Guid.NewGuid();
var nameGuidString = Guid.NewGuid().ToString();
dbContext.TestEntities.Add(new TestApp.Entities.TestEntity() { Id = idGuid, Name = nameGuidString});
await dbContext.SaveChangesAsync();

// Arrange
var client = _factory.WithWebHostBuilder(builder => {
var client = _fixture.Factory.WithWebHostBuilder(builder => {
builder.UseEnvironment("Development");
builder.ConfigureTestServices(ConfigureTestServices);
}).CreateClient();

var idGuid = Guid.NewGuid();
var nameGuidString = Guid.NewGuid().ToString();

using (var scope = _fixture.Factory.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<IntegrationTestDbContext>();
dbContext.TestEntities.Add(new TestApp.Entities.TestEntity() { Id = idGuid, Name = nameGuidString });
await dbContext.SaveChangesAsync();
}

// Act
var response = await client.GetAsync("/coreadmindata/index/testentities");

// Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299
Assert.Equal("text/html; charset=utf-8",
response.Content.Headers.ContentType.ToString());
Expand Down
Loading
Loading