Пример #1
0
        public TestGroup CreateTestGroup(int groupId)
        {
            var testGroup = _testGroupRepository.GetDataById(groupId).FirstOrDefault();

            if (testGroup == null)
            {
                throw new Exception("Test Group not found.");
            }

            testGroup.Tests = new Collection <Test>();
            foreach (var test in _testRepository.GetActiveDataByGroupId(groupId))
            {
                testGroup.Tests.Add(_testFactory.CreateTest(test.Id));
            }

            return(testGroup);
        }
Пример #2
0
        public Project CreateProject(int projectId)
        {
            var project = _projectRepository.GetDataByProjectId(projectId).FirstOrDefault();

            if (project == null)
            {
                throw new Exception("Project not found.");
            }

            project.Tests = new Collection <Test>();
            foreach (var test in _testRepository.GetActiveDataByProjectId(projectId))
            {
                project.Tests.Add(_testFactory.CreateTest(test.Id));
            }

            project.TestGroups = new Collection <TestGroup>();
            foreach (var testGroup in _testGroupRepository.GetActiveDataByProjectId(projectId))
            {
                testGroup.Tests = new Collection <Test>();
                var dTests = new Collection <Test>();
                var @group = testGroup;
                foreach (var test in project.Tests.Where(test => test.GroupId == @group.Id))
                {
                    testGroup.Tests.Add(test);
                    dTests.Add(test);
                }

                foreach (var test in dTests)
                {
                    project.Tests.Remove(test);
                }

                project.TestGroups.Add(testGroup);
            }


            return(project);
        }