public void ApplicationId()
        {
            var data = Guid.NewGuid();
            var row  = new LatestServerStatisticsRow(data);

            Assert.AreEqual <Guid>(data, row.ApplicationId);
        }
        public void ConvertNetwork()
        {
            var random = new Random();
            var row    = new LatestServerStatisticsRow(Guid.NewGuid())
            {
                CpuUsagePercentage          = random.Next(100),
                MemoryUsagePercentage       = random.Next(100),
                PhysicalDiskUsagePercentage = random.Next(100),
                DeploymentId       = StringHelper.ValidString(),
                RowKey             = StringHelper.ValidString(),
                OccurredOn         = DateTime.UtcNow,
                NetworkPercentage1 = random.Next(1, 100),
                NetworkPercentage2 = random.Next(1, 100),
                NetworkPercentage3 = random.Next(1, 100),
                NetworkPercentage4 = random.Next(1, 100),
            };

            var set = row.Convert();

            Assert.AreEqual <double>(row.CpuUsagePercentage, set.CpuUsagePercentage);
            Assert.AreEqual <double>(row.MemoryUsagePercentage, set.MemoryUsagePercentage);
            Assert.AreEqual <double>(row.PhysicalDiskUsagePercentage, set.PhysicalDiskUsagePercentage);
            Assert.AreEqual <DateTime>(row.OccurredOn, set.OccurredOn);
            Assert.AreEqual <string>(row.DeploymentId, set.DeploymentId);
            Assert.AreEqual <string>(row.RowKey, set.MachineName);
            Assert.AreEqual <Guid>(row.ApplicationId, set.Token.ApplicationId);
            Assert.AreEqual <int>(4, set.NetworkPercentages.Length);
            Assert.AreEqual <double?>(row.NetworkPercentage1, set.NetworkPercentages[0]);
            Assert.AreEqual <double?>(row.NetworkPercentage2, set.NetworkPercentages[1]);
            Assert.AreEqual <double?>(row.NetworkPercentage3, set.NetworkPercentages[2]);
            Assert.AreEqual <double?>(row.NetworkPercentage4, set.NetworkPercentages[3]);
        }
        public void OccurredOn()
        {
            var data = DateTime.UtcNow;
            var row  = new LatestServerStatisticsRow(Guid.NewGuid());

            row.OccurredOn = data;
            Assert.AreEqual <DateTime>(data, row.OccurredOn);
        }
        public void DeploymentId()
        {
            var data = StringHelper.ValidString();
            var row  = new LatestServerStatisticsRow(Guid.NewGuid());

            row.DeploymentId = data;
            Assert.AreEqual <string>(data, row.DeploymentId);
        }
        public void PhysicalDiskUsagePercentage()
        {
            var random = new Random();
            var data   = random.Next();
            var row    = new LatestServerStatisticsRow(Guid.NewGuid());

            row.PhysicalDiskUsagePercentage = data;
            Assert.AreEqual <double>(data, row.PhysicalDiskUsagePercentage);
        }
        public void NetworkPercentage2()
        {
            var random = new Random();
            var data   = random.NextDouble();
            var row    = new LatestServerStatisticsRow(Guid.NewGuid());

            Assert.IsNull(row.NetworkPercentage2);
            row.NetworkPercentage2 = data;
            Assert.AreEqual <double?>(data, row.NetworkPercentage2);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Convert to Latest Server Statistics Row
        /// </summary>
        /// <returns>Latest Server Statistics Row</returns>
        LatestServerStatisticsRow IConvert <LatestServerStatisticsRow> .Convert()
        {
            var row = new LatestServerStatisticsRow(this.Token.ApplicationId)
            {
                CpuUsagePercentage          = this.CpuUsagePercentage,
                DeploymentId                = this.DeploymentId,
                RowKey                      = this.MachineName,
                MemoryUsagePercentage       = this.MemoryUsagePercentage,
                OccurredOn                  = this.OccurredOn,
                PhysicalDiskUsagePercentage = this.PhysicalDiskUsagePercentage,
            };

            if (null != this.NetworkPercentages)
            {
                int i = 0;
                foreach (var percentage in this.NetworkPercentages)
                {
                    switch (i)
                    {
                    case 0:
                        row.NetworkPercentage1 = this.NetworkPercentages[i];
                        break;

                    case 1:
                        row.NetworkPercentage2 = this.NetworkPercentages[i];
                        break;

                    case 2:
                        row.NetworkPercentage3 = this.NetworkPercentages[i];
                        break;

                    case 3:
                        row.NetworkPercentage4 = this.NetworkPercentages[i];
                        break;
                    }
                    i++;
                }
            }

            return(row);
        }