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

Bumped .Net version to .net 8 / 9 & Using WebApplicationFactory #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading