Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/autositemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Marthijn van den Heuvel committed Jun 19, 2024
2 parents 3288901 + 0f9f908 commit d4e4e53
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Sidio.Sitemap.AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{30
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication", "src\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.csproj", "{CB190E46-DDD0-44A0-A384-9C99239A30FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests", "src\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.csproj", "{AF1B6B53-8880-478B-8F38-C45439C9E431}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -46,6 +48,10 @@ Global
{CB190E46-DDD0-44A0-A384-9C99239A30FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB190E46-DDD0-44A0-A384-9C99239A30FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB190E46-DDD0-44A0-A384-9C99239A30FF}.Release|Any CPU.Build.0 = Release|Any CPU
{AF1B6B53-8880-478B-8F38-C45439C9E431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF1B6B53-8880-478B-8F38-C45439C9E431}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF1B6B53-8880-478B-8F38-C45439C9E431}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF1B6B53-8880-478B-8F38-C45439C9E431}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -57,5 +63,6 @@ Global
{DC78B0F0-C432-40E0-B457-28DECCF93989} = {8BB6D612-E472-451D-8EE3-390A292B238F}
{FF6107F5-2129-4482-976D-4A59B7CF9012} = {150077D2-C1D4-422C-9343-1A0FAA5C663E}
{CB190E46-DDD0-44A0-A384-9C99239A30FF} = {304BDC1E-73E2-4CD5-9CAE-14642D299E4D}
{AF1B6B53-8880-478B-8F38-C45439C9E431} = {150077D2-C1D4-422C-9343-1A0FAA5C663E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using Xunit;
global using FluentAssertions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Microsoft.AspNetCore.Mvc.Testing;

namespace Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.MvcWebApplication.Controllers;

public sealed class SitemapControllerTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;

public SitemapControllerTests(WebApplicationFactory<Program> factory)
{
_factory = factory;
}

[Fact]
public async Task SitemapIndex_ReturnsSitemapIndex()
{
// arrange
var client = _factory.CreateClient();

// act
var response = await client.GetAsync("/sitemap.xml");

// assert
response.IsSuccessStatusCode.Should().BeTrue();
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("sitemapindex");
}

[Fact]
public async Task SitemapHome_ReturnsSitemap()
{
// arrange
var client = _factory.CreateClient();

// act
var response = await client.GetAsync("/sitemap-home.xml");

// assert
response.IsSuccessStatusCode.Should().BeTrue();
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("sitemap");
}

[Fact]
public async Task SitemapNews_ReturnsSitemap()
{
// arrange
var client = _factory.CreateClient();

// act
var response = await client.GetAsync("/sitemap-news.xml");

// assert
response.IsSuccessStatusCode.Should().BeTrue();
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("news:news");
}

[Fact]
public async Task SitemapImages_ReturnsSitemap()
{
// arrange
var client = _factory.CreateClient();

// act
var response = await client.GetAsync("/sitemap-images.xml");

// assert
response.IsSuccessStatusCode.Should().BeTrue();
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("image:image");
}

[Fact]
public async Task SitemapVideos_ReturnsSitemap()
{
// arrange
var client = _factory.CreateClient();

// act
var response = await client.GetAsync("/sitemap-videos.xml");

// assert
response.IsSuccessStatusCode.Should().BeTrue();
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("video:video");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.analyzers" Version="1.14.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication\Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@

app.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();
app.Run();

public partial class Program;
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.analyzers" Version="1.13.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.analyzers" Version="1.14.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Sidio.Sitemap.Core" Version="2.2.4" />
<PackageReference Include="Sidio.Sitemap.Core" Version="2.3.0" />
</ItemGroup>

</Project>

0 comments on commit d4e4e53

Please sign in to comment.