コード例 #1
0
 public void TearDown()
 {
     fsm = null;
     securityLookupServices = null;
     combiner = null;
     parser   = null;
     cache    = null;
 }
コード例 #2
0
ファイル: Demo.cs プロジェクト: kurtrips/tc
        public void DemoFinancialSecurityManagerBuilder()
        {
            //Get IConfiguration object either by preparing it manually or
            //by using File Based Configuration TCS component
            IConfiguration config = UnitTestHelper.GetConfigObject();

            //Create the FinancialSecurityManager instance from IConfiguration
            FinancialSecurityManager fsm = FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(config);
        }
コード例 #3
0
        public void TestLookupRecursive2()
        {
            fsm = new FinancialSecurityManager(securityLookupServices, combiner, true, false, cache);

            //Lookup using X
            SecurityData securityData = fsm.Lookup("X");

            //Returned data must have reference ids X,Y
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "X", "Y" }),
                          "Wrong Lookup implementation.");
        }
コード例 #4
0
 public void TestConstructorFail4()
 {
     try
     {
         fsm = new FinancialSecurityManager(parser, securityLookupServices, combiner, false, true, null);
     }
     catch (Exception e)
     {
         Assert.IsTrue(e is SelfDocumentingException, "SelfDocumentingException is expected.");
         Assert.IsTrue(e.InnerException is ArgumentNullException, "ArgumentNullException is expected.");
     }
 }
コード例 #5
0
 public void TestConstructorFail6()
 {
     try
     {
         securityLookupServices.Add("         ", new CustomSecurityLookupService());
         fsm = new FinancialSecurityManager(parser, securityLookupServices, combiner, false, true, cache);
     }
     catch (Exception e)
     {
         Assert.IsTrue(e is SelfDocumentingException, "SelfDocumentingException is expected.");
         Assert.IsTrue(e.InnerException is ArgumentException, "ArgumentException is expected.");
     }
 }
コード例 #6
0
        public void TestLookupSimple1()
        {
            fsm = new FinancialSecurityManager(securityLookupServices, combiner, false, false, cache);

            //Lookup using A
            SecurityData securityData = fsm.Lookup("A");

            //Returned data must have reference ids A,B,C
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C" }),
                          "Wrong Lookup implementation.");

            ICache cacheField = (ICache)UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCache");

            UnitTestHelper.CheckSecurityDataRecord(cacheField, "A", new string[] { "A", "B", "C" }, true);
            UnitTestHelper.CheckSecurityDataRecord(cacheField, "B", new string[] { "A", "B", "C" }, false);
            UnitTestHelper.CheckSecurityDataRecord(cacheField, "C", new string[] { "A", "B", "C" }, false);
        }
コード例 #7
0
        public void TestBuildFinancialSecurityManager()
        {
            FinancialSecurityManager fsm =
                FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(config);

            //Check if objet has been created correctly.
            Assert.IsNotNull(UnitTestHelper.GetPrivateFieldValue(fsm, "securityIdParser"),
                             "Incorrect BuildFinancialSecurityManager implementation.");
            Assert.AreEqual((UnitTestHelper.GetPrivateFieldValue(fsm, "securityLookupServices")
                             as Dictionary <string, ISecurityLookupService>).Count, 2,
                            "Incorrect BuildFinancialSecurityManager implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "recursiveLookup"), true,
                            "Incorrect BuildFinancialSecurityManager implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "referenceLookup"), false,
                            "Incorrect BuildFinancialSecurityManager implementation.");
            Assert.IsNotNull(UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCache"),
                             "Incorrect BuildFinancialSecurityManager implementation.");
            Assert.IsNotNull(UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCombiner"),
                             "Incorrect BuildFinancialSecurityManager implementation.");
        }
コード例 #8
0
        public void TestConstructor2()
        {
            fsm = new FinancialSecurityManager(securityLookupServices, combiner, false, true, cache);

            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "recursiveLookup"), false,
                            "Incorrect constructor implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "referenceLookup"), true,
                            "Incorrect constructor implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCache"), cache,
                            "Incorrect constructor implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCombiner"), combiner,
                            "Incorrect constructor implementation.");

            //The securityLookupServices instances must not be equal as shallow copy should be created.
            Assert.AreNotEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "securityLookupServices"),
                               securityLookupServices, "Incorrect constructor implementation.");

            Assert.AreNotEqual(UnitTestHelper.GetPrivateFieldValue(fsm, "securityIdParser"), parser,
                               "Incorrect constructor implementation.");
        }
コード例 #9
0
        public void TestLookupRecursive3()
        {
            fsm = new FinancialSecurityManager(securityLookupServices, combiner, true, false, cache);

            //Lookup using X
            fsm.Lookup("X");

            //Lookup again using X
            SecurityData sdx = fsm.Lookup("X");

            //Lookup using Y
            SecurityData sdy = fsm.Lookup("Y");

            //The returned securityData for X must be the same one as that in cache.
            ICache cacheField = (ICache)UnitTestHelper.GetPrivateFieldValue(fsm, "securityDataCache");

            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(cacheField["X"], "securityData"), sdx,
                            "Wrong Lookup implementation.");
            Assert.AreEqual(UnitTestHelper.GetPrivateFieldValue(cacheField["Y"], "securityData"), sdy,
                            "Wrong Lookup implementation.");
        }
コード例 #10
0
        public void SetUp()
        {
            // create a dictionary holding the security id types to ISecurityLookupService
            // objects mappings
            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();

            //Create DefaultSecurityDataCombiner
            combiner = new DefaultSecurityDataCombiner();

            //Create cache
            cache = new SimpleCache();

            //Create DefaultSecurityIdParser
            parser = new DefaultSecurityIdParser();

            fsm = new FinancialSecurityManager(parser, securityLookupServices, combiner,
                                               false, true, cache);
        }
コード例 #11
0
 public void TestLookupFail4()
 {
     securityLookupServices.Remove(SecurityIdType.SymbolTicker);
     fsm = new FinancialSecurityManager(securityLookupServices, combiner, true, false, cache);
     fsm.Lookup("A");
 }
コード例 #12
0
ファイル: Demo.cs プロジェクト: kurtrips/tc
        public void DemoLookup()
        {
            //////////////REFERENCE LOOKUP DEMO
            fsm = new FinancialSecurityManager(securityLookupServices, combiner, false, true, cache);

            //Lookup using A. Returns A,B,C
            SecurityData securityData = fsm.Lookup("A");

            //Returned data must have reference ids A,B,C
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C" }),
                          "Wrong Lookup implementation.");

            //Now lookup using B
            securityData = fsm.Lookup("B");

            //Returned data must have reference ids A,B,C,D
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C", "D" }),
                          "Wrong Lookup implementation.");



            //////////////SIMPLE LOOKUP DEMO
            cache = new SimpleCache();
            fsm   = new FinancialSecurityManager(securityLookupServices, combiner, false, false, cache);

            //Lookup using A. Returns A,B,C
            securityData = fsm.Lookup("A");

            //Returned data must have reference ids A,B,C
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C" }),
                          "Wrong Lookup implementation.");

            //Now lookup using B
            securityData = fsm.Lookup("B");

            //Returned data must have reference ids A,B,C
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C" }),
                          "Wrong Lookup implementation.");



            //////////////RECURSIVE LOOKUP DEMO
            cache = new SimpleCache();
            fsm   = new FinancialSecurityManager(securityLookupServices, combiner, true, false, cache);

            //Lookup using A. Returns A,B,C,D
            securityData = fsm.Lookup("A");

            //Returned data must have reference ids A,B,C,D
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C", "D" }),
                          "Wrong Lookup implementation.");

            //Now lookup using B
            securityData = fsm.Lookup("B");

            //Returned data must have reference ids A,B,C,D
            Assert.IsTrue(UnitTestHelper.AreReferenceIdsEqual(
                              securityData.ReferenceIds, new string[] { "A", "B", "C", "D" }),
                          "Wrong Lookup implementation.");
        }