Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions ifrs17-template/Test/AocStructureTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@
{
"cell_type": "code",
"source": [
"public async Task CheckAocStepStructureAsync(IEnumerable<BaseDataRecord> inputVariables, ",
"public async Task<ActivityLog> CheckAocStepStructureAsync(IEnumerable<BaseDataRecord> inputVariables, ",
"\n Dictionary<AocStep,IEnumerable<AocStep>> parentBm, ",
"\n Dictionary<AocStep,AocStep> referenceBm, ",
"\n Dictionary<AocStep,IEnumerable<AocStep>> fullAocBm,",
"\n Dictionary<AocStep,IEnumerable<AocStep>> parentBmCdr = null)",
"\n{",
"\n Activity.Start();",
"\n //Save test input data",
"\n var importFormat = ImportFormats.Cashflow;",
"\n var inputSource = InputSource.Cashflow;",
Expand Down Expand Up @@ -232,6 +233,7 @@
"\n }",
"\n ",
"\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));",
"\n return Activity.Finish();",
"\n}",
"\n"
],
Expand Down Expand Up @@ -502,7 +504,17 @@
{
"cell_type": "code",
"source": [
"await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm, parentBm_CDR)"
"var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm, parentBm_CDR);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down Expand Up @@ -604,7 +616,17 @@
{
"cell_type": "code",
"source": [
"await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm)"
"var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down Expand Up @@ -679,7 +701,17 @@
{
"cell_type": "code",
"source": [
"await CheckAocStepStructureAsync(inputIfrsVariables, parentBm, referenceBm, fullAocBm)"
"var activity = await CheckAocStepStructureAsync(inputIfrsVariables, parentBm, referenceBm, fullAocBm);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down
156 changes: 137 additions & 19 deletions ifrs17-template/Test/ImportStorageTest.ipynb

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions ifrs17-template/Test/MapTemplateAndImportTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,13 @@
{
"cell_type": "code",
"source": [
"public async Task CheckErrors(string inputFileName, List<string> errorBms)",
"public async Task<ActivityLog> CheckErrors(string inputFileName, List<string> errorBms)",
"\n{",
"\n Activity.Start();",
"\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(Workspace).ExecuteAsync();",
"\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());",
"\n errorBms.Intersect(log.Errors.Select(x => x.ToString().Substring(0,x.ToString().Length-2).Substring(40)).ToArray()).Count().Should().Be(errorBms.Count());",
"\n return Activity.Finish();",
"\n}"
],
"metadata": {},
Expand All @@ -555,7 +557,8 @@
"\nvar errorsBm = new List<string>(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),",
"\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),",
"\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};",
"\nawait CheckErrors(inputFileName, errorsBm);"
"\nvar activity = await CheckErrors(inputFileName, errorsBm);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
Expand All @@ -567,7 +570,8 @@
"var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";",
"\nvar errorsBm = new List<string>(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),",
"\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};",
"\nawait CheckErrors(inputFileName, errorsBm);"
"\nvar activity = await CheckErrors(inputFileName, errorsBm);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
Expand All @@ -578,7 +582,8 @@
"source": [
"var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";",
"\nvar errorsBm = new List<string>(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};",
"\nawait CheckErrors(inputFileName, errorsBm);"
"\nvar activity = await CheckErrors(inputFileName, errorsBm);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
Expand Down
16 changes: 14 additions & 2 deletions ifrs17-template/Test/ReportStorageTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
{
"cell_type": "code",
"source": [
"public async Task CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable<ExchangeRate> testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)",
"public async Task<ActivityLog> CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable<ExchangeRate> testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)",
"\n{",
"\n Activity.Start();",
"\n await Workspace.UpdateAsync(testData);",
"\n ",
"\n //Create report storage",
Expand All @@ -68,6 +69,7 @@
"\n fxEOP.Should().Be(fxEOPBenchmark);",
"\n ",
"\n await Workspace.DeleteAsync(Workspace.Query<ExchangeRate>().ToArray());",
"\n return Activity.Finish();",
"\n}"
],
"metadata": {},
Expand All @@ -84,7 +86,17 @@
"\n new ExchangeRate{ Currency = \"USD\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 5 },",
"\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 2 },",
"\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 0.5 }};",
"\nawait CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);"
"\nvar activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down
40 changes: 36 additions & 4 deletions ifrs17-template/Test/ReportVariablesTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@
{
"cell_type": "code",
"source": [
"public async Task RunTestAsync () ",
"public async Task<ActivityLog> RunTestAsync () ",
"\n{",
"\n Activity.Start();",
Comment thread
nnikolopoulos marked this conversation as resolved.
"\n scopesData = await GetScopesDataAsync(args, reportStorage, Scopes);",
"\n benchmarkData = await GetBenchmarkDataAsync(args, path, Workspace, Import);",
"\n",
Expand All @@ -145,6 +146,7 @@
"\n //.Excluding(o => o.Value)",
"\n .Using<double>(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, BenchmarkPrecision))",
"\n .WhenTypeIs<double>() );",
"\n return Activity.Finish();",
"\n}"
],
"metadata": {},
Expand Down Expand Up @@ -173,7 +175,17 @@
"cell_type": "code",
"source": [
"args = ((2020, 12), \"CH\", null, CurrencyType.Contractual);",
"\nawait RunTestAsync()"
"\nvar activity = await RunTestAsync();",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand All @@ -192,7 +204,17 @@
"cell_type": "code",
"source": [
"args = ((2021, 3), \"CH\", null, CurrencyType.Contractual);",
"\nawait RunTestAsync()"
"\nvar activity = await RunTestAsync();",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand All @@ -211,7 +233,17 @@
"cell_type": "code",
"source": [
"args = ((2020, 12), \"CH\", \"MTUP10pct\", CurrencyType.Contractual);",
"\nawait RunTestAsync()"
"\nvar activity = await RunTestAsync();",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down
3 changes: 2 additions & 1 deletion ifrs17-template/Test/ReportVariablesTestBase.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
"static async Task<ICollection<ReportVariable>> GetBenchmarkDataAsync(((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) args, string path, IWorkspace workspace, IImportVariable importVariable) {",
"\n var bmFileName = benchmarkFileNamePrefix + GetBenchmarkFileName(args) + \".csv\";",
"\n await workspace.Partition.SetAsync<PartitionByReportingNodeAndPeriod>(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Period.Year, Month = args.Period.Month });",
"\n await importVariable.FromFile(path + bmFileName).WithType<ReportVariable>(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();",
"\n var log = await importVariable.FromFile(path + bmFileName).WithType<ReportVariable>(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();",
"\n ApplicationMessage.Log(log);",
Comment thread
nnikolopoulos marked this conversation as resolved.
"\n var ret = await workspace.Query<ReportVariable>().ToArrayAsync();",
"\n workspace.Reset(x => x.ResetCurrentPartitions().ResetType<ReportVariable>());",
"\n return ret;",
Expand Down
18 changes: 18 additions & 0 deletions ifrs17-template/Test/SequenceImportTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"ifrsVars1.Count().Should().NotBe(0);"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"ifrsVars2.Count().Should().NotBe(0);"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
Expand Down
40 changes: 36 additions & 4 deletions ifrs17-template/Test/TechnicalMarginTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@
{
"cell_type": "code",
"source": [
"public async Task CheckSwitchLogicAsync(IEnumerable<IfrsVariable> inputDataSet, Dictionary<AocStep,(double valueCsm, double valueLc)> csmLcSwitchBenchmark)",
"public async Task<ActivityLog> CheckSwitchLogicAsync(IEnumerable<IfrsVariable> inputDataSet, Dictionary<AocStep,(double valueCsm, double valueLc)> csmLcSwitchBenchmark)",
"\n{",
"\n Activity.Start();",
"\n //Save test input data",
"\n await Workspace.UpdateAsync<IfrsVariable>(inputDataSet);",
"\n ",
Expand Down Expand Up @@ -154,6 +155,7 @@
"\n }",
"\n ",
"\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));",
"\n return Activity.Finish();",
"\n}"
],
"metadata": {},
Expand Down Expand Up @@ -214,7 +216,17 @@
"\n {new AocStep(\"EOP\",\"C\"),(146.5d, 0d)},",
"\n };",
"\n",
"\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);"
"\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand All @@ -240,7 +252,17 @@
"\n {new AocStep(\"EOP\",\"C\"),(29d, 0d)},",
"\n };",
"\n",
"\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);"
"\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down Expand Up @@ -279,7 +301,17 @@
"\n {new AocStep(\"EOP\",\"C\"),( 11d, 0d)},",
"\n };",
"\n",
"\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);"
"\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);",
"\nactivity"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"activity.Status.Should().Be(ActivityLogStatus.Succeeded);"
],
"metadata": {},
"execution_count": 0,
Expand Down
Loading