static void Main()
        {
            Console.WriteLine("ali");
            TransactionConfig tc  = new TransactionConfig();
            ExpectedResult    eee = new ExpectedResult();

            //  eee.Condition = "ddd";
            eee.Category      = "ddd";
            eee.Screen        = "333";
            eee.State         = "990";
            tc.ExpectedResult = eee;

            Console.WriteLine(tc.Amount + " " + tc.ExpectedResult.State);


            TransactionConfig cloned = DeepCopy <TransactionConfig>(tc);

            if (Object.ReferenceEquals(tc, cloned))
            {
                Console.WriteLine("References are the same.");
            }
            else
            {
                Console.WriteLine("References are different.");
            }


            //TransactionConfig tc2 = new TransactionConfig("7890");
            //Console.WriteLine(tc2.V + " " + tc2.X + " " + tc2.Amount);
        }
Exemplo n.º 2
0
        // public string[] ConditionList { get; set; } //TODO delete this field

        public static void Main()
        {
            var a = new ExpectedResult
            {
                //    Condition = "mdt",
                State = "ddd",
                Text  = "fdfdfdfasf"
            };
            //   Console.WriteLine(a.Condition);
        }
Exemplo n.º 3
0
        public void Parse()
        {
            // Examine the stream
            var mapping =
                (YamlMappingNode)_file.Documents[0].RootNode;

            foreach (var entry in mapping.Children)
            {
                Console.Write(((YamlScalarNode)entry.Key).Value + " : ");

                string value = Regex.Replace((entry.Value).ToString(), @"\s+", string.Empty);
                Console.Write(value.Trim('[').Trim(']'));

                Console.WriteLine();
                //output.WriteLine(((YamlScalarNode)entry.Key).Value);
            }
            Console.WriteLine("====================");

            // List all the items
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Financial")])
            {
                _financial.Add(item.ToString());
            }
            Console.WriteLine("Financial");
            foreach (string i in _financial)
            {
                Console.WriteLine(i + " ");
            }
            Console.WriteLine("====================");
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Non-Financial")])
            {
                _nonFinancial.Add(item.ToString());
            }
            Console.WriteLine("nonFinancial");
            foreach (string i in _nonFinancial)
            {
                Console.WriteLine(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Complete")])
            {
                _complete.Add(item.ToString());
            }
            Console.WriteLine("Complete");
            foreach (string i in _complete)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Condition")])
            {
                _condition.Add(item.ToString());
            }
            Console.WriteLine("Condition");
            foreach (string i in _condition)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Before-Checking")])
            {
                _beforeChecking.Add(item.ToString());
            }
            Console.WriteLine("Before-Checking");
            foreach (string i in _beforeChecking)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("After-Checking")])
            {
                _afterChecking.Add(item.ToString());
            }
            Console.WriteLine("After-Checking");
            foreach (string i in _afterChecking)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Reverse")])
            {
                _reverse.Add(item.ToString());
            }
            Console.WriteLine("Reverse");
            foreach (string i in _reverse)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine("====================");
            //====
            foreach (YamlScalarNode item in (YamlSequenceNode)mapping.Children[new YamlScalarNode("Bad-Data")])
            {
                _badData.Add(item.ToString());
            }
            Console.WriteLine("Bad-Data");
            foreach (string i in _badData)
            {
                Console.Write(i + " ");
            }

            var dataParameters = (YamlMappingNode)mapping.Children[new YamlScalarNode("Data-Parameters")];
            var cards          = (YamlSequenceNode)dataParameters.Children[new YamlScalarNode("Cards")];

            foreach (YamlMappingNode data in cards)
            {
                Card card = new Card();
                card.CardNumber = data.Children[new YamlScalarNode("Card_Number")].ToString();
                card.CardType   = data.Children[new YamlScalarNode("Card_Type")].ToString();
                card.Track      = data.Children[new YamlScalarNode("Track")].ToString();
                card.PinBufferA = data.Children[new YamlScalarNode("PinA")].ToString();
                _card.Add(card);
            }

            Console.WriteLine("====================");
            foreach (Card card in _card)
            {
                Console.WriteLine(card.CardNumber + ", " + card.CardType + ", " + card.Track);
            }
            Console.WriteLine("====================");

            var amount = (YamlScalarNode)dataParameters.Children[new YamlScalarNode("Amount")];

            _amount = amount.ToString();
            Console.WriteLine(amount);

            Console.WriteLine("====================");

            var networks = (YamlSequenceNode)dataParameters.Children[new YamlScalarNode("Networks")];

            foreach (YamlMappingNode data in networks)
            {
                var network = new Network();
                network.ServerName = data.Children[new YamlScalarNode("Name")].ToString();
                network.ServerIp   = data.Children[new YamlScalarNode("ServerIP")].ToString();
                network.PortNo     = int.Parse(data.Children[new YamlScalarNode("Port")].ToString());
                _networks.Add(network);
            }

            Console.WriteLine("====================");

            _expectedResultNames.Add("General");
            foreach (var tran in _financial)
            {
                _expectedResultNames.Add(tran);
            }
            foreach (var tran in _complete)
            {
                _expectedResultNames.Add(tran);
            }
            foreach (var tran in _nonFinancial)
            {
                _expectedResultNames.Add(tran);
            }

            var expectedResult = (YamlSequenceNode)mapping.Children[new YamlScalarNode("Expected-Results")];

            foreach (var tran in _expectedResultNames)
            {
                Dictionary <HashSet <string>, ExpectedResult> _expectedResults =
                    new Dictionary <HashSet <string>, ExpectedResult>(HashSet <string> .CreateSetComparer());

                foreach (YamlMappingNode data in expectedResult)
                {
                    if (data.Children[new YamlScalarNode("Category")].ToString().Equals(tran))
                    {
                        string[] conditionList =
                            CreateConditionList(data.Children[new YamlScalarNode("Condition")].ToString());

                        foreach (var condition in conditionList)
                        {
                            ExpectedResult expected = new ExpectedResult();
                            expected.Category = data.Children[new YamlScalarNode("Category")].ToString();
                            //Console.WriteLine("mdtmdt" + data.Children[new Yaml("Condition")].ToString());
                            //expected.Condition = data.Children[new YamlScalarNode("Condition")].ToString();
                            expected.State   = data.Children[new YamlScalarNode("State")].ToString();
                            expected.Screen  = data.Children[new YamlScalarNode("Screen")].ToString();
                            expected.Text    = data.Children[new YamlScalarNode("Text")].ToString();
                            expected.Journal = data.Children[new YamlScalarNode("Journal")].ToString();
                            try
                            {
                                _expectedResults.Add(CreateConditionSet(condition), expected);
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Duplicate Expected Result found!!!");
                            }
                        }
                    }
                }
                _expectedResultList.Add(_expectedResults);
            }
        }