示例#1
0
        public void GivenStringInt_WhenGetValueIntForOrg1Init_ThenReturnInt()
        {
            _sut.Init("OrgId1", File.ReadAllText("Configs//TestJson.json"));
            var actual = _sut.GetValue <int>("intStringProp");

            Assert.AreEqual(2, actual);
        }
        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"));

        }
示例#3
0
        static void Main(string[] args)
        {
            int count  = 0;
            var config = new JsonEncompassConfig();

            config.Init(System.IO.File.ReadAllText("../../SextantConfigTest.json"));

            //manually set appenders
            // var console = new ConsoleLogAppender(config);
            //var loggly = new LogglyLogAppender(config);
            //var elasticSearch = new ElasticsearchLogAppender(config);
            //Logger.AddAppender(console);
            //Logger.AddAppender(loggly);
            //Logger.AddAppender(elasticSearch);

            //automatically set appenders
            Logger.Setup(config);

            Logger.AddTag("runtime-tag");
            Logger.Debug("SextantTestRig", "Test debug message.");

            Logger.Info("SextantTestRig", "Test info message");
            Logger.Warn("SextantTestRig", "Test warn message");
            Logger.Error("SextantTestRig", "Test error message");
            Logger.Fatal("SextantTestRig", "Test fatal message");

            Console.WriteLine("press Q to quit or any other key to log another debug event.");

            while (Console.ReadKey().Key != ConsoleKey.Q)
            {
                var increment = 19;
                Parallel.For(0, increment, async => { Debug(); });
                count = count + increment;
            }
            Console.WriteLine($"total queued: {count}");
            Console.WriteLine("Shutting down.");
            Logger.Shutdown(30);
            return;

            #region Simple Metrics

            var datadog  = new DatadogReporter(config);
            var graphite = new GraphiteReporter(config);

            SimpleMetrics.AddReporter(datadog);
            SimpleMetrics.AddReporter(graphite);

            SimpleMetrics.AddGauge("SextantTestRig.Gauge", 10);
            SimpleMetrics.AddCounter("SextantTestRig.Counter", 10);
            SimpleMetrics.AddMeter("SextantTestRig.Meter", 10);

            #endregion

            #region StatsD Metrics

            StatsDMetrics.Setup(config);

            var    timer = StatsDMetrics.Timer("sextant-statd-tests-timer", Unit.Calls);
            Random r     = new Random();

            timer.StartRecording();

            var counter = StatsDMetrics.Counter("sextant-statd-tests-counter", Unit.Events, MetricTags.None);
            counter.Increment(r.Next(0, 100));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));
            counter.Increment(r.Next(0, 10));

            timer.EndRecording();

            #endregion

            Console.WriteLine("press enter to quit.");
            Console.ReadLine();
        }
示例#4
0
 public void SetUp()
 {
     _sut = new JsonEncompassConfig();
     _sut.Init(File.ReadAllText("Configs//TestJson.json"));
 }
        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();
            }
        }