mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-07 09:19:04 +00:00
- ProposalConcurrencyTests (shared-connection SQLite, two competing
writers): stale-token pre-check with embedded currentState, DB-level
lost race reloading the winner's values, 422 token codes, version
bump on success, bulk-update proposal-token guard, line-item create
bumping the aggregate, audit rows never persisted on a lost race.
- GlobalExceptionHandlerTests: pin both SHOC 409 envelopes verbatim
(guarded { message, currentState } incl. null state; fallback
{ status, message, code }) and assert shape exclusivity.
- RowVersionCodecTests: round-trip, SHOC-style token literal,
malformed/wrong-length rejection.
- Existing suites threaded with live version tokens (Ver helper);
audit assertions moved from LogAsync to Stage.
187 xUnit green (was 166).
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using FluentAssertions;
|
|
using ProposalSystem.Application.Common;
|
|
using Xunit;
|
|
|
|
namespace ProposalSystem.Tests.Common;
|
|
|
|
public class RowVersionCodecTests
|
|
{
|
|
[Theory(DisplayName = "Encode/TryDecode round-trips")]
|
|
[InlineData(1L)]
|
|
[InlineData(2L)]
|
|
[InlineData(long.MaxValue)]
|
|
public void RoundTrips(long version)
|
|
{
|
|
var token = RowVersionCodec.Encode(version);
|
|
|
|
RowVersionCodec.TryDecode(token, out var decoded).Should().BeTrue();
|
|
decoded.Should().Be(version);
|
|
}
|
|
|
|
[Fact(DisplayName = "Version 1 encodes to the SHOC-style opaque token")]
|
|
public void EncodesOpaqueBase64()
|
|
{
|
|
RowVersionCodec.Encode(1).Should().Be("AAAAAAAAAAE=");
|
|
}
|
|
|
|
[Theory(DisplayName = "TryDecode rejects missing/malformed/wrong-length tokens")]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData("not base64!!")]
|
|
[InlineData("AAA=")] // valid base64 but not 8 bytes
|
|
[InlineData("AAAAAAAAAAAAAAAAAAAAAA==")] // 16 bytes
|
|
public void RejectsInvalid(string? token)
|
|
{
|
|
RowVersionCodec.TryDecode(token, out _).Should().BeFalse();
|
|
}
|
|
}
|