Example #1
0
        public void Lookup_SymbolTicker3_LookA()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, false, false, cache);
            // lookup security data by security id
            // (securityId = "A", so it is a NYSE)
            SecurityData data = test.Lookup("A");

            CheckData_SymbolTicker1_LookA(data, "A");

            // first we check the number of elements in  the cache.
            Assert.AreEqual(3, cache.GetCache().Count, "The cache should only have 3 element.");

            // check the cache key : A
            Object record     = cache["A"];
            bool   isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");

            Assert.IsTrue(isLookedUp, "The IsLookedUp tag should be set well");
            SecurityData recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");

            CheckData_SymbolTicker1_LookA(recordData, "A");

            // check the cache key : B
            record     = cache["B"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookA(recordData, "B");

            // check the cache key : C
            record     = cache["C"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookA(recordData, "C");
        }
Example #2
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'.");
        }
Example #3
0
        public void Lookup_SymbolTicker1_LookAAndB()
        {
            // lookup security data by security id
            // (securityId = "A", so it is a NYSE)
            test.Lookup("A");
            SecurityData data = test.Lookup("B");

            CheckData_SymbolTicker1_LookAAndB(data, "B");

            // first we check the number of elements in  the cache.
            Assert.AreEqual(4, cache.GetCache().Count, "The cache should only have 4 element.");

            // check the cache key : A
            Object record     = cache["A"];
            bool   isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");

            Assert.IsTrue(isLookedUp, "The IsLookedUp tag should be set well");
            SecurityData recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");

            CheckData_SymbolTicker1_LookAAndB(recordData, "A");

            // check the cache key : B
            record     = cache["B"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsTrue(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookAAndB(recordData, "B");

            // check the cache key : C
            record     = cache["C"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookAAndB(recordData, "C");

            //  check the cache key : D
            record     = cache["D"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookAAndB(recordData, "D");
        }