public void ForValidConfigReturnGoodValues()
        {
            var config = new JsonEncompassConfig();
                config.Init(_json);
            Assert.That(config.GetKeys().Count == 22, String.Format("Expected 22, got {0}", config.GetKeys().Count));
            Assert.That(config.GetValue("widget.debug", false).Equals(true),
                String.Format("Expected 'true' , got '{0}'", config.GetValue("widget.debug", false)));
            Assert.That(config.GetValue("widget.window.title").Equals("Sample Konfabulator Widget"));

            var subConfig = config.GetConfigGroup("widget.window");
            Assert.That(subConfig.GetValue("title").Equals("Sample Konfabulator Widget"));

        }
Ejemplo n.º 2
0
        public void ForValidConfigReturnGoodValues()
        {
            Assert.That(_sut.GetKeys().Count == 49, $"Expected 49, got {_sut.GetKeys().Count}");
            Assert.That(_sut.GetValue("widget.debug", false).Equals(true), $"Expected 'true' , got '{_sut.GetValue("widget.debug", false)}'");

            Assert.That(_sut.GetValue <bool>("widget.debug", false).Equals(true), $"Expected 'true' , got '{_sut.GetValue("widget.debug", false)}'");
            Assert.That(_sut.GetValue("widget.window.title").Equals("Sample Konfabulator Widget"));

            var subConfig = _sut.GetConfigGroup("widget.window");

            Assert.That(subConfig.GetValue("title").Equals("Sample Konfabulator Widget"));
        }
        static void Main(string[] args)
        {
            var config = new JsonEncompassConfig();

            config.Init(System.IO.File.ReadAllText("../../ConsoleTester.json"));
            var server      = config.GetValue <string>("encompass-url", String.Empty);
            var userid      = config.GetValue <string>("encompass-userid", String.Empty);
            var password    = config.GetValue <string>("encompass-password", String.Empty);
            var loanNumbers = config.GetValue <List <string> >("test-loans", new List <string>());

            if (server == String.Empty)
            {
                Console.Write("Please enter the url of your Encompass instance and press enter.");
                server = Console.ReadLine();
            }

            if (userid == String.Empty)
            {
                Console.Write("Please enter your Encompass userid and press enter.");
                userid = Console.ReadLine();
            }

            if (password == String.Empty)
            {
                Console.Write("Please enter your Encompass password and press enter.");
                while (true)
                {
                    var key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Enter)
                    {
                        break;
                    }
                    password += key.KeyChar;
                }
            }

            Console.WriteLine();
            Console.WriteLine("Logging into Encompass");
            using (var sess = SessionUtils.GetEncompassSession(server, userid, password))
            {
                if (!loanNumbers.Any())
                {
                    Console.WriteLine("Please enter a loan number to test and press enter.");
                    loanNumbers.Add(Console.ReadLine());
                }

                var sw = new Stopwatch();
                foreach (var ln in loanNumbers)
                {
                    Console.WriteLine($"opening loan {ln}");
                    var loan = SessionUtils.OpenLoanFromLoanNumber(sess, ln);
                    Console.WriteLine("Extracting");
                    FieldUtils.session = sess;
                    sw.Start();
                    var serialized = JsonConvert.SerializeObject(LoanDataUtils.ExtractEverything(loan));
                    var path       = String.Format(@"c:\junk\{0}.json", ln);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    System.IO.File.WriteAllText(path, serialized);
                    sw.Stop();
                    Console.WriteLine($"Extracted loan {ln} in {sw.ElapsedMilliseconds / 1000} seconds.");
                    sw.Reset();
                    loan.Close();
                }
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }