From 95c406137c4e52cd3ba99cbba67e8a8a9bcc686f Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 11:16:06 +0100 Subject: [PATCH 1/9] Add non-zero count checks in SequenceImportTest --- ifrs17-template/Test/SequenceImportTest.ipynb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index 1b9b3bcf..493fc333 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -159,7 +159,16 @@ { "cell_type": "code", "source": [ - "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance()).Count().Should().Be(0);" + "ifrsVars1.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrsVars2.Count().Should().NotBe(0);" ], "metadata": {}, "execution_count": 0, @@ -168,7 +177,7 @@ { "cell_type": "code", "source": [ - "" + "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance()).Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, From d41db42f65c8343dfa324fbd06b8e94d7b32bd6b Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 11:42:02 +0100 Subject: [PATCH 2/9] Empty cell --- ifrs17-template/Test/SequenceImportTest.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index 493fc333..8a1b0187 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -182,6 +182,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file From b4b9ba527b5e970047e37565de6a69449b630866 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 13:10:33 +0100 Subject: [PATCH 3/9] Add ApplicationMessage log in ReportVariablesTest --- ifrs17-template/Test/ReportVariablesTest.ipynb | 4 +++- ifrs17-template/Test/ReportVariablesTestBase.ipynb | 3 ++- ifrs17/Utils/ApplicationMessage.ipynb | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ifrs17-template/Test/ReportVariablesTest.ipynb b/ifrs17-template/Test/ReportVariablesTest.ipynb index 978d2a5e..6a145be3 100644 --- a/ifrs17-template/Test/ReportVariablesTest.ipynb +++ b/ifrs17-template/Test/ReportVariablesTest.ipynb @@ -131,8 +131,9 @@ { "cell_type": "code", "source": [ - "public async Task RunTestAsync () ", + "public async Task RunTestAsync () ", "\n{", + "\n Activity.Start();", "\n scopesData = await GetScopesDataAsync(args, reportStorage, Scopes);", "\n benchmarkData = await GetBenchmarkDataAsync(args, path, Workspace, Import);", "\n", @@ -145,6 +146,7 @@ "\n //.Excluding(o => o.Value)", "\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, BenchmarkPrecision))", "\n .WhenTypeIs() );", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, diff --git a/ifrs17-template/Test/ReportVariablesTestBase.ipynb b/ifrs17-template/Test/ReportVariablesTestBase.ipynb index 36d07af7..a41671c0 100644 --- a/ifrs17-template/Test/ReportVariablesTestBase.ipynb +++ b/ifrs17-template/Test/ReportVariablesTestBase.ipynb @@ -146,7 +146,8 @@ "static async Task> 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(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Period.Year, Month = args.Period.Month });", - "\n await importVariable.FromFile(path + bmFileName).WithType(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();", + "\n var log = await importVariable.FromFile(path + bmFileName).WithType(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();", + "\n ApplicationMessage.Log(log);", "\n var ret = await workspace.Query().ToArrayAsync();", "\n workspace.Reset(x => x.ResetCurrentPartitions().ResetType());", "\n return ret;", diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index e261b4a6..990dd62b 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -56,6 +56,12 @@ "\n public static Object Log (Error e, params string[] s) { log.LogError(Get(e,s)); return null; }", "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(Get(w,s)); return null; }", "\n ", + "\n public static Object Log (ActivityLog activityLog) {", + "\n foreach(var error in activityLog.Errors) log.LogError(error.ToString());", + "\n foreach(var warning in activityLog.Warnings) log.LogWarning(warning.ToString());", + "\n return null;", + "\n }", + "\n ", "\n public static bool HasErrors () => activity.HasErrors();", "\n public static bool HasWarnings () => activity.HasWarnings();", "\n}" From a20c114146a8cc5cf564862e100038a6008af020 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 18:22:30 +0100 Subject: [PATCH 4/9] Implement ActivityLog in: ImportStorageTest, MapTemplateAndImportTest, ReportStorageTest --- ifrs17-template/Test/ImportStorageTest.ipynb | 148 ++++++++++++++++-- .../Test/MapTemplateAndImportTest.ipynb | 23 ++- ifrs17-template/Test/ReportStorageTest.ipynb | 16 +- ifrs17/DataModel/DataStructure.ipynb | 2 + 4 files changed, 168 insertions(+), 21 deletions(-) diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index 24387d42..4dd24ad4 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -102,8 +102,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark)", + "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark)", "\n{", + "\n Activity.Start();", "\n //Prepare Workspace and DataSource", "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", @@ -132,6 +133,7 @@ "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -160,7 +162,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -193,7 +205,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -228,7 +250,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, EstimateType = EstimateTypes.AA, Novelty = Novelties.C, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -271,7 +303,17 @@ "\n basicAdvanceActualIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -324,7 +366,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -455,8 +507,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetUnderlyingGicsAsync(RawVariable[] inputDataVariable, Dictionary> underlyingGicBm)", + "public async Task CheckGetUnderlyingGicsAsync(RawVariable[] inputDataVariable, Dictionary> underlyingGicBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n ", "\n await PrepareWorkspaceDataNodes();", @@ -476,6 +529,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -493,7 +547,17 @@ "\n {\"Reins2\",new string[]{\"Gross1\",\"Gross2\"}},", "\n};", "\n", - "\nawait CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);" + "\nvar activity = await CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -508,7 +572,17 @@ "\n {\"Reins2\",new string[]{\"Gross1\",\"Gross2\"}},", "\n};", "\n", - "\nawait CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);" + "\nvar activity = await CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -526,10 +600,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetReinsuranceCoverageAsync(RawVariable[] inputDataVariable, ", + "public async Task CheckGetReinsuranceCoverageAsync(RawVariable[] inputDataVariable, ", "\n Dictionary<(string, string),double> reinsCovBoPBm, ", "\n Dictionary<(string, string),double> reinsCovEoPBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n", "\n await PrepareWorkspaceDataNodes();", @@ -566,6 +641,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -590,7 +666,17 @@ "\n {(\"Reins2\",\"Gross2\"),0.7},", "\n};", "\n", - "\nawait CheckGetReinsuranceCoverageAsync(inputDataVariable, reinsCovBoPBm, reinsCovEoPBm);" + "\nvar activity = await CheckGetReinsuranceCoverageAsync(inputDataVariable, reinsCovBoPBm, reinsCovEoPBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -608,8 +694,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckSecondaryScopeAsync(RawVariable[] inputDataVariable, string[] primaryScopeBm, string[] secondaryScopeBm)", + "public async Task CheckSecondaryScopeAsync(RawVariable[] inputDataVariable, string[] primaryScopeBm, string[] secondaryScopeBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n ", "\n await PrepareWorkspaceDataNodes();", @@ -639,6 +726,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -653,7 +741,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\", \"Reins2\"};", "\nvar secondaryScopeBm = new string[]{\"Gross1\", \"Gross2\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -666,7 +764,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\"};", "\nvar secondaryScopeBm = new string[]{\"Gross1\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -680,7 +788,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\",\"Gross1\",\"Reins2\"};", "\nvar secondaryScopeBm = new string[]{\"Gross2\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index f06f2428..fa38033b 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -246,7 +246,8 @@ { "cell_type": "code", "source": [ - "static var partition = new PartitionByReportingNodeAndPeriod() { ReportingNode = \"CH\", Year = 2021, Month = 3 };", + "using System.ComponentModel.DataAnnotations;", + "\nstatic var partition = new PartitionByReportingNodeAndPeriod() { ReportingNode = \"CH\", Year = 2021, Month = 3 };", "\nstatic var filename = \"TestMapTemplateDataNodeState\";", "\n", "\nWorkspace.InitializeFrom(DataSource);", @@ -267,7 +268,11 @@ "\n .MainTabConfigurationWoScenario(partition)", "\n.ExecuteAsync();", "\n", - "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" + "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);", + "\n", + "\nvar partitionResult = new List();", + "\nValidator.TryValidateObject(partition, new ValidationContext(partition), partitionResult, true);", + "\npartitionResult" ], "metadata": {}, "execution_count": 0, @@ -464,7 +469,12 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\nActivity.HasErrors().Should().Be(true);", "\nvar log = Activity.Finish().Errors.First().ToString().Substring(40);", - "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);" + "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);", + "\n", + "\nvar instances = new DataNodeState[] {itemInactive, itemActive};", + "\nvar itemResults = new List();", + "\nforeach (var instance in instances) Validator.TryValidateObject(instance, new ValidationContext(instance), itemResults, true);", + "\nitemResults" ], "metadata": {}, "execution_count": 0, @@ -510,7 +520,12 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\n", "\n// Check that the new redundant State is removed from the Workspace", - "\nWorkspace.Query().ToArray().Should().BeEmpty();" + "\nWorkspace.Query().ToArray().Should().BeEmpty();", + "\n", + "\nvar instances = new DataNodeState[] {itemPrevious, itemImport};", + "\nvar itemResults = new List();", + "\nforeach (var instance in instances) Validator.TryValidateObject(instance, new ValidationContext(instance), itemResults, true);", + "\nitemResults" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 851ea575..ae144950 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -77,14 +77,26 @@ { "cell_type": "code", "source": [ - "var testData = new ExchangeRate[] {new ExchangeRate{ Currency = \"EUR\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 10 }, ", + "using System.ComponentModel.DataAnnotations;", + "\nvar testData = new ExchangeRate[] {new ExchangeRate{ Currency = \"EUR\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 10 }, ", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 3, FxType = FxType.Spot, FxToGroupCurrency = 15 },", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 20 },", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 30 },", "\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 testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 3e6144ff..2672b4d8 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1301,10 +1301,12 @@ "public record PartitionByReportingNodeAndPeriod : IfrsPartition {", "\n [Dimension(typeof(int), nameof(Year))]", "\n [IdentityProperty]", + "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", "\n public int Year { get; init; }", "\n", "\n [Dimension(typeof(int), nameof(Month))]", "\n [IdentityProperty]", + "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", "\n public int Month { get; init; }", "\n}" ], From ccc8e6564b3a2d6029fb7e016304f2f4afdf63f1 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 21:44:10 +0100 Subject: [PATCH 5/9] Undo year and month checking in MapTemplateAndImportTest --- .../Test/MapTemplateAndImportTest.ipynb | 36 +++++++------------ ifrs17/DataModel/DataStructure.ipynb | 2 -- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index fa38033b..cd6603fd 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -246,8 +246,7 @@ { "cell_type": "code", "source": [ - "using System.ComponentModel.DataAnnotations;", - "\nstatic var partition = new PartitionByReportingNodeAndPeriod() { ReportingNode = \"CH\", Year = 2021, Month = 3 };", + "static var partition = new PartitionByReportingNodeAndPeriod() { ReportingNode = \"CH\", Year = 2021, Month = 3 };", "\nstatic var filename = \"TestMapTemplateDataNodeState\";", "\n", "\nWorkspace.InitializeFrom(DataSource);", @@ -268,11 +267,7 @@ "\n .MainTabConfigurationWoScenario(partition)", "\n.ExecuteAsync();", "\n", - "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);", - "\n", - "\nvar partitionResult = new List();", - "\nValidator.TryValidateObject(partition, new ValidationContext(partition), partitionResult, true);", - "\npartitionResult" + "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -469,12 +464,7 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\nActivity.HasErrors().Should().Be(true);", "\nvar log = Activity.Finish().Errors.First().ToString().Substring(40);", - "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);", - "\n", - "\nvar instances = new DataNodeState[] {itemInactive, itemActive};", - "\nvar itemResults = new List();", - "\nforeach (var instance in instances) Validator.TryValidateObject(instance, new ValidationContext(instance), itemResults, true);", - "\nitemResults" + "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -520,12 +510,7 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\n", "\n// Check that the new redundant State is removed from the Workspace", - "\nWorkspace.Query().ToArray().Should().BeEmpty();", - "\n", - "\nvar instances = new DataNodeState[] {itemPrevious, itemImport};", - "\nvar itemResults = new List();", - "\nforeach (var instance in instances) Validator.TryValidateObject(instance, new ValidationContext(instance), itemResults, true);", - "\nitemResults" + "\nWorkspace.Query().ToArray().Should().BeEmpty();" ], "metadata": {}, "execution_count": 0, @@ -552,11 +537,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckErrors(string inputFileName, List errorBms)", + "public async Task CheckErrors(string inputFileName, List 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": {}, @@ -570,7 +557,8 @@ "\nvar errorsBm = new List(){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, @@ -582,7 +570,8 @@ "var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";", "\nvar errorsBm = new List(){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, @@ -593,7 +582,8 @@ "source": [ "var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";", "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};", - "\nawait CheckErrors(inputFileName, errorsBm);" + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 2672b4d8..3e6144ff 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1301,12 +1301,10 @@ "public record PartitionByReportingNodeAndPeriod : IfrsPartition {", "\n [Dimension(typeof(int), nameof(Year))]", "\n [IdentityProperty]", - "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", "\n public int Year { get; init; }", "\n", "\n [Dimension(typeof(int), nameof(Month))]", "\n [IdentityProperty]", - "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", "\n public int Month { get; init; }", "\n}" ], From a67b2802a0c2eb06d7009ee8ce77b9f2f56c58a9 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 21:46:35 +0100 Subject: [PATCH 6/9] Check year and month entries in YieldCurves and apply ActivityLog in QueriesTest --- ifrs17/Test/QueriesTest.ipynb | 405 +++++++++++++++++++++++++++++++--- 1 file changed, 377 insertions(+), 28 deletions(-) diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index a3f67136..96b6fb5d 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -57,10 +57,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(Args args, IEnumerable testData, ", "\n (int Year, int Month, string Scenario) expectedCurrentPeriod, ", "\n (int Year, int Month, string Scenario) expectedPreviousPeriod)", "\n{", + "\n Activity.Start();", "\n await Workspace.UpdateAsync(testData);", "\n var eurCurrentAndPreviousYieldCurve = (await Workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Currency))[\"EUR\"];", "\n ", @@ -75,6 +76,7 @@ "\n eurCurrentAndPreviousYieldCurve[PreviousPeriod].Scenario.Should().Be(expectedPreviousPeriod.Scenario);", "\n ", "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -86,7 +88,17 @@ "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, null),(2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, null),(2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -98,7 +110,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new[] { new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9 } };", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario),(2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario),(2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -109,7 +131,17 @@ "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12, null), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -121,7 +153,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -133,7 +175,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -145,7 +197,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -157,7 +219,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2019, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2019, 3, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -169,7 +241,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -181,7 +263,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2019, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2019, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -190,11 +282,33 @@ { "cell_type": "code", "source": [ - "var args = new Args(\"EUR\",2020,9,Periodicity.Monthly,scenario);", + "using System.ComponentModel.DataAnnotations;", + "\nvar args = new Args(\"EUR\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -206,7 +320,28 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -218,7 +353,28 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -231,7 +387,28 @@ "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -245,7 +422,28 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -259,7 +457,28 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2015, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -274,7 +493,28 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2021, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", "\n", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -292,8 +532,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadDataNodeStateAsync(Args args, IEnumerable testData, bool isExpectedToBeActive)", + "public async Task CheckLoadDataNodeStateAsync(Args args, IEnumerable testData, bool isExpectedToBeActive)", "\n{", + "\n Activity.Start();", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", "\n var isActive = (await Workspace.LoadDataNodeStateAsync(args)).Keys.Contains(gic);", @@ -301,6 +542,7 @@ "\n isActive.Should().Be(isExpectedToBeActive);", "\n ", "\n Workspace.Reset(x => x.ResetCurrentPartitions());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -313,7 +555,28 @@ "var args = new Args(\"CH\",2020,12,Periodicity.Monthly,null);", "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2019, Month = 12, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 6, State = State.Inactive }};", - "\nawait CheckLoadDataNodeStateAsync(args, testData, false);" + "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -325,7 +588,28 @@ "var args = new Args(\"CH\",2020,12,Periodicity.Monthly,null);", "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2020, Month = 3, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 9, State = State.Inactive }};", - "\nawait CheckLoadDataNodeStateAsync(args, testData, false);" + "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -343,12 +627,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadYieldCurveAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadYieldCurveAsync(Args args, IEnumerable testData, ", "\n (int year , int month) dataNodeYearAndMonth, ", "\n double expectedCurrentPreviousFirstYcValue,", "\n double expectedCurrentFirstYcValue,", "\n double expectedLockedFirstYcValue)", "\n{", + "\n Activity.Start();", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", "\n await Workspace.UpdateAsync(new ReportingNode[]{new ReportingNode{Currency=\"EUR\",SystemName=\"CH\"}});", @@ -373,6 +658,7 @@ "\n errors.Add( $\"LockedIn YieldCurve not matching:\\n Expected {expectedLockedFirstYcValue} \\n Computed {lockedYc}.\" );", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors)); ", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -388,7 +674,28 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2021, Month = 9, Values = new double[]{4.1,4.2,4.3,4.4,4.5,4.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", - "\nawait CheckLoadYieldCurveAsync(args, testData, (2016, 6), 6.1, 0.1, 6.1);" + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, (2016, 6), 6.1, 0.1, 6.1);", + "\nvar testDataResults = new List();", + "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", + "\ntestDataResults" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -417,10 +724,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadInterDataNodeParameterAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadInterDataNodeParameterAsync(Args args, IEnumerable testData, ", "\n int previousYear,", "\n int? currentYear = null)", "\n{", + "\n Activity.Start();", "\n currentYear = currentYear ?? previousYear;", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", @@ -500,6 +808,7 @@ "\n Workspace.Reset(x => x.ResetCurrentPartitions());", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -517,7 +826,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)previousYear)/1000, Year = previousYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -538,7 +857,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)currentYear)/1000, Year = currentYear, Month = 9}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -556,7 +885,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)previousYear)/1000, Year = previousYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -574,7 +913,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)currentYear)/1000, Year = currentYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, From efb6aee4f28d85fa7669b5162ef75fece5ef2f84 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 13 Dec 2022 21:47:30 +0100 Subject: [PATCH 7/9] Apply ActivityLogs in AocStructureTest, ReportStorageTest, ReportVariablesTest and TechnicalMarginTest --- ifrs17-template/Test/AocStructureTest.ipynb | 40 +++++++++++++++++-- ifrs17-template/Test/ReportStorageTest.ipynb | 16 +++++++- .../Test/ReportVariablesTest.ipynb | 36 +++++++++++++++-- .../Test/TechnicalMarginTest.ipynb | 40 +++++++++++++++++-- 4 files changed, 119 insertions(+), 13 deletions(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 91bf53b8..b52e9153 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -94,12 +94,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckAocStepStructureAsync(IEnumerable inputVariables, ", + "public async Task CheckAocStepStructureAsync(IEnumerable inputVariables, ", "\n Dictionary> parentBm, ", "\n Dictionary referenceBm, ", "\n Dictionary> fullAocBm,", "\n Dictionary> parentBmCdr = null)", "\n{", + "\n Activity.Start();", "\n //Save test input data", "\n var importFormat = ImportFormats.Cashflow;", "\n var inputSource = InputSource.Cashflow;", @@ -232,6 +233,7 @@ "\n }", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}", "\n" ], @@ -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, @@ -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, @@ -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, diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index ae144950..caf0ef82 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -48,8 +48,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)", + "public async Task CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)", "\n{", + "\n Activity.Start();", "\n await Workspace.UpdateAsync(testData);", "\n ", "\n //Create report storage", @@ -68,6 +69,7 @@ "\n fxEOP.Should().Be(fxEOPBenchmark);", "\n ", "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -96,7 +98,17 @@ { "cell_type": "code", "source": [ - "await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60)" + "var 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, diff --git a/ifrs17-template/Test/ReportVariablesTest.ipynb b/ifrs17-template/Test/ReportVariablesTest.ipynb index 6a145be3..1ed77b94 100644 --- a/ifrs17-template/Test/ReportVariablesTest.ipynb +++ b/ifrs17-template/Test/ReportVariablesTest.ipynb @@ -175,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, @@ -194,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, @@ -213,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, diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17-template/Test/TechnicalMarginTest.ipynb index 1407c020..8d0d4f34 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17-template/Test/TechnicalMarginTest.ipynb @@ -90,8 +90,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckSwitchLogicAsync(IEnumerable inputDataSet, Dictionary csmLcSwitchBenchmark)", + "public async Task CheckSwitchLogicAsync(IEnumerable inputDataSet, Dictionary csmLcSwitchBenchmark)", "\n{", + "\n Activity.Start();", "\n //Save test input data", "\n await Workspace.UpdateAsync(inputDataSet);", "\n ", @@ -154,6 +155,7 @@ "\n }", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -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, @@ -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, @@ -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, From b49df930babb1203faf6cb52d8d17bdc6f0b2cdc Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Wed, 14 Dec 2022 11:34:30 +0100 Subject: [PATCH 8/9] Implement feedback --- ifrs17-template/Test/ReportStorageTest.ipynb | 16 +-- ifrs17/Test/QueriesTest.ipynb | 133 ++----------------- 2 files changed, 13 insertions(+), 136 deletions(-) diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index caf0ef82..0f49a5d2 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -79,26 +79,14 @@ { "cell_type": "code", "source": [ - "using System.ComponentModel.DataAnnotations;", - "\nvar testData = new ExchangeRate[] {new ExchangeRate{ Currency = \"EUR\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 10 }, ", + "var testData = new ExchangeRate[] {new ExchangeRate{ Currency = \"EUR\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 10 }, ", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 3, FxType = FxType.Spot, FxToGroupCurrency = 15 },", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 20 },", "\n new ExchangeRate{ Currency = \"EUR\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 30 },", "\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 }};", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", + "\nvar activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index 96b6fb5d..0bf6dc5d 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -282,24 +282,12 @@ { "cell_type": "code", "source": [ - "using System.ComponentModel.DataAnnotations;", - "\nvar args = new Args(\"EUR\",2020,9,Periodicity.Monthly,scenario);", + "var args = new Args(\"EUR\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -321,18 +309,7 @@ "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -354,18 +331,7 @@ "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 9, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -388,18 +354,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -423,18 +378,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -458,18 +402,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2015, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -494,18 +427,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", "\n", "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -556,18 +478,7 @@ "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2019, Month = 12, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 6, State = State.Inactive }};", "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -589,18 +500,7 @@ "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2020, Month = 3, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 9, State = State.Inactive }};", "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -675,18 +575,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, (2016, 6), 6.1, 0.1, 6.1);", - "\nvar testDataResults = new List();", - "\nforeach (var instance in testData) Validator.TryValidateObject(instance, new ValidationContext(instance), testDataResults, true);", - "\ntestDataResults" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "activity" + "\nactivity" ], "metadata": {}, "execution_count": 0, From f92b8609ae35fea16df392891ced5e9d8c6c9948 Mon Sep 17 00:00:00 2001 From: Sara Busato Date: Wed, 14 Dec 2022 17:23:30 +0100 Subject: [PATCH 9/9] fixed ImportStorageTest --- ifrs17-template/Test/ImportStorageTest.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index 4dd24ad4..19b809b5 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -82,16 +82,16 @@ "//Define partition", "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", "\n ReportingNode = reportingNode, ", "\n Scenario = scenario, ", "\n Year = args.Year,", "\n Month = args.Month };", - "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", + "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", "\n ReportingNode = reportingNode, ", "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month };", "\nawait DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", "\nawait DataSource.CommitAsync();" ],