From 1abf84337fbe57c18e2b58f855bee8ffee7b1f4b Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 14 Jul 2020 11:53:48 -0500 Subject: [PATCH] include Sim ContractSpecs in tick unit tests --- ...ContractSpecifications.contract_spec_proto | Bin 0 -> 633 bytes .../spark_test/Security/SecurityTests.cs | 23 +++++++++++++----- src/client/spark_test/spark_test.csproj | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 src/client/spark_test/Resources/SimContractSpecifications.contract_spec_proto diff --git a/src/client/spark_test/Resources/SimContractSpecifications.contract_spec_proto b/src/client/spark_test/Resources/SimContractSpecifications.contract_spec_proto new file mode 100644 index 0000000000000000000000000000000000000000..5cb718ce9d4d7665ebcb8cf05b0965da8240ee26 GIT binary patch literal 633 zcmY!nWB`K;_8%ExtbKTsV+#|NM~U1yos zkIbZi=D}Fl)EPkSodCCYf;~2M5118RFf)B%W>&}J&`1;q%$f-TJAnqnSTGNP)WO7H z9!deKgLo(f=75gHC?1FCSP3_8B}^RyY5+mh&4jC)30GGMH1E&KkC%Lt0_=66{#XE1 z2MM$VFm)&a3H0~}W+s>`OW>|7fvHAwCB&=;a8nO1^{!=vE2Xw literal 0 HcmV?d00001 diff --git a/src/client/spark_test/Security/SecurityTests.cs b/src/client/spark_test/Security/SecurityTests.cs index 8d448a32f..da6a864a5 100644 --- a/src/client/spark_test/Security/SecurityTests.cs +++ b/src/client/spark_test/Security/SecurityTests.cs @@ -38,12 +38,11 @@ namespace bts.tests.security { [Test] public void test_ticks() { - foreach (var file_path in SecurityFiles.all()) { - var ticks = read_securities(file_path).Select(s => s.ContractSpec).Distinct().ToList(); - foreach (var tick in ticks) { - _test_ticks(tick); - } - } + var from_sec_files = SecurityFiles.all().SelectMany(read_securities).Select(s => s.ContractSpec); + var from_spec_files = ContractSpecificationFiles.all().SelectMany(read_contract_specs); + var distinct_specs = new HashSet(from_sec_files.Concat(from_spec_files)); + foreach (var spec in distinct_specs) + _test_ticks(spec); } void _test_ticks(ContractSpecificationImmutable tick) { @@ -84,6 +83,9 @@ namespace bts.tests.security { ComparisonTests.identity_comparison(sec_list, SecurityHelper.Comparer.InstanceImmutable); } + public static IEnumerable read_contract_specs(string file_path) => + StreamHelper.ReadProtos(ResourceHelper.LoadResource(file_path)).Select(s => new ContractSpecificationImmutable(s)); + public static IEnumerable read_securities(string file_path) => StreamHelper.ReadProtos(ResourceHelper.LoadResource(file_path)).Select(s => new SecurityImmutable(s)); @@ -97,5 +99,14 @@ namespace bts.tests.security { yield return NonDeterministicICEFutures; } } + + public static class ContractSpecificationFiles { + public const string + Sim = "SimContractSpecifications.contract_spec_proto"; + + public static IEnumerable all() { + yield return Sim; + } + } } } diff --git a/src/client/spark_test/spark_test.csproj b/src/client/spark_test/spark_test.csproj index 01a4a5d11..114d47039 100644 --- a/src/client/spark_test/spark_test.csproj +++ b/src/client/spark_test/spark_test.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -17,5 +17,6 @@ +