Exemple #1
0
 public void TestSerialisingInterfaceTypes()
 {
     // tests control of the serialisation type
     // - interface types
     using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
     {
         using (CoreServer server = new CoreServer(loggerRef, "UTT", NodeType.Router))
         {
             // start server
             server.Start();
             using (ICoreClient client = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
             {
                 AssetMeasureValue codeValueInstance = new AssetMeasureValue()
                 {
                     Code        = "Test",
                     Description = "This is a test",
                     Source      = "UnitTest"
                 };
                 IFpMLCodeValue codeValueInterface = codeValueInstance;
                 // save reference item
                 client.SaveObject(codeValueInstance, "Test0", null, TimeSpan.MaxValue);
                 ICoreItem itemA = client.LoadItem("Test0");
                 Assert.AreEqual(typeof(AssetMeasureValue).FullName, itemA.DataTypeName);
                 // test interface and instance both serialise identically
                 {
                     client.SaveUntypedObject(codeValueInterface, "Test1", null);
                     ICoreItem itemB = client.LoadItem("Test1");
                     Assert.AreEqual(typeof(AssetMeasureValue).FullName, itemB.DataTypeName);
                     Assert.AreEqual(itemA.Text, itemB.Text);
                 }
                 {
                     client.SaveObject((AssetMeasureValue)codeValueInterface, "Test2", null, TimeSpan.MaxValue);
                     ICoreItem itemB = client.LoadItem("Test2");
                     Assert.AreEqual(typeof(AssetMeasureValue).FullName, itemB.DataTypeName);
                     Assert.AreEqual(itemA.Text, itemB.Text);
                 }
                 {
                     // this should fail because interfaces cant be serialised
                     UnitTestHelper.AssertThrows <ArgumentException>("Cannot be an interface type!\r\nParameter name: dataType", () =>
                     {
                         client.SaveObject(codeValueInterface, "Test3", null, TimeSpan.MaxValue);
                     });
                 }
                 {
                     // note: this silently binds to SaveObject<IFpMLCodeValue>(...) which should fail
                     UnitTestHelper.AssertThrows <ArgumentException>("Cannot be an interface type!\r\nParameter name: dataType", () =>
                     {
                         client.SaveObject(codeValueInterface, "Test4", null, TimeSpan.MaxValue);
                     });
                 }
             }
             // shutdown
             server.Stop();
         }
     }
 }
Exemple #2
0
 public void TestMutationDetection()
 {
     // tests the object mutation detector
     using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
     {
         using (CoreServer server = new CoreServer(loggerRef, "UTT", NodeType.Router))
         {
             // start server
             server.Start();
             using (ICoreClient client = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
             {
                 // create reference object
                 TestData data0 = new TestData("Zero", 0);
                 client.SaveObject(data0, "Item0", null);
                 ICoreItem item = client.LoadItem <TestData>("Item0");
                 string    text = item.Text;
                 TestData  data = item.GetData <TestData>(false);
                 // - assert not mutated
                 Assert.AreEqual(text, XmlSerializerHelper.SerializeToString(item.GetData <TestData>(false)));
                 // - mutate the object
                 data.field1 = "One";
                 data.field2 = 1;
                 // - assert mutated
                 Assert.AreNotEqual(text, XmlSerializerHelper.SerializeToString(item.GetData <TestData>(false)));
             }
             // shutdown
             server.Stop();
         }
     }
 }
Exemple #3
0
        private void BtnDebugLoadAlertRulesClick(object sender, EventArgs e)
        {
            using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TextBoxLogger(txtDebugLog)))
            {
                loggerRef.Target.LogDebug("Loading alert rules...");

                using (ICoreClient client = new CoreClientFactory(loggerRef).SetEnv(BuildConst.BuildEnv).Create())
                {
                    // load test user details
                    //client.SaveObject<UserDetail>(MakeUserDetail(User_MLim2, "Mark Lim", "*****@*****.**"));
                    //client.SaveObject<UserDetail>(MakeUserDetail(User_SDudley, "Simon Dudley", "*****@*****.**"));
                    client.SaveObject(MakeUserDetail(AlertRule.UserDefaultReplyTo, "Default ReplyTo User", "*****@*****.**"));
                    client.SaveObject(MakeUserGroup(AlertRule.GroupDefaultMailTo, "Default MailTo Group", new[] { AlertRule.UserDefaultReplyTo }, null));
                    //client.SaveObject<UserGroup>(MakeUserGroup(Group_QDS_Developers, "QDS Developers Group", new string[] { User_SDudley, User_MLim2 }, null));
                    //client.SaveObject<UserGroup>(MakeUserGroup(Group_QDS_Developers, "QDS Developers Group", new string[] { User_SDudley }, null));

                    // defaults
                    // - check constraint: time of day is between 4:30am and 8:30pm 7 days a week
                    IExpression defaultCheckConstraint = Expr.BoolAND(
                        Expr.IsGEQ(Expr.DayOfWeek(Expr.FuncToday()), Expr.Const(DayOfWeek.Monday)),
                        Expr.IsLEQ(Expr.DayOfWeek(Expr.FuncToday()), Expr.Const(DayOfWeek.Friday)),
                        Expr.IsGEQ(Expr.FuncTimeOfDay(), Expr.Const(new TimeSpan(4, 30, 0))),
                        Expr.IsLEQ(Expr.FuncTimeOfDay(), Expr.Const(new TimeSpan(20, 30, 0))));
                    // - monitor period: every minute
                    TimeSpan defaultMonitorPeriod = TimeSpan.FromMinutes(1);
                    // - publish period: hourly
                    TimeSpan defaultPublishPeriod = TimeSpan.FromHours(1);

                    // build rules
                    var alertRules = new List <AlertRule>();

                    alertRules.AddRange(CreateDevRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
                    //alertRules.AddRange(CreateSitRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
                    //alertRules.AddRange(CreateStgRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
                    //alertRules.AddRange(CreateLegacyRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));

                    // save Import rules
                    foreach (AlertRule rule in alertRules)
                    {
                        loggerRef.Target.LogDebug("  Loading AlertRule: {0}.{1}.{2} ({3})...", rule.HostEnvAbbr, rule.HostInstance, rule.RuleUniqueId, rule.Disabled ? "Disabled" : "Enabled");
                        TimeSpan lifetime = rule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
                        client.SaveObject(rule, lifetime);
                    }
                    loggerRef.Target.LogDebug("Loaded {0} alert rules.", alertRules.Count);
                }
            }
        }
        public void TestBasicEncryption()
        {
            // tests key creation and exchange
            // - between 2 clients
            using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
            {
                using (CoreServer server = new CoreServer(loggerRef, "UTT", NodeType.Router))
                {
                    server.Start();

                    using (ICoreClient sender = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
                        using (ICoreClient recver = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
                        {
                            // check un-encrypted traffic
                            Guid evtId1 = sender.SaveObject <TestData>(new TestData("1", 1), "test", null, TimeSpan.MaxValue);

                            List <ICoreItem> recdList1 = recver.LoadItems <TestData>(Expr.ALL);
                            Assert.AreEqual <int>(1, recdList1.Count);
                            ICoreItem recdItem1 = recdList1[0];
                            Assert.AreEqual <Guid>(evtId1, recdItem1.Id);
                            Assert.IsNull(recdItem1.TranspKeyId);
                            Assert.IsNull(recdItem1.SenderKeyId);
                            Assert.IsNull(recdItem1.RecverKeyId);

                            // generate keys
                            string senderKeyId = sender.CryptoManager.GenerateNewKeys();
                            string recverKeyId = recver.CryptoManager.GenerateNewKeys();

                            // send encrypted message and check receiver fails to decrypt
                            ICoreItem sentItem2 = sender.MakeObject <TestData>(new TestData("2", 2), "test", null);
                            sentItem2.TranspKeyId = senderKeyId;
                            sentItem2.SenderKeyId = senderKeyId;
                            Guid             evtId2    = sender.SaveItem(sentItem2);
                            List <ICoreItem> recdList2 = recver.LoadItems <TestData>(Expr.ALL);
                            Assert.AreEqual <int>(1, recdList2.Count);
                            ICoreItem recdItem2 = recdList2[0];
                            Assert.AreEqual <Guid>(evtId2, recdItem2.Id);
                            Assert.AreEqual <Guid>(evtId2, recdItem2.Id);
                            Assert.AreEqual <string>(senderKeyId, recdItem2.TranspKeyId);
                            Assert.AreEqual <string>(senderKeyId, recdItem2.SenderKeyId);
                            Assert.IsNull(recver.CryptoManager.GetTranspKey(senderKeyId));
                            // set public key at receiver and check authentication
                            recver.CryptoManager.SetPublicKey(senderKeyId, sender.CryptoManager.GetPublicKey(senderKeyId));
                            Assert.IsTrue(recdItem2.IsSigned);
                            Assert.IsFalse(recdItem2.IsSecret);
                            // set transport key at receiver and recheck decryption
                            recver.CryptoManager.SetTranspKey(senderKeyId, sender.CryptoManager.GetTranspKey(senderKeyId));
                            object data2 = recdItem2.Data;
                            Assert.IsNotNull(data2);
                            Assert.AreEqual <Type>(typeof(TestData), data2.GetType());
                        }

                    server.Stop();
                }
            }
        }
 public void TestManualRecovery()
 {
     // demonstrates how an application should use the client in its simplest (transient) mode:
     // - exceptions should be handled by the application;
     // - client must be disposed and recreated after an exception has occurred;
     // - subscriptions are not supported.
     //TimeSpan outageDuration = TimeSpan.FromMinutes(1);
     //TimeSpan requestTimeout = TimeSpan.FromSeconds(30);
     using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
     {
         loggerRef.Target.LogDebug("----------> test commenced");
         // create unit test storage
         IStoreEngine unitTestStore = new UnitTestStoreEngine(loggerRef.Target);
         CoreServer   server        = null;
         try
         {
             var serverSettings = new NamedValueSet();
             serverSettings.Set(CfgPropName.NodeType, (int)NodeType.Server);
             serverSettings.Set(CfgPropName.EnvName, "UTT");
             server = new CoreServer(loggerRef, serverSettings)
             {
                 StoreEngine = unitTestStore
             };
             loggerRef.Target.LogDebug("----------> starting server");
             server.Start();
             // create 1st client and save object - should succeed
             Guid id1;
             using (ICoreClient client1 = new CoreClientFactory(loggerRef)
                                          .SetEnv("UTT")
                                          .Create())
             {
                 id1 = client1.SaveObject(new TestData("Test1", 1), "Test1", null, TimeSpan.MaxValue);
                 // stop server and begin save - should fail with timeout
                 loggerRef.Target.LogDebug("----------> stopping server");
                 server.Stop();
                 DisposeHelper.SafeDispose(ref server);
                 client1.RequestTimeout = TimeSpan.FromSeconds(10);
                 UnitTestHelper.AssertThrows <TimeoutException>(() =>
                 {
                     client1.SaveObject(new TestData("Test2a", 2), "Test2", null, TimeSpan.MaxValue);
                 });
                 // further use of client throws more timeout errors
                 UnitTestHelper.AssertThrows <TimeoutException>(() => { client1.LoadObject <TestData>("Test2a"); });
             }
             // create 2nd client - should fail to connect
             UnitTestHelper.AssertThrows <EndpointNotFoundException>("No server in list 'localhost:8113' found!", () =>
             {
                 using (ICoreClient client2 = new CoreClientFactory(loggerRef)
                                              .SetEnv("UTT")
                                              .Create())
                 {
                     client2.SaveObject <TestData>(new TestData("Test2b", 2), "Test2", null, TimeSpan.MaxValue);
                 }
             });
             // restart server
             server = new CoreServer(loggerRef, serverSettings)
             {
                 StoreEngine = unitTestStore
             };
             loggerRef.Target.LogDebug("----------> restarting server");
             server.Start();
             // load 1st object - should succeed
             ICoreItem item1;
             ICoreItem item2;
             using (ICoreClient client3 = new CoreClientFactory(loggerRef)
                                          .SetEnv("UTT")
                                          .Create())
             {
                 item1 = client3.LoadItem <TestData>("Test1");
                 item2 = client3.LoadItem <TestData>("Test2");
             }
             Assert.IsNotNull(item1);
             Assert.AreEqual(id1, item1.Id);
             Assert.IsNull(item2);
             // done
             loggerRef.Target.LogDebug("----------> test completed");
             server.Stop();
             DisposeHelper.SafeDispose(ref server);
         }
         finally
         {
             DisposeHelper.SafeDispose(ref server);
         }
     }
 }
Exemple #6
0
        public void TestFailingExpressions()
        {
            // tests expressions that fail to evaluate on the server
            using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
            {
                NamedValueSet serverSettings = new NamedValueSet();
                serverSettings.Set(CfgPropName.NodeType, (int)NodeType.Router);
                serverSettings.Set(CfgPropName.EnvName, "UTT");
                using (CoreServer server = new CoreServer(loggerRef, serverSettings))
                {
                    server.Start();
                    // save
                    using (ICoreClient client1 = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
                    {
                        client1.SaveObject(new TestData(), "AllValuesNotNull", new NamedValueSet("StrValue/String=A|NumValue/Int32=0"), TimeSpan.MaxValue);
                        client1.SaveObject(new TestData(), "NumValueIsNull", new NamedValueSet("StrValue/String=A"), TimeSpan.MaxValue);
                        client1.SaveObject(new TestData(), "StrValueIsNull", new NamedValueSet("NumValue/Int32=0"), TimeSpan.MaxValue);
                        client1.SaveObject(new TestData(), "AllValuesAreNull", null, TimeSpan.MaxValue);
                    }

                    // load using expression
                    using (ICoreClient client2 = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
                    {
                        client2.DebugRequests = true;
                        {
                            var items = client2.LoadObjects <TestData>(Expr.BoolAND(Expr.IsEQU("StrValue", "A"), Expr.IsEQU("NumValue", 0)));
                            Assert.AreEqual(1, items.Count);
                        }
                        {
                            var items = client2.LoadObjects <TestData>(Expr.BoolOR(Expr.IsEQU("StrValue", "A"), Expr.IsEQU("NumValue", 0)));
                            Assert.AreEqual(3, items.Count);
                        }
                        {
                            // unknown/missing string property
                            var items = client2.LoadObjects <TestData>(Expr.BoolOR(Expr.IsEQU("StrValue", "A"), Expr.IsEQU("XValue", "X")));
                            Assert.AreEqual(2, items.Count);
                        }
                        {
                            // unknown/missing non-string property
                            var items = client2.LoadObjects <TestData>(Expr.BoolOR(Expr.IsEQU("StrValue", "A"), Expr.IsEQU("YValue", 1)));
                            Assert.AreEqual(2, items.Count);
                        }
                        {
                            // property missing
                            var items = client2.LoadObjects <TestData>(Expr.IsNull("StrValue"));
                            Assert.AreEqual(2, items.Count);
                        }
                        {
                            // property has value
                            var items = client2.LoadObjects <TestData>(Expr.IsNotNull("StrValue"));
                            Assert.AreEqual(2, items.Count);
                        }
                        {
                            var items = client2.LoadObjects <TestData>(Expr.StartsWith("StrValue", "A"));
                            Assert.AreEqual(2, items.Count);
                        }
                        {
                            var items = client2.LoadObjects <TestData>(Expr.BoolOR(Expr.StartsWith("StrValue", "A"), Expr.IsEQU("NumValue", 0)));
                            Assert.AreEqual(3, items.Count);
                        }
                    }
                }
            }
        }
        public void TestFileImportServer()
        {
            // start the server, connect a client1, and shutdown
            using (ILogger logger = new TraceLogger(true))
            {
                const EnvId env    = EnvId.Utt_UnitTest;
                var         logRef = Reference <ILogger> .Create(logger);

                var random = new Random(Environment.TickCount);
                int port   = random.Next(8000, 8099);
                using (var server = new CoreServer(logRef, env.ToString(), NodeType.Router, port, WcfConst.NetTcp))
                {
                    // start server
                    server.Start();
                    // connect client
                    using (ICoreClient client = new CoreClientFactory(logRef).SetEnv(env.ToString()).Create())
                    {
                        // create test import rule
                        var rule = new FileImportRule
                        {
                            RuleName         = "UnitTest",
                            SourceLocation   = @"C:\windows\system32",
                            TargetLocation   = @"c:\temp",
                            CopyFilePatterns = "notep*.exe"
                        };
                        var name = rule.RuleName;
                        // start the file import server
                        //DateTimeOffset waitCompleted;
                        var target = new FileImportServer {
                            Client = Reference <ICoreClient> .Create(client)
                        };
                        client.SaveObject(rule, "UnitTest", null, true, TimeSpan.MaxValue);
                        using (target)//logger, env
                        {
                            target.Start();
                            Thread.Sleep(TimeSpan.FromSeconds(5));
                            //waitCompleted = DateTimeOffset.Now;
                            target.Stop();
                        }
                        {
                            var results1 = client.LoadItem <FileImportRule>(name);
                            Assert.IsNotNull(results1);
                            //List<ImportRuleResult> results = client.LoadObjects<ImportRuleResult>(Expr.ALL);//IRuleObject ImportRuleResult
                            //Assert.AreEqual(1, results.Count);
                            //ImportRuleResult result = results[0];
                            //Assert.AreEqual("UnitTest", result.RuleName);
                            //Assert.AreEqual("Completed", result.ImportResult);
                            //Assert.AreEqual(1, result.FileNames.Length);
                            //Assert.AreEqual("notepad.exe", result.FileNames[0].ToLower());
                        }
                        //{
                        //    List<ImportFileResult> results = client.LoadObjects<ImportFileResult>(Expr.ALL);
                        //    Assert.AreEqual(1, results.Count);
                        //    ImportFileResult result = results[0];
                        //    Assert.AreEqual("UnitTest", result.RuleName);
                        //    Assert.AreEqual("Completed", result.ImportResult);
                        //    Assert.AreEqual("notepad.exe", result.FileName.ToLower());
                        //}
                    }
                    // explicit shutdown
                    // - not necessary in a "using" block but run it anyway
                    server.Stop();
                }
            }
        }
Exemple #8
0
        public void TestSerialisingDerivedTypes()
        {
            // tests control of the serialisation type
            // - type b (derived from a) is saved as b, loaded as b;
            // - type b (derived from a) is saved as a, loaded as a (but is type b).
            // (in this example a = PricingStructure, b = YieldCurve)
            using (Reference <ILogger> loggerRef = Reference <ILogger> .Create(new TraceLogger(true)))
            {
                using (CoreServer server = new CoreServer(loggerRef, "UTT", NodeType.Router))
                {
                    // start server
                    server.Start();
                    using (ICoreClient client = new CoreClientFactory(loggerRef).SetEnv("UTT").Create())
                    {
                        {
                            YieldCurve dataA = new YieldCurve
                            {
                                currency = new Currency {
                                    Value = "USD"
                                },
                                algorithm = "FastCubicSpline"
                            };
                            // - save as derived type
                            client.SaveObject(dataA, "TestA", null, TimeSpan.MaxValue);
                            ICoreItem test1 = client.LoadItem <YieldCurve>("TestA");
                            Assert.IsNotNull(test1);
                            Assert.IsNotNull(test1.Text);
                            Assert.AreEqual(
                                "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<yieldCurve xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.fpml.org/FpML-5/reporting\">\r\n  <currency>USD</currency>\r\n  <algorithm>FastCubicSpline</algorithm>\r\n</yieldCurve>",
                                test1.Text);
                            Assert.AreEqual(typeof(YieldCurve).FullName, test1.DataTypeName);
                            Assert.AreEqual(typeof(YieldCurve), test1.DataType);
                            Assert.IsNotNull(test1.Data);
                            Assert.AreEqual(typeof(YieldCurve), test1.Data.GetType());

                            // - save as base type
                            client.SaveObject <PricingStructure>(dataA, "TestA", null, TimeSpan.MaxValue);
                            ICoreItem test2 = client.LoadItem <PricingStructure>("TestA");
                            Assert.IsNotNull(test2);
                            Assert.IsNotNull(test2.Text);
                            Assert.AreEqual(
                                "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<PricingStructure xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:q1=\"http://www.fpml.org/FpML-5/reporting\" xsi:type=\"q1:YieldCurve\">\r\n  <q1:currency>USD</q1:currency>\r\n  <q1:algorithm>FastCubicSpline</q1:algorithm>\r\n</PricingStructure>",
                                test2.Text);
                            Assert.AreEqual(typeof(PricingStructure).FullName, test2.DataTypeName);
                            Assert.AreEqual(typeof(PricingStructure), test2.DataType);
                            Assert.IsNotNull(test2.Data);
                            Assert.AreEqual(typeof(YieldCurve), test2.Data.GetType());
                        }
                        {
                            FxCurve dataB = new FxCurve()
                            {
                                quotedCurrencyPair = new QuotedCurrencyPair()
                                {
                                    currency1 = new Currency()
                                    {
                                        Value = "USD"
                                    },
                                    currency2 = new Currency()
                                    {
                                        Value = "JPY"
                                    },
                                    quoteBasis = QuoteBasisEnum.Currency2PerCurrency1
                                }
                            };
                            // - save as derived type
                            client.SaveObject(dataB, "TestB", null, TimeSpan.MaxValue);
                            ICoreItem test1 = client.LoadItem <FxCurve>("TestB");
                            Assert.IsNotNull(test1);
                            Assert.IsNotNull(test1.Text);
                            Assert.AreEqual(
                                "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<fxCurve xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.fpml.org/FpML-5/reporting\">\r\n  <quotedCurrencyPair>\r\n    <currency1>USD</currency1>\r\n    <currency2>JPY</currency2>\r\n  </quotedCurrencyPair>\r\n</fxCurve>",
                                test1.Text);
                            Assert.AreEqual(typeof(FxCurve).FullName, test1.DataTypeName);
                            Assert.AreEqual(typeof(FxCurve), test1.DataType);
                            Assert.IsNotNull(test1.Data);
                            Assert.AreEqual(typeof(FxCurve), test1.Data.GetType());
                            // - save as base type
                            client.SaveObject <PricingStructure>(dataB, "TestB", null, TimeSpan.MaxValue);
                            ICoreItem test2 = client.LoadItem <PricingStructure>("TestB");
                            Assert.IsNotNull(test2);
                            Assert.IsNotNull(test2.Text);
                            Assert.AreEqual(
                                "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<PricingStructure xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:q1=\"http://www.fpml.org/FpML-5/reporting\" xsi:type=\"q1:FxCurve\">\r\n  <q1:quotedCurrencyPair>\r\n    <q1:currency1>USD</q1:currency1>\r\n    <q1:currency2>JPY</q1:currency2>\r\n  </q1:quotedCurrencyPair>\r\n</PricingStructure>",
                                test2.Text);
                            Assert.AreEqual(typeof(PricingStructure).FullName, test2.DataTypeName);
                            Assert.AreEqual(typeof(PricingStructure), test2.DataType);
                            Assert.IsNotNull(test2.Data);
                            Assert.AreEqual(typeof(FxCurve), test2.Data.GetType());
                        }
                        {
                            // load a collection of the base type and verify specific types
                            List <ICoreItem> items = client.LoadItems <PricingStructure>(Expr.ALL);
                            Assert.AreEqual(2, items.Count);
                            Dictionary <string, PricingStructure> index = new Dictionary <string, PricingStructure>();
                            foreach (ICoreItem item in items)
                            {
                                index[item.Name] = (PricingStructure)item.Data;
                            }
                            Assert.AreEqual(typeof(YieldCurve), index["TestA"].GetType());
                            Assert.AreEqual(typeof(FxCurve), index["TestB"].GetType());
                        }
                    }
                    // shutdown
                    server.Stop();
                }
            }
        }