void ITestService.TestTestsuite(int testerId, int testsystemId, int testsuiteId)
		{
			Testsuite testsuite  = _testsuiteRepository.GetById(testsuiteId);
			Testsystem testsystem = _testsystemRepository.GetById(testsystemId);
			Tester tester = _testerRepository.GetById(testerId);

			TestJob testJob = CreateTestJob("Testsuite " + testsuite.Name, testsuite, testsystem, tester);

			ITestJobManager testJobManager = new TestJobManager(testJob);

			ICollection<WorkItem> workItems = (from testcase in testsuite.Testcases
			                               from browser in testsuite.Browsers
			                               from language in testsuite.Languages
												  select new WorkItem(testJobManager)
				                               {
					                               Testcase = testcase,
												   Browser = browser,
												   Language = language,
												   Testsystem = testsystem,
												   Tester = tester 
				                               }).ToList();

			_testPool.AddTestJob(testJobManager, workItems);
		}
		void ITestService.TestFailedTestsOfTestsuite(int testerId, int testsystemId, int testsuiteId)
		{
			Testsuite testsuite = _testsuiteRepository.GetById(testsuiteId);
			IList<Result> errorResults = _resultRepository.GetErrorResultsOfTestsuite(testsystemId, testsuite.Browsers, testsuite.Testcases,
				testsuite.Languages);
			Testsystem testsystem = _testsystemRepository.GetById(testsystemId);
			Tester tester = _testerRepository.GetById(testerId);

			TestJob testjob = CreateTestJob("Repeat failed of " + testsuite.Name, testsuite, testsystem, tester);

			ITestJobManager testjobManager = new TestJobManager(testjob);

			ICollection<WorkItem> workItems = (from result in errorResults
												  select new WorkItem(testjobManager)
												  {
													  Testcase = result.Testcase,
													  Browser = result.Browser,
													  Language = result.Language,
													  Testsystem = testsystem,
													  Tester = tester
												  }).ToList();

			_testPool.AddTestJob(testjobManager, workItems);
		}
		void ILocalTestService.AddTestsuiteTask(string userName, string testsystemName, string testsystemUrl, string testsuiteName)
		{
			Testsuite testsuite = _testsuiteRepository.GetByName(testsuiteName);
			Testsystem testsystem = _testsystemRepository.GetByName(testsystemName);
			testsystem.Url = testsystemUrl;
			_testsystemRepository.Store(testsystem);

			Tester tester = _testerRepository.GetByName(userName);
			string testjobname =  "Testsuite " + testsuite.Name + " on " + testsystem.Url;

			TestJob testjob = new TestJob
			{
				Name = testjobname,
				ResultCode = TestState.Pending,
				Testsuite = testsuite,
				Testsystem = testsystem,
				Tester = tester,
				StartedAt = DateTime.Now,
				JobType = JobType.Localtesttool
			};

			ITestJobManager testJobManager = new TestJobManager(testjob);

			ICollection<WorkItem> workItems = (from testcase in testsuite.Testcases
											   from browser in testsuite.Browsers
											   from language in testsuite.Languages
											   select new WorkItem(testJobManager)
											   {
												   Testcase = testcase,
												   Browser = browser,
												   Language = language,
												   Testsystem = testsystem,
												   Tester = tester
											   }).ToList();

			_testPool.AddTestJob(testJobManager, workItems);
		}
		int IBuildTaskService.AddRegTestTasks(string testsystemName, string emailReceiver, string testsuiteName, string branch, string commitId, string commitMessage)
		{
			Testsuite testsuite = _testsuiteRepository.GetByName(testsuiteName);
			Testsystem testsystem = _testsystemRepository.GetByName(testsystemName);
			Tester tester = _testerRepository.GetByName(emailReceiver);
			string testjobname;
			if (!String.IsNullOrEmpty(commitId) && !String.IsNullOrEmpty(branch))
			{
				testjobname = "Commit " + commitId + " on " + ParseBranchName(branch);
			}
			else
			{
				testjobname = "Testsuite " + testsuiteName;
			}

			TestJob testjob = new TestJob
			{
				Name = testjobname,
				Description = commitMessage,
				ResultCode = TestState.Pending,
				Testsuite = testsuite,
				Testsystem = testsystem,
				Tester = tester,
				StartedAt = DateTime.Now,
				JobType = JobType.Buildtask
			};

			ITestJobManager testJobManager = new TestJobManager(testjob);

			ICollection<WorkItem> workItems = (from testcase in testsuite.Testcases
												  from browser in testsuite.Browsers
												  from language in testsuite.Languages
												  select new WorkItem(testJobManager)
												  {
													  Testcase = testcase,
													  Browser = browser,
													  Language = language,
													  Testsystem = testsystem,
													  Tester = tester
												  }).ToList();

			_testPool.AddTestJob(testJobManager, workItems);
			return testjob.ID;
		}
		void ILocalTestService.AddLocalTestTasks(string userName, string testsystemName, string testsystemUrl, List<string> browsers,
			List<string> testcases, List<string> languages)
		{
			
			Testsystem testsystem = _testsystemRepository.GetByName(testsystemName);
			Tester tester = _testerRepository.GetByName(userName);

			testsystem.Url = testsystemUrl;
			_testsystemRepository.Store(testsystem);

			Testsuite testsuite = new Testsuite { Description = "", Name = "Local " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), TestsystemFilter = testsystem };
			_testsuiteRepository.Store(testsuite);

			int testsuiteId = testsuite.ID;
			List<int> testcaseIds = testcases.Select(t => _testcaseRepository.GetByType(t).ID).ToList();
			List<int> browserIds = browsers.Select(t => _browserRepository.GetByName(t).ID).ToList();
			List<int> languageIds = languages.Select(t => _languageRepository.GetByLanguageCode(t).ID).ToList();


			_testsuiteRepository.SetTestcasesForTestsuite(testsuiteId, testcaseIds);
			_testsuiteRepository.SetBrowsersForTestsuite(testsuiteId, browserIds);
			_testsuiteRepository.SetLanguagesForTestsuite(testsuiteId, languageIds);


			TestJob testjob = new TestJob
			{
				Name = "A set of tests on " + testsystem.Url,
				ResultCode = TestState.Pending,
				Testsuite = testsuite,
				Testsystem = testsystem,
				Tester = tester,
				StartedAt = DateTime.Now,
				JobType = JobType.Localtesttool
			};

			ITestJobManager testJobManager = new TestJobManager(testjob);

			ICollection<WorkItem> workItems = (from testcase in testsuite.Testcases
												  from browser in testsuite.Browsers
												  from language in testsuite.Languages
												  select new WorkItem(testJobManager)
												  {
													  Testcase = testcase,
													  Browser = browser,
													  Language = language,
													  Testsystem = testsystem,
													  Tester = tester
												  }).ToList();

			_testPool.AddTestJob(testJobManager, workItems);
		}