Add unit tests for 9 new services/controllers and expand existing test coverage
116 tests passing: JobPhotoService, MeasurementConversionService, PlatformSettingsService, QuoteApprovalController, QuotePhotoService, ShopCapabilityCalculator, StorageMigrationService, TenantContext, UsageQuotaController — plus expanded PricingCalculation, Registration, and Subscription tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
using PowderCoating.Application.Services;
|
||||
using PowderCoating.Core.Entities;
|
||||
using PowderCoating.Core.Enums;
|
||||
|
||||
namespace PowderCoating.UnitTests;
|
||||
|
||||
public class ShopCapabilityCalculatorTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetBlastRateSqFtPerHour_WithOverride_ReturnsOverride()
|
||||
{
|
||||
var costs = new CompanyOperatingCosts
|
||||
{
|
||||
BlastRateSqFtPerHourOverride = 42.5m,
|
||||
CompressorCfm = 150m,
|
||||
BlastNozzleSize = 6,
|
||||
BlastSetupType = BlastSetupType.PressurePot,
|
||||
PrimaryBlastSubstrate = BlastSubstrateType.Paint
|
||||
};
|
||||
|
||||
var result = ShopCapabilityCalculator.GetBlastRateSqFtPerHour(costs);
|
||||
|
||||
Assert.Equal(42.5m, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBlastRateSqFtPerHour_WithNoCompressorCfm_ReturnsZero()
|
||||
{
|
||||
var costs = new CompanyOperatingCosts
|
||||
{
|
||||
CompressorCfm = 0m
|
||||
};
|
||||
|
||||
var result = ShopCapabilityCalculator.GetBlastRateSqFtPerHour(costs);
|
||||
|
||||
Assert.Equal(0m, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBlastRateSqFtPerHour_DerivesRateFromEquipmentInputs()
|
||||
{
|
||||
var costs = new CompanyOperatingCosts
|
||||
{
|
||||
CompressorCfm = 150m,
|
||||
BlastNozzleSize = 6,
|
||||
BlastSetupType = BlastSetupType.PressurePot,
|
||||
PrimaryBlastSubstrate = BlastSubstrateType.Paint
|
||||
};
|
||||
|
||||
var result = ShopCapabilityCalculator.GetBlastRateSqFtPerHour(costs);
|
||||
|
||||
Assert.Equal(58.5m, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBlastRateSqFtPerHour_ForNamedSetup_UsesSetupOverload()
|
||||
{
|
||||
var setup = new CompanyBlastSetup
|
||||
{
|
||||
Name = "Main Cabinet",
|
||||
CompressorCfm = 7m,
|
||||
BlastNozzleSize = 4,
|
||||
SetupType = BlastSetupType.SiphonCabinet,
|
||||
PrimarySubstrate = BlastSubstrateType.Mixed
|
||||
};
|
||||
|
||||
var result = ShopCapabilityCalculator.GetBlastRateSqFtPerHour(setup);
|
||||
|
||||
Assert.Equal(1.7m, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(CoatingGunType.Corona, 40)]
|
||||
[InlineData(CoatingGunType.Tribo, 35)]
|
||||
[InlineData(CoatingGunType.Both, 40)]
|
||||
public void GetCoatingRateSqFtPerHour_ReturnsExpectedDefaultByGunType(CoatingGunType gunType, decimal expected)
|
||||
{
|
||||
var costs = new CompanyOperatingCosts
|
||||
{
|
||||
CoatingGunType = gunType
|
||||
};
|
||||
|
||||
var result = ShopCapabilityCalculator.GetCoatingRateSqFtPerHour(costs);
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ShopCapabilityTier.Garage, BlastSetupType.SiphonCabinet, 7, 4, BlastSubstrateType.Mixed)]
|
||||
[InlineData(ShopCapabilityTier.Small, BlastSetupType.PressurePot, 40, 5, BlastSubstrateType.Mixed)]
|
||||
[InlineData(ShopCapabilityTier.Medium, BlastSetupType.PressurePot, 80, 5, BlastSubstrateType.Mixed)]
|
||||
[InlineData(ShopCapabilityTier.Large, BlastSetupType.PressurePot, 150, 6, BlastSubstrateType.Mixed)]
|
||||
public void TierDefaults_ReturnExpectedPresetValues(
|
||||
ShopCapabilityTier tier,
|
||||
BlastSetupType expectedSetup,
|
||||
decimal expectedCfm,
|
||||
int expectedNozzle,
|
||||
BlastSubstrateType expectedSubstrate)
|
||||
{
|
||||
var defaults = ShopCapabilityCalculator.TierDefaults(tier);
|
||||
|
||||
Assert.Equal(expectedSetup, defaults.SetupType);
|
||||
Assert.Equal(expectedCfm, defaults.Cfm);
|
||||
Assert.Equal(expectedNozzle, defaults.NozzleSize);
|
||||
Assert.Equal(expectedSubstrate, defaults.Substrate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user