public void BenchmarkBuildFinancialSecurityManager() { Start(); for (int i = 0; i < ITERATION; i++) { FinancialSecurityManager manager = FinancialSecurityManagerBuilder.BuildFinancialSecurityManager (StressTestHelper.BuildConfiguration()); Assert.IsNotNull(manager, "the BuildFinancialSecurityManager() is wrong."); } Stop("Run FinancialSecurityManagerBuilder.BuildFinancialSecurityManager() "); }
public void TestBuildFinancialSecurityManager_Null_configuration() { try { FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(null); } catch (Exception e) { Assert.IsTrue(e.InnerException is ArgumentNullException, "Inner exception should be ArgumentNullException"); throw e; } }
public void TestBuildFinancialSecurityManager_invalid_security_data_combiner_key() { try { IConfiguration configuration = GetConfigObject(); configuration.SetSimpleAttribute("security_data_combiner_key", "invalid"); FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(configuration); } catch (Exception e) { Assert.IsTrue(e.InnerException is ConfigurationErrorsException, "Inner exception should be ConfigurationErrorsException"); throw e; } }
public void TestBuildFinancialSecurityManager_Null_security_data_cache_key() { try { IConfiguration configuration = GetConfigObject(); configuration.RemoveAttribute("security_data_cache_key"); FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(configuration); } catch (Exception e) { Assert.IsTrue(e.InnerException is ConfigurationErrorsException, "Inner exception should be ConfigurationErrorsException"); throw e; } }
public void TestBuildFinancialSecurityManager_zero_security_lookup_service_keys() { try { IConfiguration configuration = GetConfigObject(); configuration.SetAttribute("security_id_types", new string[] { }); configuration.SetAttribute("security_lookup_service_keys", new string[] { }); FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(configuration); } catch (Exception e) { Assert.IsTrue(e.InnerException is ConfigurationErrorsException, "Inner exception should be ConfigurationErrorsException"); throw e; } }
public void BuildFinancialSecurityManager_OptionConfig() { IConfiguration config = AccuracyTestsTestHelper.GetConfigObject(); // the security_id_parser_key value is optional. config.RemoveAttribute("security_id_parser_key"); FinancialSecurityManager manager = FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(config); Assert.IsNotNull(manager, "The build method should work well."); // 1 get the idParser to test the builder. ISecurityIdParser idParser = (ISecurityIdParser)AccuracyTestsTestHelper.getPrivateField(manager, "securityIdParser"); // this idParser should be not null. Assert.IsNotNull(idParser, "The build method should work well."); // 2 get the lookupServices to test the builder. IDictionary <string, ISecurityLookupService> lookupServices = (IDictionary <string, ISecurityLookupService>) AccuracyTestsTestHelper.getPrivateField(manager, "securityLookupServices"); Assert.AreEqual(2, lookupServices.Count, "Should have 2 element"); Assert.IsTrue(lookupServices.ContainsKey(SecurityIdType.CUSIP), "Should have this lookupService name"); Assert.IsTrue(lookupServices.ContainsKey(SecurityIdType.ISIN), "Should have this lookupService name"); // 3 get the recursive to test the builder. bool recursive = (bool)AccuracyTestsTestHelper.getPrivateField(manager, "recursiveLookup"); Assert.IsFalse(recursive, "Should set to false"); // 4 get the recursive to test the builder. bool reference = (bool)AccuracyTestsTestHelper.getPrivateField(manager, "referenceLookup"); Assert.IsTrue(reference, "Should set to true"); // 5 get the combiner to test the builder. ISecurityDataCombiner combiner = (ISecurityDataCombiner) AccuracyTestsTestHelper.getPrivateField(manager, "securityDataCombiner"); SecurityData data1 = new SecurityData("1", "TopCoder", new string[] { "1", "2", "3" }); SecurityData data2 = new SecurityData("2", "IBM", new string[] { "4", "2", "3" }); SecurityData result = combiner.Combine(data1, data2); // get the property to test the method. Assert.AreEqual("1", result.Id, "The Id property should be set to '1'."); Assert.AreEqual("TopCoder", result.CompanyName, "The CompanyName property should be set to 'TopCoder'."); }