Example #1
0
        public static MachineStatusResult Failure(Exception ex)
        {
            var result = new MachineStatusResult();

            result.AddErrors(ex.Message, ex.StackTrace);
            return(result);
        }
Example #2
0
        public int Run()
        {
            MachineStatusResult programResult = null;

            try
            {
                var facility = FacilityResolver.CreateFacility();

                var systemMonitor = new SystemMonitor(facility);

                var status = systemMonitor.GetSystemStatus();

                programResult = new MachineStatusResult(status);

                var processor = new JsonAssertionProcessor(programResult);
                foreach (var expectation in Expectations.Select(x => Expectation.Parse(x)))
                {
                    var expectationResult = processor.Assert(expectation);
                    if (expectationResult.Failed)
                    {
                        programResult.AddErrors(expectationResult.Errors);
                    }
                }
            }
            catch (Exception ex)
            {
                programResult = MachineStatusResult.Failure(ex);
            }
            finally
            {
                var formating = Format ? Formatting.Indented : Formatting.None;
                System.Console.WriteLine(JsonConvert.SerializeObject(programResult, formating, serializerSettings));
            }
            if (programResult == null || programResult.Error)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }