Exemplo n.º 1
0
 public void ValidFmplPassesValidation()
 {
     var fpml = File.ReadAllText(@"Resources\Fpml-Valid_5-7.xml");
     var validator = new FpmlValidator();
     var failures = validator.Validate(fpml);
     Assert.IsNotNull(failures);
     Assert.IsFalse(failures.Any());
 }
Exemplo n.º 2
0
 public void InvalidFmplFailsValidation()
 {
     var fpml = File.ReadAllText(@"Resources\Fpml-Invalid_5-7.xml");
     var validator = new FpmlValidator();
     var failures = validator.Validate(fpml);
     Assert.IsNotNull(failures);
     Assert.AreEqual(2, failures.Count());
     Assert.AreEqual(1, failures.Count(x => x == @"The 'http://www.fpml.org/FpML-5/reporting:isCorrection' element is invalid - The value 'maybe' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:boolean' - The string 'maybe' is not a valid Boolean value."));
     Assert.AreEqual(1, failures.Count(x => x == "Reference to undeclared ID is 'party1'."));
 }
        public void Handle(IMessage message)
        {
            var stopwatch = Stopwatch.StartNew();
            var tradeMessage = message as ValidateTradeMessage;

            Console.WriteLine("| ValidateTradeHandler | Received trade with message ID: " + tradeMessage.TradeId);

            using (var db = _dbFactory.GetContext())
            {
                var trade = db.IncomingTrades.Find(tradeMessage.TradeId);

                var validator = new FpmlValidator();
                var failures = validator.Validate(trade.Fpml);
                trade.IsFpmlValid = failures.Any() == false;

                trade.ProcessedAt = DateTime.UtcNow;
                db.SaveChanges();
            }

            Console.WriteLine("* | ValidateTradeHandler | Processed trade with ID: {0}, took: {1}ms", tradeMessage.TradeId, stopwatch.ElapsedMilliseconds);
        }