Skip to content

Commit

Permalink
BUMP to .net 8 / 9
Browse files Browse the repository at this point in the history
FIX Using WebApplicationFactory for tests to follow latest guidance regarding integration tests and Asp.Net
  • Loading branch information
anton-kirschhock committed Dec 19, 2024
1 parent afb5661 commit 047b92f
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -17,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

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

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks>
<AssemblyName>TurnerSoftware.RobotsExclusionTools</AssemblyName>
<Description>Robots.txt parsing and querying utility</Description>
<PackageTags>$(PackageBaseTags)</PackageTags>
Expand All @@ -10,9 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="TurnerSoftware.BuildVersioning" Version="0.5.0" />
</ItemGroup>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.IO;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

using TurnerSoftware.RobotsExclusionTools.Tests.TestSite;


var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.UseRouting();


app.MapGet("robots.txt", async (ctx) =>
{
var context = ctx.RequestServices.GetRequiredService<SiteContext>();
if (context.ExpectedStatusCode == 200)
{
ctx.Response.Headers.ContentType = new("text/plain");
ctx.Response.StatusCode = 200;
await ctx.Response.WriteAsync("# This file is used by the Test Server\n# This allows testing loading by URI\nUser-agent: MyCustom-UserAgent\nDisallow: ");
}
else
{
ctx.Response.StatusCode = context.ExpectedStatusCode;
}
await ctx.Response.CompleteAsync();

});

app.Run();
public partial class Program { }
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TurnerSoftware.RobotsExclusionTools.Tests.TestSite
namespace TurnerSoftware.RobotsExclusionTools.Tests.TestSite
{
public class SiteContext
public class SiteContext(int expectedStatusCode)
{
public int StatusCode { get; set; }
public int ExpectedStatusCode { get; set; } = expectedStatusCode;
}
}

This file was deleted.

This file was deleted.

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

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\*.*" />
</ItemGroup>

<ItemGroup>
<Content Include="Resources\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
</ItemGroup>

</Project>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\*.*" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using TurnerSoftware.RobotsExclusionTools.Helpers;

namespace TurnerSoftware.RobotsExclusionTools.Tests.Helpers;
Expand All @@ -19,9 +19,9 @@ public class RobotsExclusionProtocolHelperTests
[DataRow(9, new byte[] { 0xF2, 0xBF, 0xBF, 0x80 }, 4)]
[DataRow(10, new byte[] { 0xF4, 0x8F, 0x80, 0x80 }, 4)]
[DataTestMethod]
public void TryReadUtf8ByteSequenceTest(int _, object[] rawInput, int? expectedNumberOfBytes)
public void TryReadUtf8ByteSequenceTest(int _, byte[] rawInput, int? expectedNumberOfBytes)
{
var bytes = Array.ConvertAll(rawInput, (input) => (byte)Convert.ToInt32(input));
var bytes = rawInput; //Array.ConvertAll(rawInput, (input) => (byte)Convert.ToInt32(input));
var result = RobotsExclusionProtocolHelper.TryReadUtf8ByteSequence(bytes, out var actual);
if (expectedNumberOfBytes is null)
{
Expand Down
Loading

0 comments on commit 047b92f

Please sign in to comment.