Ejemplo n.º 1
0
        public void CreateTestPlan(TestPlan plan)
        {
            plan.CreatedDate = DateTime.UtcNow;

            if (plan.Name.IsNullOrEmpty())
                throw new ArgumentNullException("Name");

            if (plan.Slug.IsNullOrEmpty())
                plan.Slug = plan.Name.SafeVarName().ToLower();

            if (Db.Count<TestPlan>(q => q.Slug == plan.Slug) > 0)
                throw new ArgumentException("Slug already exists", "Slug");

            plan.UserAuthId = GetSignedInUserId();

            Db.Insert(plan);
        }
Ejemplo n.º 2
0
        private TestPlan AddMissingLabels(TestPlan testPlan)
        {
            var distinctResults = Db.Select(Db.From<TestResult>()
                .SelectDistinct(x => new { x.Hostname, x.Port, x.RequestPath })
                .Where(q => q.TestPlanId == testPlan.Id));

            if (testPlan.ServerLabels == null)
                testPlan.ServerLabels = new Dictionary<string, string>();

            if (testPlan.TestLabels == null)
                testPlan.TestLabels = new Dictionary<string, string>();

            var serverLabels = distinctResults.ConvertAll(x => x.Hostname + ":" + x.Port).ToHashSet();
            serverLabels.Each(x => {
                if (!testPlan.ServerLabels.ContainsKey(x))
                    testPlan.ServerLabels[x] = "";
            });

            var testLabels = distinctResults.ConvertAll(x => x.RequestPath).ToHashSet();
            testLabels.Each(x =>
            {
                if (!testPlan.TestLabels.ContainsKey(x))
                    testPlan.TestLabels[x] = "";
            });

            return testPlan;
        }