Exemple #1
0
        public static void LoadTrades2(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading trades...");
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadAndReturnConfirmationExamples(
                schemaSet, FpMLViewHelpers.AutoDetectType,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                false, false, false);

            foreach (var document in results)
            {
                var extraProps = new NamedValueSet();
                extraProps.Set(TradeProp.TradingBookName, "Test");
                extraProps.Set(TradeProp.TradeState, "Confirmed");
                //extraProps.Set("TradeType", "Deposit");
                extraProps.Set(TradeProp.TradeSource, "FPMLSamples");
                extraProps.Set(TradeProp.AsAtDate, DateTime.Today);
                extraProps.Set("Namespace", "Confirmation");
                ItemInfo itemInfo = MakeTradeProps(document.GetType().ToString(), null, extraProps, nameSpace);
                logger.LogDebug("  {0} ...", itemInfo.ItemName);
                targetClient.SaveObject(document, itemInfo.ItemName, itemInfo.ItemProps, false, TimeSpan.MaxValue);
            } // foreach file
            //as TradeConfirmed
            logger.LogDebug("Loaded {0} trades.", results.Count());
        }
        public void TestConfirmationFpMLSamplesRoundtripAll()
        {
            const string fileSpec  = "*.xml";
            var          schemaSet = FpMLViewHelpers.GetSchemaSet();
            var          results   = TestHelper.LoadFiles(
                fpmlViewName, schemaSet, FpMLViewHelpers.AutoDetectType, fileSpec,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                true, true, true);

            Assert.AreEqual(593, results.FilesProcessed.Count); // 593
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
            Assert.AreEqual(0, results.OutgoingTransformErrors.Count);
            Assert.AreEqual(0, results.DeserialisationErrors.Count);
            Assert.AreEqual(0, results.InternalComparisonErrors.Count);
            Assert.AreEqual(0, results.ExternalComparisonErrors.Count);
            // Note: There are 4 files causing benign validation events. These are all
            // due to un-necessary emission of the "breakFeeElection" element in the
            // "equitySwapTransactionSupplement" element. It appears that the schema should
            // define the "breakFeeElection" element as minOccurs=0, but it does not, and
            // the consequence is that the element is emitted with the default value (FlatFee).
            // Removal of the extra element causes downstream errors so it remains as is.
            Assert.AreEqual(4, results.CopyValidationErrors.Count);
            Assert.AreEqual(0, results.CopyValidationWarnings.Count);
        }
        public void TestConfirmationFpMLSamplesLoadErrors()
        {
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadFiles(
                fpmlViewName, schemaSet, FpMLViewHelpers.AutoDetectType, "*.error",
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                false, false, false);

            Assert.AreEqual(7, results.FilesProcessed.Count);
            Assert.AreEqual(4, results.DeserialisationErrors.Count);
        }
        public void TestConfirmationFpMLSamplesLoadAndValidateAll()
        {
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadFiles(
                fpmlViewName, schemaSet, FpMLViewHelpers.AutoDetectType, "*.xml",
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                true, false, false);

            Assert.AreEqual(593, results.FilesProcessed.Count);
            Assert.AreEqual(0, results.DeserialisationErrors.Count);
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
        }
Exemple #5
0
        public void TestConfirmationFpMLSamplesLoadAllValid()
        {
            const string fileSpec  = "*.xml";
            var          schemaSet = FpMLViewHelpers.GetSchemaSet();
            var          results   = TestHelper.LoadFiles(
                FPMLViewName, schemaSet, FpMLViewHelpers.AutoDetectType, fileSpec,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                false, false, false);

            Assert.AreEqual(1493, results.FilesProcessed.Count);
            Assert.AreEqual(107, results.DeserialisationErrors.Count);//121 errors
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
        }
        public void TestReportingFpMLSamplesLoadAndValidateAll()
        {
            //string fileSpec = "rpt-ex11-position-report-equity.xml";
            string fileSpec  = "*.xml";
            var    schemaSet = FpMLViewHelpers.GetSchemaSet();
            var    results   = TestHelper.LoadFiles(
                fpmlViewName, schemaSet, FpMLViewHelpers.AutoDetectType, fileSpec,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                true, false, false);

            Assert.AreEqual(149, results.FilesProcessed.Count);
            Assert.AreEqual(0, results.DeserialisationErrors.Count);
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
        }
        public void TestConfirmationFpMLSamplesRoundtripFromQrml()
        {
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadFiles(
                fpmlViewName, schemaSet, FpMLViewHelpers.AutoDetectType, @"FromQRML\*.xml",
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                true, true, true);

            Assert.AreEqual(1, results.FilesProcessed.Count);
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
            Assert.AreEqual(0, results.OutgoingTransformErrors.Count);
            Assert.AreEqual(0, results.DeserialisationErrors.Count);
            Assert.AreEqual(0, results.InternalComparisonErrors.Count);
            Assert.AreEqual(0, results.ExternalComparisonErrors.Count);
            Assert.AreEqual(0, results.CopyValidationWarnings.Count);
            Assert.AreEqual(0, results.CopyValidationErrors.Count);
        }
Exemple #8
0
        public void TestReportingFpMLSamplesRoundtripAll()
        {
            //string fileSpec = "rpt-ex11-position-report-equity.xml";
            string fileSpec  = "*.xml";
            var    schemaSet = FpMLViewHelpers.GetSchemaSet();
            var    results   = TestHelper.LoadFiles(
                FPMLViewName, schemaSet, FpMLViewHelpers.AutoDetectType, fileSpec,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                true, true, true);

            Assert.AreEqual(178, results.FilesProcessed.Count);
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
            Assert.AreEqual(3, results.DeserialisationErrors.Count);     //TODO should be 0
            Assert.AreEqual(12, results.InternalComparisonErrors.Count); //TODO should be 0
            Assert.AreEqual(12, results.ExternalComparisonErrors.Count); //TODO should be 0
            Assert.AreEqual(0, results.CopyValidationWarnings.Count);
            Assert.AreEqual(10, results.CopyValidationErrors.Count);
        }
Exemple #9
0
        public void TestReportingFpMLSamplesLoadAllValid()
        {
            //string fileSpec =  "rpt-ex20-matured-and-expired-trades.xml";
            string   fileSpec        = "*.xml";
            TimeSpan localTimeOffset = DateTimeOffset.Now.Offset;

            Assert.AreEqual(TimeSpan.FromHours(10), localTimeOffset);//11
            var transformIncoming = new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap(), OutputDateTimeKind.UnspecifiedOrLocal, null);
            var transformOutgoing = new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap(), OutputDateTimeKind.UnspecifiedOrCustom, TimeSpan.FromHours(-5));
            var schemaSet         = FpMLViewHelpers.GetSchemaSet();
            var results           = TestHelper.LoadFiles(
                FPMLViewName, schemaSet, FpMLViewHelpers.AutoDetectType, fileSpec,
                transformIncoming, transformOutgoing,
                false, false, false);

            Assert.AreEqual(178, results.FilesProcessed.Count);
            Assert.AreEqual(3, results.DeserialisationErrors.Count);//TODO should be 0
            Assert.AreEqual(0, results.OrigValidationWarnings.Count);
            Assert.AreEqual(0, results.OrigValidationErrors.Count);
            Assert.AreEqual(0, results.IncomingTransformErrors.Count);
        }
Exemple #10
0
        private void BtnRunTestsClick(object sender, EventArgs e)
        {
            txtLog.Clear();
            _Abort = false;
            LogInfo("Tests starting...");
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            // init paths
            string          externalPath      = txtWorkPath.Text + @"\External.xml";
            string          importedPath      = txtWorkPath.Text + @"\Imported.xml";
            string          internalPath      = txtWorkPath.Text + @"\Internal.xml";
            string          exportedPath      = txtWorkPath.Text + @"\Exported.xml";
            IXmlTransformer importTransformer = new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap());
            IXmlTransformer exportTransformer = new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap());

            // test loop
            foreach (var item in clbTests.CheckedItems)
            {
                if (_Abort)
                {
                    break;
                }
                string checkedTest = item.ToString();
                int    p1          = checkedTest.IndexOf('[');
                int    p2          = checkedTest.IndexOf(']');
                string testId      = checkedTest.Substring(p1 + 1, (p2 - p1 - 1));
                string testTitle   = checkedTest.Substring(0, p1 - 1);
                LogInfo(testTitle + " ...", testId);
                var errorCounter   = new Counter();
                var warningCounter = new Counter();
                try
                {
                    switch (testId)
                    {
                    case "FMTEXT":
                        TestHelper.FormatXml(this, testId, txtSourcePath.Text, externalPath, errorCounter);
                        ShowXml(externalPath, txtExternalXml);
                        break;

                    case "VALEXT":
                        TestHelper.ValidateXml(this, testId, externalPath, schemaSet, errorCounter, warningCounter);
                        break;

                    case "IMPORT":
                        TestHelper.TransformXml(this, testId, importTransformer, externalPath, importedPath, errorCounter);
                        ShowXml(importedPath, txtImportedXml);
                        break;

                    case "DESIMP":
                        _FpMLObject = TestHelper.DeserialiseXml(this, testId, FpMLViewHelpers.AutoDetectType, importedPath, errorCounter);
                        break;

                    case "SERIAL":
                        TestHelper.SerialiseXml(this, testId, _FpMLObject, internalPath, errorCounter);
                        ShowXml(internalPath, txtInternalXml);
                        break;

                    case "CMPINT":
                        TestHelper.CompareXml(this, testId, importedPath, internalPath, errorCounter);
                        break;

                    case "EXPORT":
                        TestHelper.TransformXml(this, testId, exportTransformer, internalPath, exportedPath, errorCounter);
                        ShowXml(exportedPath, txtExportedXml);
                        break;

                    case "VALEXP":
                        TestHelper.ValidateXml(this, testId, exportedPath, schemaSet, errorCounter, warningCounter);
                        break;

                    case "CMPEXT":
                        TestHelper.CompareXml(this, testId, txtSourcePath.Text, exportedPath, errorCounter);
                        break;

                    // internal
                    case "FMTINT":
                        TestHelper.FormatXml(this, testId, txtSourcePath.Text, importedPath, errorCounter);
                        ShowXml(importedPath, txtImportedXml);
                        break;

                    case "CMPIIS":
                        TestHelper.CompareXml(this, testId, txtSourcePath.Text, importedPath, errorCounter);
                        break;

                    default:
                        throw new NotImplementedException("This test has not not implemented!");
                    }
                }
                catch (System.Exception excp)
                {
                    errorCounter.Inc();
                    LogException(excp, testId, true);
                }
                if (errorCounter.Count > 0)
                {
                    LogError(String.Format("    Test FAILED with {0} errors, {1} warnings.", errorCounter.Count, warningCounter.Count), testId, true);
                }
                else
                {
                    LogInfo(String.Format("    Test PASSED with {0} warnings.", warningCounter.Count), testId);
                }
            }
            Log(_Abort ? "Tests aborted!" : "Tests completed.");
        }
Exemple #11
0
        public static void LoadTrades(ILogger logger, ICoreCache targetClient)
        {
            logger.LogDebug("Loading trades...");
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadAndReturnConfirmationExamples(
                schemaSet, FpMLViewHelpers.AutoDetectType,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                false, false, false);

            foreach (var document in results)
            {
                SaveDocument(logger, targetClient, document);
                //var result = TestHelper.DeserialiseXml(testLog, testId, typeDetector, sourcePath, counters.DeserialisationErrors)
                //var document = XmlSerializerHelper.DeserializeFromString<Document>(file);//This does not work!
                //if (document as DataDocument != null)
                //{
                //    var tradeData = (DataDocument)document;
                //    Trade tradeVersion = tradeData.trade[0];
                //    if (tradeVersion != null)
                //    {
                //        Party[] party = tradeData.party;
                //        BuildTrade(logger, targetClient, tradeVersion, party);
                //    }
                //}
                //else if (document as TradeConfirmed != null)
                //{
                //    var tradeData = (TradeConfirmed)document;
                //    tradeVersion = tradeData.trade;
                //    party = tradeData.party;
                //    BuildTrade(logger, targetClient, tradeVersion, party);
                //}
                //else if (document as RequestTradeConfirmation != null)
                //{
                //    var tradeData = (RequestTradeConfirmation)document;
                //    tradeVersion = tradeData.trade;
                //    party = tradeData.party;
                //    BuildTrade(logger, targetClient, tradeVersion, party);
                //}
                //else if (document as TradeCreated != null)
                //{
                //    var tradeData = (TradeCreated)document;
                //    tradeVersion = tradeData.trade;
                //    party = tradeData.party;
                //    BuildTrade(logger, targetClient, tradeVersion, party);//TradeCancelled
                //}
                //else if (document as TradeCancelled != null)
                //{
                //    var tradeData = (TradeCancelled)document;
                //    tradeVersion = tradeData.Items[0] as Trade;
                //    party = tradeData.party;
                //    BuildTrade(logger, targetClient, tradeVersion, party);//
                //}
                //else if (document as LoanContractNotice != null)
                //{
                //    var tradeData = (LoanContractNotice)document;
                //    tradeVersion = tradeData.Items[0] as Trade;
                //    party = tradeData.party;
                //    BuildTrade(logger, targetClient, tradeVersion, party);
                //}
            } // foreach file
            //as TradeConfirmed
            logger.LogDebug("Loaded {0} trades.", results.Count());
        }