diff --git a/Sidio.Sitemap.AspNetCore.sln b/Sidio.Sitemap.AspNetCore.sln index 2686a25..a20fda2 100644 --- a/Sidio.Sitemap.AspNetCore.sln +++ b/Sidio.Sitemap.AspNetCore.sln @@ -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 @@ -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 @@ -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 diff --git a/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/GlobalUsings.cs b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/GlobalUsings.cs new file mode 100644 index 0000000..7fef4b0 --- /dev/null +++ b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Xunit; +global using FluentAssertions; \ No newline at end of file diff --git a/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/MvcWebApplication/Controllers/SitemapControllerTests.cs b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/MvcWebApplication/Controllers/SitemapControllerTests.cs new file mode 100644 index 0000000..f57c2b5 --- /dev/null +++ b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/MvcWebApplication/Controllers/SitemapControllerTests.cs @@ -0,0 +1,88 @@ +using Microsoft.AspNetCore.Mvc.Testing; + +namespace Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.MvcWebApplication.Controllers; + +public sealed class SitemapControllerTests : IClassFixture> +{ + private readonly WebApplicationFactory _factory; + + public SitemapControllerTests(WebApplicationFactory 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"); + } +} \ No newline at end of file diff --git a/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.csproj b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.csproj new file mode 100644 index 0000000..ca5a389 --- /dev/null +++ b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication.Tests.csproj @@ -0,0 +1,31 @@ + + + + net8.0 + enable + enable + false + true + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication/Program.cs b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication/Program.cs index c20156a..ddcf3c3 100644 --- a/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication/Program.cs +++ b/src/Sidio.Sitemap.AspNetCore.Examples.MvcWebApplication/Program.cs @@ -29,4 +29,6 @@ app.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); -app.Run(); \ No newline at end of file +app.Run(); + +public partial class Program; \ No newline at end of file diff --git a/src/Sidio.Sitemap.AspNetCore.Tests/Sidio.Sitemap.AspNetCore.Tests.csproj b/src/Sidio.Sitemap.AspNetCore.Tests/Sidio.Sitemap.AspNetCore.Tests.csproj index cde3558..eb2072a 100644 --- a/src/Sidio.Sitemap.AspNetCore.Tests/Sidio.Sitemap.AspNetCore.Tests.csproj +++ b/src/Sidio.Sitemap.AspNetCore.Tests/Sidio.Sitemap.AspNetCore.Tests.csproj @@ -11,10 +11,10 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Sidio.Sitemap.AspNetCore/Sidio.Sitemap.AspNetCore.csproj b/src/Sidio.Sitemap.AspNetCore/Sidio.Sitemap.AspNetCore.csproj index f712858..c918182 100644 --- a/src/Sidio.Sitemap.AspNetCore/Sidio.Sitemap.AspNetCore.csproj +++ b/src/Sidio.Sitemap.AspNetCore/Sidio.Sitemap.AspNetCore.csproj @@ -36,7 +36,7 @@ - +