Exemple #1
0
        public void ConvertNetworkPercentage2()
        {
            var random  = new Random();
            var network = new float[] { random.Next(), random.Next() };
            var set     = new ServerStatisticSet()
            {
                CpuUsagePercentage          = random.Next(100),
                MemoryUsagePercentage       = random.Next(100),
                PhysicalDiskUsagePercentage = random.Next(100),
                DeploymentId = StringHelper.ValidString(),
                MachineName  = StringHelper.ValidString(),
                OccurredOn   = DateTime.UtcNow,
                Token        = new Token()
                {
                    ApplicationId = Guid.NewGuid()
                },
                NetworkPercentages = network,
            };

            var row = set.Convert();

            Assert.AreEqual <double>(set.CpuUsagePercentage, row.CpuUsagePercentage);
            Assert.AreEqual <double>(set.MemoryUsagePercentage, row.MemoryUsagePercentage);
            Assert.AreEqual <double>(set.PhysicalDiskUsagePercentage, row.PhysicalDiskUsagePercentage);
            Assert.AreEqual <DateTime>(set.OccurredOn, row.OccurredOn);
            Assert.AreEqual <string>(set.DeploymentId, row.DeploymentId);
            Assert.AreEqual <string>(set.MachineName, row.MachineName);
            Assert.AreEqual <Guid>(set.Token.ApplicationId, row.ApplicationId);

            Assert.AreEqual <double?>(network[0], row.NetworkPercentage1);
            Assert.AreEqual <double?>(network[1], row.NetworkPercentage2);
            Assert.IsNull(row.NetworkPercentage3);
            Assert.IsNull(row.NetworkPercentage4);
        }
        public void Log(ServerStatisticSet data)
        {
            Contract.Requires <ArgumentNullException>(null != data);
            Contract.Requires <ArgumentNullException>(null != data.Token);
            Contract.Requires <ArgumentException>(Guid.Empty != data.Token.ApplicationId);

            using (new PerformanceMonitor())
            {
                this.serverStatisticsTable.AddEntity(data.Convert());
                this.latestServerStatisticsTable.AddOrUpdateEntity(((IConvert <LatestServerStatisticsRow>)data).Convert());

                this.StoreByteCount(data.Token.ApplicationId, DataCostType.Stored, data);
            }
        }