public void Usage()
        {
            DateTime timeStamp = DateTime.UtcNow;
            string serverName = Environment.MachineName;
            string applicationName = "NetChris.Web.SelfTest.UnitTests";
            string applicationFriendlyName = "Unit tests against NetChris.Web.SelfTest";
            string applicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            SelfTestStatus applicationStatus = new SelfTestStatus("Application", StatusCode.Fail,
                "Some subsystems in failure mode");
            var dbStatus = new SelfTestStatus("db", StatusCode.Pass);
            var diskspaceStatus = new SelfTestStatus("diskspace", StatusCode.Warn, "Only 20MB left");
            var awsStatus = new SelfTestStatus("aws", StatusCode.Fail, "AWS unavailable");
            IEnumerable<SelfTestStatus> subsystemStatuses = new[] {
                dbStatus,
                diskspaceStatus,
                awsStatus
            };
            ISelfTestResult result = new SelfTestResultJsonWrapper(timeStamp, serverName, applicationName, applicationFriendlyName,
                applicationVersion, applicationStatus, subsystemStatuses);

            Assert.Equal(applicationFriendlyName, result.ApplicationFriendlyName);
            Assert.Equal(timeStamp, result.Timestamp);
            Assert.Equal(serverName, result.ServerName);
            Assert.Equal(applicationName, result.ApplicationName);
            Assert.Equal(".NET Assembly", result.ApplicationType);
            Assert.Equal(applicationVersion, result.ApplicationVersion);
            Assert.Equal(applicationStatus.Code, result.ApplicationStatus.Code);
            Assert.Equal(applicationStatus.Description, result.ApplicationStatus.Description);
            Assert.Equal(applicationStatus.Name, result.ApplicationStatus.Name);
            Assert.Equal(3, result.SubsystemStatuses.Count());
            Assert.True(result.SubsystemStatuses.Contains(dbStatus));
            Assert.True(result.SubsystemStatuses.Contains(diskspaceStatus));
            Assert.True(result.SubsystemStatuses.Contains(awsStatus));
        }
        public void Null_application_status_throws_ArgumentNullException()
        {
            SelfTestStatus applicationStatus = new SelfTestStatus("Application", StatusCode.Fail,
                "Some subsystems in failure mode");

            Assert.Throws<ArgumentNullException>(() =>
            new SelfTestResultJsonWrapper(DateTime.UtcNow, "", "", null, "", null, null));
        }
        public async Task<ISelfTestResult> RunTests()
        {
            DateTime timeStamp = DateTime.Parse("2016-02-16T00:49:45.4905098Z").ToUniversalTime();
            string serverName = "OFFICE";
            string applicationName = "NetChris.Web.SelfTest.UnitTests";
            // TODO - ApplicationType is hard-coded to be ".NET Assembly"
            string applicationFriendlyName = "Unit tests against NetChris.Web.SelfTest";
            string applicationVersion = "1.2.3.4";
            SelfTestStatus applicationStatus = new SelfTestStatus("Application", StatusCode.Fail,
                "Some subsystems in failure mode");
            var dbStatus = new SelfTestStatus("db", StatusCode.Pass);
            var diskspaceStatus = new SelfTestStatus("diskspace", StatusCode.Warn, "Only 20MB left");
            var awsStatus = new SelfTestStatus("aws", StatusCode.Fail, "AWS unavailable");
            IEnumerable<SelfTestStatus> subsystemStatuses = new[] {
                dbStatus,
                diskspaceStatus,
                awsStatus
            };
            ISelfTestResult result = new SelfTestResultJsonWrapper(timeStamp, serverName, applicationName, applicationFriendlyName,
                applicationVersion, applicationStatus, subsystemStatuses);

            return await Task.FromResult(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SelfTestResultJsonWrapper"/> class.
        /// </summary>
        /// <param name="timestamp">The timestamp.</param>
        /// <param name="serverName">Name of the server.</param>
        /// <param name="applicationName">Name of the application.</param>
        /// <param name="applicationFriendlyName">Friendly name of the application.</param>
        /// <param name="applicationVersion">The application version.</param>
        /// <param name="applicationStatus">The application status.</param>
        /// <param name="subsystemStatuses">The subsystem statuses.</param>
        /// <exception cref="ArgumentNullException"><paramref name="serverName"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="applicationName"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="applicationVersion"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="applicationStatus"/> is <see langword="null" />.</exception>
        public SelfTestResultJsonWrapper(DateTime timestamp, string serverName,
            string applicationName, string applicationFriendlyName,
            string applicationVersion, SelfTestStatus applicationStatus,
            IEnumerable<SelfTestStatus> subsystemStatuses = null)
        {
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }
            if (applicationName == null)
            {
                throw new ArgumentNullException(nameof(applicationName));
            }
            if (applicationVersion == null)
            {
                throw new ArgumentNullException(nameof(applicationVersion));
            }
            if (applicationStatus == null)
            {
                throw new ArgumentNullException(nameof(applicationStatus));
            }
            Timestamp = timestamp;
            ServerName = serverName;
            ApplicationName = applicationName;
            ApplicationFriendlyName = applicationFriendlyName ?? applicationName;
            ApplicationVersion = applicationVersion;
            ApplicationStatus = applicationStatus;

            if (subsystemStatuses == null)
            {
                SubsystemStatuses = new List<SelfTestStatus>().AsReadOnly();
            }
            else
            {
                SubsystemStatuses = new List<SelfTestStatus>(subsystemStatuses).AsReadOnly();
            }
        }
        public void To_JSON()
        {
            DateTime timeStamp = DateTime.UtcNow;
            string serverName = Environment.MachineName;
            string applicationName = "NetChris.Web.SelfTest.UnitTests";
            // TODO - ApplicationType is hard-coded to be ".NET Assembly"
            string applicationFriendlyName = "Unit tests against NetChris.Web.SelfTest";
            string applicationVersion = "1.2.3.4";
            SelfTestStatus applicationStatus = new SelfTestStatus("Application", StatusCode.Fail,
                "Some subsystems in failure mode");
            var dbStatus = new SelfTestStatus("db", StatusCode.Pass);
            var diskspaceStatus = new SelfTestStatus("diskspace", StatusCode.Warn, "Only 20MB left");
            var awsStatus = new SelfTestStatus("aws", StatusCode.Fail, "AWS unavailable");
            IEnumerable<SelfTestStatus> subsystemStatuses = new[] {
                dbStatus,
                diskspaceStatus,
                awsStatus
            };
            ISelfTestResult result = new SelfTestResultJsonWrapper(timeStamp, serverName, applicationName, applicationFriendlyName,
                applicationVersion, applicationStatus, subsystemStatuses);

            string output = JsonConvert.SerializeObject(result, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });
            Console.WriteLine(output);
        }
        public void Null_subsystems()
        {
            SelfTestStatus applicationStatus = new SelfTestStatus("Application", StatusCode.Fail,
                "Some subsystems in failure mode");

            var thing = new SelfTestResultJsonWrapper(DateTime.UtcNow, "", "", null, "", applicationStatus);
        }