Phase 7: Mapping-Randfälle + Parser-/Repo-Randfälle (78 Tests)
- DbContextModelTests: feinkörnige Modell-Invarianten - Dezimal-Präzision (18,6) auf Geldfeldern (Core + Settings), MaxLength auf Strings, manuell gesetzte Keys (ValueGeneratedNever), AssignedAccountIds hat Value-Converter + text-Spalte, MarketData JSON-Spalten = text, Indizes (TradeRecord.ClosedAt, MasterTraderHistory TraderId/ClosedAt). (GetColumnType() wirft unter InMemory -> Spaltentyp via Relational:ColumnType- Annotation ausgelesen.) - MongoExportParserTests erweitert: numerische statt String-Dezimale, unbekannte Felder ignoriert, mehrere Dokumente in Reihenfolge, AssignedAccountIds als String-Zahlen, IsActive-Default. - RepositoryEdgeCaseTests: GetAll leer != null, Update-Alias, Factory-Isolation, History-Exists/GetByTraderSince inklusive an den Grenzen. Alle 78 gruen. (Copytrading-Service-Logik bewusst noch nicht getestet - wird parallel ueberarbeitet.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b8d2c8094b
commit
92a88e8be8
@@ -116,5 +116,51 @@ namespace PolyTrader.Tests
|
||||
Assert.Empty(MongoExportParser.ParseAccounts("[]"));
|
||||
Assert.Empty(MongoExportParser.ParseTraders("[]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAccounts_accepts_numeric_decimals_not_only_strings()
|
||||
{
|
||||
const string json = """[{ "_id": 1, "TotalBalance": 12.5, "PerMarketLimit": 3 }]""";
|
||||
|
||||
var imp = Assert.Single(MongoExportParser.ParseAccounts(json));
|
||||
Assert.Equal(12.5m, imp.Account.TotalBalance);
|
||||
Assert.Equal(3m, imp.Settings.PerMarketLimit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAccounts_ignores_unknown_extra_fields()
|
||||
{
|
||||
const string json = """[{ "_id": 1, "Name": "X", "SomethingUnknown": {"a":1}, "Extra": [1,2,3] }]""";
|
||||
|
||||
var imp = Assert.Single(MongoExportParser.ParseAccounts(json));
|
||||
Assert.Equal("X", imp.Account.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAccounts_reads_multiple_documents_in_order()
|
||||
{
|
||||
const string json = """[{ "_id": 1 }, { "_id": 2 }, { "_id": 3 }]""";
|
||||
|
||||
var ids = MongoExportParser.ParseAccounts(json).Select(x => x.Account.AccountId).ToArray();
|
||||
Assert.Equal(new[] { 1, 2, 3 }, ids);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseTraders_accepts_assigned_account_ids_as_string_numbers()
|
||||
{
|
||||
const string json = """[{ "_id": 9, "AssignedAccountIds": ["1", "3"] }]""";
|
||||
|
||||
var t = Assert.Single(MongoExportParser.ParseTraders(json));
|
||||
Assert.Equal(new HashSet<int> { 1, 3 }, t.AssignedAccountIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseTraders_missing_isactive_defaults_true()
|
||||
{
|
||||
const string json = """[{ "_id": 9 }]""";
|
||||
|
||||
var t = Assert.Single(MongoExportParser.ParseTraders(json));
|
||||
Assert.True(t.IsActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user