Relocate test project: test/yavscTests -> src/Yavsc.Org.Tests

Move the integration test project from the top-level test/ directory into
src/ alongside the projects it tests. Rename the project (and folder) to
Yavsc.Org.Tests to match .NET conventions and reflect that it tests the
Org runtime primarily.

Path changes:
- test/yavscTests/yavscTests.csproj -> src/Yavsc.Org.Tests/Yavsc.Org.Tests.csproj
- All .cs / .json / .resx files moved to their new location
- PostItViewModelTests moved out to the dedicated src/PostIt.Tests project
  (it was unrelated to Org testing)

Build adjustments:
- <ProjectReference> paths shortened (..\..\src\X -> ..\X)
- PostIt project reference removed (covered by its own test project)
- <OutputType>exe added (required by xunit.v3)
- xunit.v3.common and xunit.v3.extensibility.core added to package versions

Solution + sln:
- yavsc.sln Project Name updated to 'Yavsc.Org.Tests' and path updated
- GUID preserved so existing build configs stay valid

Static web assets:
- The CopyStaticWebAssetsManifest target was hard-coding the destination
  filename to 'testhost.staticwebassets.endpoints.json', which worked
  when the assembly was named 'yavscTests'. Now that the assembly name
  is 'Yavsc.Org.Tests', ASP.NET Core's MapStaticAssets() looks for
  'Yavsc.Org.Tests.staticwebassets.endpoints.json' (entry-assembly-based
  resolution). Use $(MSBuildProjectName) so the copy target stays
  correct under any future rename.
This commit is contained in:
Paul Schneider 2026-06-19 17:52:54 +01:00
commit 22b397ce7e
18 changed files with 16 additions and 22 deletions

View file

@ -0,0 +1,27 @@
using Yavsc.Server.Helpers;
namespace yavscTests
{
[Collection("Yavsc Abstract tests")]
[Trait("regression", "II")]
public class AbstractTests
{
readonly ITestOutputHelper output;
public AbstractTests(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void UniqueFilenameAfterCleaning()
{
var name1 = "content:///scanned_files/2020-06-02/00.11.02.JPG";
var name2 = "content:///scanned_files/2020-06-02/00.11.03.JPG";
var cleanName1 = AbstractFileSystemHelpers.FilterFileName(name1);
var cleanName2 = AbstractFileSystemHelpers.FilterFileName(name2);
output.WriteLine($"{name1} => {cleanName1}");
output.WriteLine($"{name2} => {cleanName2}");
Assert.True(cleanName1 != cleanName2);
}
}
}

View file

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore;
using Xunit;
using Yavsc;
using Yavsc.Abstract.Workflow;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Billing;
using Yavsc.Models.Haircut;
using Yavsc.Services;
namespace yavscTests
{
[Trait("regression", "II")]
public class BillingServiceTests
{
[Fact]
public void ConfigureBillingService_CanBeCalledTwiceWithoutThrowing()
{
// First initialization should populate the billing registry.
WorkflowHelpers.ConfigureBillingService();
int firstBillingCount = BillingService.Billing.Count;
int firstSettingsCount = BillingService.UserSettings.Count;
int firstProfileTypesCount = Config.ProfileTypes.Count;
// Second call should be idempotent and not throw.
WorkflowHelpers.ConfigureBillingService();
Assert.Equal(firstBillingCount, BillingService.Billing.Count);
Assert.Equal(firstSettingsCount, BillingService.UserSettings.Count);
Assert.Equal(firstProfileTypesCount, Config.ProfileTypes.Count);
}
[Fact]
public void RegisterBilling_DuplicateRegistrationThrowsInvalidOperationException()
{
WorkflowHelpers.ConfigureBillingService();
var firstRegistrar = new Func<ApplicationDbContext, long, IDecidableQuery>((db, id) =>
db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id));
const string testCode = "Brush";
Assert.Throws<InvalidOperationException>(() =>
WorkflowHelpers.RegisterBilling<HairCutQuery>(testCode, firstRegistrar));
}
}
}

View file

@ -0,0 +1,36 @@
using yavscTests.ServerFixtures;
namespace yavscTests.Mandatory
{
[Collection("Database")]
[Trait("regression", "II")]
[Trait("dev", "wip")]
public class Database: IClassFixture<WebServerFixture>, IDisposable
{
readonly WebServerFixture _serverFixture;
readonly ITestOutputHelper output;
public Database(WebServerFixture serverFixture, ITestOutputHelper output)
{
this.output = output;
_serverFixture = serverFixture;
}
/// <summary>
/// Assuming we're using an account that may create databases,
/// Install all our migrations in a fresh new database.
/// </summary>
public void Dispose()
{
if (_serverFixture!=null)
{
_serverFixture.Dispose();
}
}
}
}

View file

@ -0,0 +1,43 @@
using yavscTests.ServerFixtures;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Yavsc.Interface;
namespace yavscTests
{
[Collection("EMaillingTeststCollection")]
[Trait("regression", "II")]
public class EMaillingTests : IClassFixture<WebServerFixture>
{
readonly WebServerFixture _serverFixture;
readonly ITestOutputHelper output;
readonly ILogger _logger;
public EMaillingTests(WebServerFixture serverFixture, ITestOutputHelper output)
{
this.output = output;
_serverFixture = serverFixture;
_logger = serverFixture.Logger;
}
[Fact]
public void SendEMailSynchrone()
{
using IServiceScope scope = _serverFixture.Services.CreateScope();
ITrueEmailSender mailSender = scope.ServiceProvider.GetRequiredService<ITrueEmailSender>();
output.WriteLine("SendEMailSynchrone ...");
mailSender.SendEmailAsync
(
_serverFixture.SiteSettings.Owner.Name,
_serverFixture.SiteSettings.Owner.EMail,
$"monthly email",
"test boby monthly email").Wait();
}
}
}