Пример #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");
        }
Пример #2
0
        public void Lookup_SymbolTicker3_LookAAndB()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, false, false, cache);
            test.Lookup("A");
            SecurityData data = test.Lookup("B");

            CheckData_SymbolTicker1_LookA(data, "B");
        }
Пример #3
0
        public void Lookup_SymbolTicker2_IdDetails_True()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, true, true, cache);
            test.Lookup("A");
            SecurityData data = test.Lookup(test.Parse("B"));

            CheckData_SymbolTicker1_LookAAndB(data, "B");
        }
Пример #4
0
 public void SetUp()
 {
     idParser       = new DefaultSecurityIdParser();
     lookupServices = new Dictionary <string, ISecurityLookupService>();
     lookupServices.Add(SecurityIdType.SymbolTicker, new SimpleSecurityLookupService());
     combiner = new DefaultSecurityDataCombiner();
     cache    = new SimpleCache();
     test     = new FinancialSecurityManager(idParser, lookupServices, combiner, false, true, cache);
 }
Пример #5
0
        public void FinancialSecurityManager_Ctor1()
        {
            test = new FinancialSecurityManager(lookupServices, combiner, true, false, cache);
            Assert.IsNotNull(test, "The ctor should work well.");

            SecurityIdDetails details = test.Parse("037833100");

            // get the property to test the method.
            Assert.AreEqual("037833100", details.Id, "The Id property should be set to '037833100'.");
            Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'.");
        }
Пример #6
0
 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() ");
 }
 protected void SetUp()
 {
     parser                 = new DefaultSecurityIdParser();
     combiner               = new DefaultSecurityDataCombiner();
     lookupService          = new SecurityLookupServiceMock();
     dataCache              = new SimpleCache(3, new FIFOCacheEvictionStrategy(), TimeSpan.FromSeconds(10));
     securityLookupServices = new Dictionary <string, ISecurityLookupService>();
     securityLookupServices[SecurityIdType.CUSIP]        = lookupService;
     securityLookupServices[SecurityIdType.ISIN]         = lookupService;
     securityLookupServices[SecurityIdType.SEDOL]        = lookupService;
     securityLookupServices[SecurityIdType.SymbolTicker] = lookupService;
     instance = new FinancialSecurityManager(securityLookupServices, combiner, true, true, dataCache);
 }
Пример #8
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'.");
        }
        public void SetUp()
        {
            IDictionary <string, ISecurityLookupService> securityLookupServices =
                new Dictionary <string, ISecurityLookupService>();

            securityLookupServices[SecurityIdType.CUSIP]        = new CustomSecurityLookupService();
            securityLookupServices[SecurityIdType.ISIN]         = new CustomSecurityLookupService();
            securityLookupServices[SecurityIdType.SEDOL]        = new CustomSecurityLookupService();
            securityLookupServices[SecurityIdType.SymbolTicker] =
                new CustomSecurityLookupService();

            ICache cache = new SimpleCache();

            manager = new FinancialSecurityManager(new DefaultSecurityIdParser(),
                                                   securityLookupServices,
                                                   new DefaultSecurityDataCombiner(),
                                                   true, false, cache);
        }
Пример #10
0
 public void TearDown()
 {
     test = null;
 }
 public void TearDown()
 {
     manager = null;
 }