public async Task OneTimeSetup()
        {
            connectionFactory = TestUtilities.GetIntegrationConnectionFactory();
            userExperienceReportRepository = new UserExperienceReportRepository(connectionFactory);
            var hourRepo = new HourRepository(connectionFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            var serverRepo = new ServerRepository(connectionFactory);

            server = await serverRepo.CreateAsync(new Server
            {
                ServerName                       = Environment.MachineName,
                CreatedOn                        = DateTime.Now,
                DeletedOn                        = null,
                ServerTypeId                     = 3,
                ServerIpAddress                  = "127.0.0.1",
                IgnoreServer                     = false,
                ResponsibleAgent                 = "",
                ArtifactId                       = 1234,
                LastChecked                      = null,
                UptimeMonitoringResourceHost     = null,
                UptimeMonitoringResourceUseHttps = null,
                LastServerBackup                 = null,
                AdminScriptsVersion              = null,
            });
        }
        public async Task SetUp()
        {
            var connFactory = TestUtilities.GetIntegrationConnectionFactory();

            this.searchAuditBatchRepository = new SearchAuditBatchRepository(connFactory);
            var hourRepo = new HourRepository(connFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.UtcNow.NormilizeToHour() });

            Assert.That(hour, Is.Not.Null, "Must have a valid hour for tests");
            var serverRepo = new ServerRepository(connFactory);

            server = (await serverRepo.ReadAllActiveAsync()).FirstOrDefault();
            Assert.That(server, Is.Not.Null, "Must have a valid server for tests");

            this.HourAuditSearchBatchId =
                await this.searchAuditBatchRepository.CreateHourSearchAuditBatch(hour.Id, server.ServerId, 1);

            await this.searchAuditBatchRepository.CreateBatches(new[] {
                new SearchAuditBatch
                {
                    HourSearchAuditBatchId = this.HourAuditSearchBatchId,
                    WorkspaceId            = Config.WorkSpaceId,
                    BatchStart             = 0,
                    BatchSize = 5000
                }
            });

            this.searchAuditBatch = (await this.searchAuditBatchRepository.ReadBatchesByHourAndServer(hour.Id, server.ServerId)).FirstOrDefault();
        }
        public async Task OneTimeSetup()
        {
            var hourRepo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            this.metricRepository = new MetricRepository(ConnectionFactorySetup.ConnectionFactory);
            var serverRepository = new ServerRepository(ConnectionFactorySetup.ConnectionFactory);

            this.server = await serverRepository.CreateAsync(new Server
            {
                ServerName       = Environment.MachineName,
                CreatedOn        = DateTime.Now,
                DeletedOn        = null,
                ServerTypeId     = 3,
                ServerIpAddress  = "127.0.0.1",
                IgnoreServer     = false,
                ResponsibleAgent = "",
                ArtifactId       = 1234,
            });

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now.NormilizeToHour() });

            metric = await this.metricRepository.CreateAsync(new Metric { HourId = hour.Id, MetricType = MetricType.WebUptime });

            this.metricDataRepository = new MetricDataRepository(ConnectionFactorySetup.ConnectionFactory);
            metricData = await this.metricDataRepository.CreateAsync(new MetricData { MetricId = metric.Id, Score = 100.0m });

            metricData.Score = 75.0m;
            metricData.Data  = "asdf";
            await this.metricDataRepository.UpdateAsync(metricData);

            metricData = await this.metricDataRepository.ReadAsync(metricData.Id);
        }
        public async Task SetUp()
        {
            connectionFactory = TestUtilities.GetIntegrationConnectionFactory();

            var hourRepo   = new HourRepository(connectionFactory);
            var metricRepo = new MetricRepository(connectionFactory);
            var hour       = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            var metric = await metricRepo.CreateAsync(new Metric { HourId = hour.Id, MetricType = MetricType.WebUptime });

            var metricDataRepo = new MetricDataRepository(connectionFactory);

            metricData = await metricDataRepo.CreateAsync(new MetricData { MetricId = metric.Id, Score = 100.0m });

            var repo = new AuditAnalysisRepository(connectionFactory);
            await repo.CreateAsync(Enumerable.Range(0, 4).Select(i =>
                                                                 new AuditAnalysis
            {
                MetricDataId = metricData.Id,
                TotalQueries = 123,
                TotalLongRunningQueries = 234,
                TotalComplexQueries = 345,
                UserId = 456
            }).ToList());

            auditAnalyses = await repo.ReadByMetricData(metricData);
        }
        public async Task AgentHistory_ReadByHourAsync_Success()
        {
            //Arrange
            var hourRepo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);
            var hour     = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.UtcNow.NormilizeToHour() });

            //Act
            var result = await agentHistoryRepository.ReadByHourAsync(hour);

            //Assert
            Assert.That(result, Is.Not.Empty);
        }
Esempio n. 6
0
        public async Task OneTimeSetup()
        {
            var hourRepo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            categoryRepository = new CategoryRepository(ConnectionFactorySetup.ConnectionFactory);
            category           = await categoryRepository.CreateAsync(new Category { HourId = hour.Id, CategoryType = CategoryType.InfrastructurePerformance });

            category = await categoryRepository.ReadAsync(category.Id);

            category.CategoryType = CategoryType.Uptime;
            await categoryRepository.UpdateAsync(category);
        }
        public async Task OneTimeSetup()
        {
            var hourRepo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            metricRepository = new MetricRepository(ConnectionFactorySetup.ConnectionFactory);
            metric           = await metricRepository.CreateAsync(new Metric { HourId = hour.Id, MetricType = MetricType.AgentUptime });

            metric = await metricRepository.ReadAsync(metric.Id);

            metric.MetricType = MetricType.WebUptime;
            await metricRepository.UpdateAsync(metric);
        }
Esempio n. 8
0
        public async Task Exists_NewHour()
        {
            // Arrange
            var hour = await hourRepository.CreateAsync(new Hour
            {
                HourTimeStamp = DateTime.UtcNow.AddYears(-100),
                Score         = 110.0m,
                InSample      = true,
            });

            // Act
            var result = await this.ratingsRepository.Exists(hour.Id);

            // Assert
            Assert.That(result, Is.False);             // Newly created hour should not have QoSRating entry
        }
Esempio n. 9
0
        public async Task OneTimeSetup()
        {
            var hourRepo     = new HourRepository(ConnectionFactorySetup.ConnectionFactory);
            var categoryRepo = new CategoryRepository(ConnectionFactorySetup.ConnectionFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            category = await categoryRepo.CreateAsync(new Category { HourId = hour.Id, CategoryType = CategoryType.Uptime });

            categoryScoreRepository = new CategoryScoreRepository(ConnectionFactorySetup.ConnectionFactory);
            categoryScore           = await categoryScoreRepository.CreateAsync(new CategoryScore { CategoryId = category.Id, Score = 100.0m });

            categoryScore.Score = 75.0m;
            await categoryScoreRepository.UpdateAsync(categoryScore);

            categoryScore = await categoryScoreRepository.ReadAsync(categoryScore.Id);
        }
Esempio n. 10
0
        public async Task SetUp()
        {
            var nowHour = DateTime.UtcNow.NormilizeToHour();

            repo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            hour = await repo.CreateAsync(new Hour
            {
                HourTimeStamp = nowHour,
                Score         = 100.0m,
                InSample      = true
            });


            hour.Score = 75.0m;
            await repo.UpdateAsync(hour);

            hour = await repo.ReadAsync(hour.Id);
        }
Esempio n. 11
0
        public async Task Setup()
        {
            var hourRepository = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            this.repository             = new IntegrationTestNewHourRepository(ConnectionFactorySetup.ConnectionFactory, hourRepository);
            this.hourTestDataRepository = new HourTestDataRepository(ConnectionFactorySetup.ConnectionFactory, hourRepository);

            this.testHour = new MockHour {
                HourTimeStamp = DateTime.UtcNow.NormilizeToHour()
            };
            await this.hourTestDataRepository.CreateAsync(new List <MockHour> {
                this.testHour
            });

            var hourToCreate = new Hour {
                HourTimeStamp = DateTime.UtcNow.NormilizeToHour().AddHours(-4)
            };

            this.nonTestHour = await hourRepository.CreateAsync(hourToCreate);
        }
        public async Task OneTimeSetup()
        {
            var hourRepo = new HourRepository(ConnectionFactorySetup.ConnectionFactory);

            hour = await hourRepo.CreateAsync(new Hour { HourTimeStamp = DateTime.Now });

            this.eventRepository = new EventRepository(ConnectionFactorySetup.ConnectionFactory);
            evnt = await this.eventRepository.CreateAsync(new Event
            {
                Status     = EventStatus.Pending,
                HourId     = hour.Id,
                TimeStamp  = DateTime.Now,
                SourceType = EventSourceType.CreateNextHour,
                SourceId   = hour.Id,
                EventHash  = "x"
            });

            evnt = await this.eventRepository.ReadAsync(evnt.Id);

            evnt.Retries = (evnt.Retries ?? 0) + 1;
            await this.eventRepository.UpdateAsync(evnt);

            updatedEvent = await this.eventRepository.ReadAsync(evnt.Id);
        }