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.
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
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));
|
|
}
|
|
}
|
|
}
|