Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 public void TestConfirmationAutoDetectionAllTypes()
 {
     foreach (var concreteType in FpMLViewHelpers.GetFpMLTypes(true))
     {
         System.Diagnostics.Debug.Print("Type: {0} ...", concreteType.Name);
         var orig = Activator.CreateInstance(concreteType);
         // serialise/deserialise as Document and then specific type
         foreach (var serialiserType in new[] {
             typeof(Document),
             concreteType,
         })
         {
             byte[] streamBytes;
             {
                 var xs = new XmlSerializer(serialiserType);
                 using (var ms = new MemoryStream())
                     using (var xw = new XmlTextWriter(ms, Encoding.UTF8))
                     {
                         xs.Serialize(xw, orig);
                         streamBytes = ms.ToArray();
                     }
                 using (var ms = new MemoryStream(streamBytes, false))
                 {
                     var copy = xs.Deserialize(ms);
                     Assert.IsNotNull(copy);
                     Assert.AreEqual(concreteType, copy.GetType());
                 }
             }
             // autodetect concrete type to deserialise from stream
             Type autoDetectedType = FpMLViewHelpers.AutoDetectType(streamBytes);
             using (var ms = new MemoryStream(streamBytes, false))
             {
                 var xs   = new XmlSerializer(autoDetectedType);
                 var copy = xs.Deserialize(ms);
                 Assert.IsNotNull(copy);
                 Assert.AreEqual(concreteType, copy.GetType());
             }
         }
     }
 }
Ejemplo n.º 11
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.");
        }
Ejemplo n.º 12
0
        private T Roundtrip_OutThenIn <T>(T input, bool compare, bool validate)
        {
            string          originalPath      = Path.GetFullPath(@"..\..\step0original.xml");
            string          internalPath      = Path.GetFullPath(@"..\..\step1external.xml");
            string          externalPath      = Path.GetFullPath(@"..\..\step2internal.xml");
            IXmlTransformer transformIncoming = new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap());
            IXmlTransformer transformOutgoing = new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap());
            // emit original internal
            var xs = new XmlSerializer(typeof(T));

            using (var fs = new FileStream(originalPath, FileMode.Create, FileAccess.Write))
            {
                xs.Serialize(fs, input);
            }
            // transform to external format
            transformOutgoing.Transform(originalPath, externalPath);
            // transform to internal format
            transformIncoming.Transform(externalPath, internalPath);
            if (compare)
            {
                // compare
                // load original into xml doc
                var docA = new XmlDocument();
                using (var fs = new FileStream(originalPath, FileMode.Open, FileAccess.Read))
                //using (var sr = new StreamReader(fs, Encoding.UTF8))
                {
                    docA.Load(fs);
                }
                // load emitted stream into xml doc
                var docB = new XmlDocument();
                using (var fs = new FileStream(internalPath, FileMode.Open, FileAccess.Read))
                {
                    docB.Load(fs);
                }
                // compare
                XmlCompare.CompareXmlDocs(docA, docB);
            }
            // validate external
            if (validate)
            {
                const string schemaPath     = @"..\..\..\..\..\Metadata\FpML.V5r3\FpML.V5r3\" + fpmlViewName + ".xsd";
                string       schemaFullPath = Path.GetFullPath(schemaPath);
                Assert.IsTrue(File.Exists(schemaFullPath));
                // validate external xml
                int validationEvents = 0;
                var externalDoc      = new XmlDocument();
                externalDoc.Schemas.Add(null, "file://" + schemaFullPath);
                externalDoc.Load(externalPath);
                externalDoc.Validate((o, e) =>
                {
                    validationEvents++;
                    System.Diagnostics.Debug.Print("Validation event: {0}", e.Message);
                });
                Assert.AreEqual(0, validationEvents);
            }
            // deserialise
            using (TextReader tr = new StreamReader(internalPath))
            {
                return((T)xs.Deserialize(tr));
            }
        }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public void TestReportingRoundtripDateTimes()
        {
            const string schemaPath     = @"..\..\..\..\..\Metadata\FpML.V5r10\FpML.V5r10.Reporting\MergedReportingSchemas\Reporting.xsd";
            string       schemaFullPath = Path.GetFullPath(schemaPath);

            Assert.IsTrue(File.Exists(schemaFullPath));
            string          originalFullPath  = Path.GetFullPath(@"..\..\testOriginalFragment.xml");
            string          internalFullPath  = Path.GetFullPath(@"..\..\testInternalFragment.xml");
            string          outgoingFullPath  = Path.GetFullPath(@"..\..\testOutgoingFragment.xml");
            string          externalFullPath  = Path.GetFullPath(@"..\..\testExternalFragment.xml");
            IXmlTransformer transformIncoming = new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap(), OutputDateTimeKind.UnspecifiedOrUniversal, null);
            IXmlTransformer transformOutgoing = new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap(), OutputDateTimeKind.UnspecifiedOrCustom, TimeSpan.FromHours(-5));
            XmlSerializer   xs = new XmlSerializer(typeof(ExposureReport));
            // original FpML.org sample
            string originalFpMLText =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<exposureReport" +
                "    xmlns=\"http://www.fpml.org/FpML-5/reporting\"" +
                "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                "    fpmlVersion=\"5-10\" >" +
                "  <asOfDate>2010-09-27</asOfDate>" +
                "  <asOfTime>20:08:10-05:00</asOfTime>" +
                "</exposureReport>";

            using (var sw = new StreamWriter(originalFullPath))
            {
                sw.WriteLine(originalFpMLText);
            }
            DateTime expectedAsOfDate = new DateTime(2010, 9, 27, 0, 0, 0);
            DateTime expectedAsOfTime = new DateTime(1, 1, 1, 1, 8, 10);//11 became 12

            {
                // original FpML.org sample
                // --- does not parse reliably due to variably local time zone offset of parser ---
                // asOfDate has an unspecified time zone
                // asOfTime has specific time zone (New York)
                ExposureReport orig;
                using (StringReader sr = new StringReader(originalFpMLText))
                {
                    orig = (ExposureReport)xs.Deserialize(sr);
                }
                Assert.AreEqual(DateTimeKind.Unspecified, orig.asOfDate.Value.Kind);
                Assert.IsTrue(orig.asOfTimeSpecified);
                Assert.AreEqual(DateTimeKind.Local, orig.asOfTime.Kind);
                // --- this test does not pass reliably due to variable local time zone offset of parser ---
                DateTime asOfDate = new DateTime(2010, 9, 27);
                Assert.AreEqual(asOfDate, orig.asOfDate.Value);
                DateTime asOfTime = new DateTime(1, 1, 2, 11, 8, 10);//TODO the time changed due to daylight saving??Why?
                Assert.AreEqual(asOfTime, orig.asOfTime);
            }
            {
                // modified FpML.org sample
                // --- this test does not pass reliably due to variable local time zone offset of parser ---
                // - asOfDate time zone modified to match asOfTime
                string externalXmlText =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<exposureReport" +
                    "    xmlns=\"http://www.fpml.org/FpML-5/reporting\"" +
                    "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                    "    fpmlVersion=\"5-10\" >" +
                    "  <asOfDate>2010-09-27-5:00</asOfDate>" +
                    "  <asOfTime>20:08:10-05:00</asOfTime>" +
                    "</exposureReport>";
                ExposureReport orig;
                using (StringReader sr = new StringReader(externalXmlText))
                {
                    orig = (ExposureReport)xs.Deserialize(sr);
                }
                Assert.AreEqual(DateTimeKind.Local, orig.asOfDate.Value.Kind);
                Assert.IsTrue(orig.asOfTimeSpecified);
                Assert.AreEqual(DateTimeKind.Local, orig.asOfTime.Kind);
                // --- this test does not pass reliably due to variable local time zone offset of parser ---
                DateTime asOfDate = new DateTime(2010, 9, 27, 15, 0, 0); // Australia EST is +10:00
                Assert.AreEqual(asOfDate, orig.asOfDate.Value);
                DateTime asOfTime = new DateTime(1, 1, 2, 11, 8, 10);    //11 became 12
                Assert.AreEqual(asOfTime, orig.asOfTime);
            }
            {
                // modified FpML.org sample
                // - asOfDate and asOfTime set to UTC
                string externalXmlText =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<exposureReport" +
                    "    xmlns=\"http://www.fpml.org/FpML-5/reporting\"" +
                    "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                    "    fpmlVersion=\"5-10\" >" +
                    "  <asOfDate>2010-09-27Z</asOfDate>" +
                    "  <asOfTime>20:08:10Z</asOfTime>" +
                    "</exposureReport>";
                ExposureReport orig;
                using (StringReader sr = new StringReader(externalXmlText))
                {
                    orig = (ExposureReport)xs.Deserialize(sr);
                }
                Assert.AreEqual(DateTimeKind.Local, orig.asOfDate.Value.Kind);
                Assert.IsTrue(orig.asOfTimeSpecified);
                Assert.AreEqual(DateTimeKind.Utc, orig.asOfTime.Kind);   //Local
                // --- this test does not pass reliably due to variable local time zone offset of parser ---
                DateTime asOfDate = new DateTime(2010, 9, 27, 10, 0, 0); // Australia EST is +10:00
                Assert.AreEqual(asOfDate, orig.asOfDate.Value);
                DateTime asOfTime = new DateTime(1, 1, 1, 20, 8, 10);    //6 became 7
                Assert.AreEqual(asOfTime, orig.asOfTime);
            }
            {
                // modified FpML.org sample
                // --- passes reliably because local time zone offset of parser is ignored ---
                // - asOfDate and asOfTime set to unspecified time zone
                string externalXmlText =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<exposureReport" +
                    "    xmlns=\"http://www.fpml.org/FpML-5/reporting\"" +
                    "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                    "    fpmlVersion=\"5-10\" >" +
                    "  <asOfDate>2010-09-27</asOfDate>" +
                    "  <asOfTime>20:08:10</asOfTime>" +
                    "</exposureReport>";
                ExposureReport orig;
                using (StringReader sr = new StringReader(externalXmlText))
                {
                    orig = (ExposureReport)xs.Deserialize(sr);
                }
                Assert.AreEqual(DateTimeKind.Unspecified, orig.asOfDate.Value.Kind);
                Assert.IsTrue(orig.asOfTimeSpecified);
                Assert.AreEqual(DateTimeKind.Unspecified, orig.asOfTime.Kind);
                Assert.AreEqual(new DateTime(2010, 9, 27, 0, 0, 0), orig.asOfDate.Value);
                Assert.AreEqual(new DateTime(1, 1, 1, 20, 8, 10), orig.asOfTime);
            }
            // now that we have a reliably formatted external fpml fragment we can test the roundtrip
            // transform to internal format
            transformIncoming.Transform(originalFullPath, internalFullPath);
            // deserialise
            ExposureReport fpml;

            using (var sr = new FileStream(internalFullPath, FileMode.Open, FileAccess.Read))
            {
                fpml = (ExposureReport)xs.Deserialize(sr);
            }
            Assert.AreEqual(DateTimeKind.Unspecified, fpml.asOfDate.Value.Kind);
            Assert.IsTrue(fpml.asOfTimeSpecified);
            Assert.AreEqual(DateTimeKind.Utc, fpml.asOfTime.Kind);//Local
            Assert.AreEqual(expectedAsOfDate, fpml.asOfDate.Value);
            Assert.AreEqual(expectedAsOfTime, fpml.asOfTime);
            // emit test fragment
            using (var fs = new FileStream(outgoingFullPath, FileMode.Create, FileAccess.Write))
            {
                xs.Serialize(fs, fpml);
            }
            // transform to external format
            transformOutgoing.Transform(outgoingFullPath, externalFullPath);
            // compare external xml
            using (var originalStream = new FileStream(originalFullPath, FileMode.Open, FileAccess.Read))
                using (var externalStream = new FileStream(externalFullPath, FileMode.Open, FileAccess.Read))
                {
                    XmlDocument originalDoc = new XmlDocument();
                    originalDoc.Load(originalStream);
                    XmlDocument emittedDoc = new XmlDocument();
                    emittedDoc.Load(externalStream);
                    // compare
                    XmlCompare.CompareXmlDocs(originalDoc, emittedDoc);
                }
        }