示例#1
0
        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'.");
        }