public void RunApplicationHealthMapper_PeakUserFeature()
        {
            IList <HealthBase> healthData;
            var task = new HealthTask();

            healthData = task.GetHealthData(MeasureTypes.AppHealth, DateTime.Now.AddDays(-90), DateTime.Now.AddDays(1), 300);
            var applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);


            Assert.IsTrue(false);
        }
        public void RunApplicationHealthMapper_StraightOnes_ForMultipleDays()
        {
            Boolean                       pass_or_fail = true;
            IList <HealthBase>            healthData   = new List <HealthBase>();
            Dictionary <int, List <int> > keys         = LoadDateTestRangeData(healthData, 5, true, false, true);
            var applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);

            foreach (var dta in applicationHealthDatas)
            {
                if (dta.Users != 1)
                {
                    pass_or_fail = false;
                }
            }

            Assert.IsTrue(pass_or_fail);
        }
        public void RunApplicationHealthMapper_PeakUsersForDateRange()
        {
            Boolean                       pass_or_fail = true;
            IList <HealthBase>            healthData   = new List <HealthBase>();
            Dictionary <int, List <int> > keys         = LoadDateTestRangeData(healthData);
            var applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);

            foreach (var dta in applicationHealthDatas)
            {
                var healthItems   = healthData.Where(x => ((ApplicationHealth)x).CaseArtifactId == dta.ArtifactID);
                var derivedAnswer = Math.Ceiling(healthItems.GroupBy(x => x.MeasureDate.Date).Average(x => x.Max(y => Math.Max(((ApplicationHealth)y).UserCount, 0))));
                if (dta.Users != derivedAnswer)
                {
                    pass_or_fail = false;
                }
            }

            Assert.IsTrue(pass_or_fail);
        }
        public void RunApplicationHealthMapper_Success()
        {
            IList <HealthBase> healthData;
            var task = new HealthTask();

            healthData = task.GetHealthData(MeasureTypes.AppHealth, DateTime.Now.AddDays(-90), DateTime.Now.AddDays(1), 300);
            var    applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);
            String tempPath = System.IO.Path.GetTempFileName();

            using (var file = System.IO.File.Open(tempPath, System.IO.FileMode.Append))
            {
                foreach (var appHealthData in applicationHealthDatas)
                {
                    var bytes = Encoding.ASCII.GetBytes(String.Format("{0},{1},{2},{3},{4},{5},{6}\r\n", appHealthData.SQLInstanceName, appHealthData.Errors, appHealthData.ArtifactID, appHealthData.LRQ, appHealthData.MeasureDate, appHealthData.Users, appHealthData.WorkspaceName));
                    file.Write(bytes, 0, bytes.Length);
                }
            }
            Console.WriteLine(tempPath);
        }
        public void RunApplicationHealthMapper_PeakUsersForNegativeOrZeroedOutUserCounts_ForMultipleDays()
        {
            Boolean                       pass_or_fail = true;
            IList <HealthBase>            healthData   = new List <HealthBase>();
            Dictionary <int, List <int> > keys         = LoadDateTestRangeData(healthData, 5, true);
            var applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);

            foreach (var dta in applicationHealthDatas)
            {
                List <int> usrCounts     = keys[Convert.ToInt32(dta.ArtifactID)];
                double     derivedAnswer = 0;
                if (usrCounts.Where(a => a > 1).Any())
                {
                    derivedAnswer = Math.Ceiling(usrCounts.Where(a => a > 1).Average());
                }
                if (dta.Users != derivedAnswer)
                {
                    pass_or_fail = false;
                }
            }

            Assert.IsTrue(pass_or_fail);
        }
        public void RunApplicationHealthMapper_PeakUsersForSingleDay()
        {
            Boolean                       pass_or_fail = true;
            IList <HealthBase>            healthData   = new List <HealthBase>();
            Dictionary <int, List <int> > keys         = LoadDateTestRangeData(healthData, 1);
            var applicationHealthDatas = ApplicationHealthMapper.ToApplicationHealth(healthData);

            foreach (var dta in applicationHealthDatas)
            {
                List <int> usrCounts     = keys[Convert.ToInt32(dta.ArtifactID)];
                double     derivedAnswer = 0;
                if (usrCounts.Where(a => a > 0).Any())
                {
                    derivedAnswer = usrCounts.Max();
                }
                if (dta.Users != derivedAnswer)
                {
                    pass_or_fail = false;
                }
            }

            Assert.IsTrue(pass_or_fail);
        }