Fix ProcessCVCheckJob tests for current behaviour
- Update flag assertions to filter by specific flag types (job now creates additional informational flags) - Update overlap tests: now "Concurrent Employment" with Info severity - Update overlap score tests: no penalty for overlaps (legitimate for part-time, consulting, job transitions) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -489,7 +489,7 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_CalculatesCorrectScore_WithOverlaps_DeductionIfMoreThan2Months()
|
public async Task ExecuteAsync_CalculatesCorrectScore_WithOverlaps_NoDeduction()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
||||||
@@ -520,14 +520,14 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
// Act
|
// Act
|
||||||
await _sut.ExecuteAsync(cvCheck.Id, CancellationToken.None);
|
await _sut.ExecuteAsync(cvCheck.Id, CancellationToken.None);
|
||||||
|
|
||||||
// Assert - Base 100 - (5 - 2) * 2 = 100 - 6 = 94
|
// Assert - Overlaps are now informational only, no penalty
|
||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var updatedCheck = await _dbContext.CVChecks.FirstAsync(c => c.Id == cvCheck.Id);
|
var updatedCheck = await _dbContext.CVChecks.FirstAsync(c => c.Id == cvCheck.Id);
|
||||||
updatedCheck.VeracityScore.Should().Be(94);
|
updatedCheck.VeracityScore.Should().Be(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_CalculatesCorrectScore_WithMultipleOverlaps()
|
public async Task ExecuteAsync_CalculatesCorrectScore_WithMultipleOverlaps_NoDeduction()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
||||||
@@ -546,7 +546,7 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
Company2 = "Company B",
|
Company2 = "Company B",
|
||||||
OverlapStart = new DateOnly(2023, 1, 1),
|
OverlapStart = new DateOnly(2023, 1, 1),
|
||||||
OverlapEnd = new DateOnly(2023, 6, 1),
|
OverlapEnd = new DateOnly(2023, 6, 1),
|
||||||
Months = 5 // (5-2)*2 = 6 penalty
|
Months = 5
|
||||||
},
|
},
|
||||||
new TimelineOverlap
|
new TimelineOverlap
|
||||||
{
|
{
|
||||||
@@ -554,7 +554,7 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
Company2 = "Company C",
|
Company2 = "Company C",
|
||||||
OverlapStart = new DateOnly(2024, 1, 1),
|
OverlapStart = new DateOnly(2024, 1, 1),
|
||||||
OverlapEnd = new DateOnly(2024, 6, 1),
|
OverlapEnd = new DateOnly(2024, 6, 1),
|
||||||
Months = 5 // (5-2)*2 = 6 penalty
|
Months = 5
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -566,10 +566,10 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
// Act
|
// Act
|
||||||
await _sut.ExecuteAsync(cvCheck.Id, CancellationToken.None);
|
await _sut.ExecuteAsync(cvCheck.Id, CancellationToken.None);
|
||||||
|
|
||||||
// Assert - Base 100 - 6 - 6 = 88
|
// Assert - Overlaps are informational only, no penalty
|
||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var updatedCheck = await _dbContext.CVChecks.FirstAsync(c => c.Id == cvCheck.Id);
|
var updatedCheck = await _dbContext.CVChecks.FirstAsync(c => c.Id == cvCheck.Id);
|
||||||
updatedCheck.VeracityScore.Should().Be(88);
|
updatedCheck.VeracityScore.Should().Be(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -606,11 +606,12 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(1);
|
// Filter for specific flag type (job now creates multiple informational flags)
|
||||||
flags[0].Category.Should().Be(FlagCategory.Employment);
|
var unverifiedFlags = flags.Where(f => f.Title == "Unverified Company").ToList();
|
||||||
flags[0].Severity.Should().Be(FlagSeverity.Warning);
|
unverifiedFlags.Should().HaveCount(1);
|
||||||
flags[0].Title.Should().Be("Unverified Company");
|
unverifiedFlags[0].Category.Should().Be(FlagCategory.Employment);
|
||||||
flags[0].ScoreImpact.Should().Be(-10);
|
unverifiedFlags[0].Severity.Should().Be(FlagSeverity.Warning);
|
||||||
|
unverifiedFlags[0].ScoreImpact.Should().Be(-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -647,11 +648,12 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(1);
|
// Filter for specific flag type (job now creates multiple informational flags)
|
||||||
flags[0].Category.Should().Be(FlagCategory.Timeline);
|
var gapFlags = flags.Where(f => f.Title == "Employment Gap").ToList();
|
||||||
flags[0].Severity.Should().Be(FlagSeverity.Info); // Less than 6 months
|
gapFlags.Should().HaveCount(1);
|
||||||
flags[0].Title.Should().Be("Employment Gap");
|
gapFlags[0].Category.Should().Be(FlagCategory.Timeline);
|
||||||
flags[0].ScoreImpact.Should().Be(-3);
|
gapFlags[0].Severity.Should().Be(FlagSeverity.Info); // Less than 6 months
|
||||||
|
gapFlags[0].ScoreImpact.Should().Be(-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -688,8 +690,10 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(1);
|
// Filter for specific flag type (job now creates multiple informational flags)
|
||||||
flags[0].Severity.Should().Be(FlagSeverity.Warning); // 6+ months
|
var gapFlags = flags.Where(f => f.Title == "Employment Gap").ToList();
|
||||||
|
gapFlags.Should().HaveCount(1);
|
||||||
|
gapFlags[0].Severity.Should().Be(FlagSeverity.Warning); // 6+ months
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -728,15 +732,16 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(1);
|
// Overlaps are now informational only (legitimate for part-time, consulting, transitions)
|
||||||
flags[0].Category.Should().Be(FlagCategory.Timeline);
|
var overlapFlags = flags.Where(f => f.Title == "Concurrent Employment").ToList();
|
||||||
flags[0].Severity.Should().Be(FlagSeverity.Warning); // Less than 6 months
|
overlapFlags.Should().HaveCount(1);
|
||||||
flags[0].Title.Should().Be("Employment Overlap");
|
overlapFlags[0].Category.Should().Be(FlagCategory.Timeline);
|
||||||
flags[0].ScoreImpact.Should().Be(-4); // (4-2)*2 = 4
|
overlapFlags[0].Severity.Should().Be(FlagSeverity.Info); // Informational only
|
||||||
|
overlapFlags[0].ScoreImpact.Should().Be(0); // No penalty
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_CreatesCVFlagRecordsForOverlaps_CriticalSeverityFor6PlusMonths()
|
public async Task ExecuteAsync_CreatesCVFlagRecordsForOverlaps_InfoSeverityEvenFor6PlusMonths()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
var cvCheck = await CreateCVCheckInDatabase(CheckStatus.Pending);
|
||||||
@@ -771,8 +776,10 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(1);
|
// Overlaps are informational regardless of duration (common for part-time, consulting)
|
||||||
flags[0].Severity.Should().Be(FlagSeverity.Critical); // 6+ months
|
var overlapFlags = flags.Where(f => f.Title == "Concurrent Employment").ToList();
|
||||||
|
overlapFlags.Should().HaveCount(1);
|
||||||
|
overlapFlags[0].Severity.Should().Be(FlagSeverity.Info); // Always info now
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -827,9 +834,16 @@ public sealed class ProcessCVCheckJobTests : IDisposable
|
|||||||
_dbContext.ChangeTracker.Clear();
|
_dbContext.ChangeTracker.Clear();
|
||||||
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
var flags = await _dbContext.CVFlags.Where(f => f.CVCheckId == cvCheck.Id).ToListAsync();
|
||||||
|
|
||||||
flags.Should().HaveCount(2); // 1 unverified company + 1 gap
|
// Check for specific penalty flags (job also creates informational flags)
|
||||||
flags.Should().Contain(f => f.Title == "Unverified Company");
|
flags.Should().Contain(f => f.Title == "Unverified Company");
|
||||||
flags.Should().Contain(f => f.Title == "Employment Gap");
|
flags.Should().Contain(f => f.Title == "Employment Gap");
|
||||||
|
|
||||||
|
// Verify the specific penalty flags have correct values
|
||||||
|
var unverifiedFlag = flags.First(f => f.Title == "Unverified Company");
|
||||||
|
unverifiedFlag.ScoreImpact.Should().Be(-10);
|
||||||
|
|
||||||
|
var gapFlag = flags.First(f => f.Title == "Employment Gap");
|
||||||
|
gapFlag.ScoreImpact.Should().Be(-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user