private TestsystemSummary CreateTestsystemSummary(Testsystem testsystem, Testsuite testsuite, TestsystemSummariesCache cache)
		{
			lock (cache.GetLock(testsystem.ID))
			{
				
				TestsystemSummary cachedResult = cache.Get(testsystem.ID);

				if (cachedResult != null)
					return cachedResult;


				IList<Result> results = _resultRepository.GetListOfResults(testsystem.ID, testsuite.Browsers, testsuite.Testcases,
													  testsuite.Languages);

				TestsystemSummary testsystemSummary = new TestsystemSummary
				{
					TestsuiteName = testsuite.Name,
					TestsuiteID = testsuite.ID,
					TestsystemName = testsystem.Name,
					TestsystemID = testsystem.ID,
				};

				if (results.Count != 0)
				{
					testsystemSummary.LastChangeDate = results.Min(t => t.Testtime);
					testsystemSummary.TestsystemStatus = results.Max(t => t.ResultCode);
				}
				else
				{
					testsystemSummary.LastChangeDate = DateTime.MinValue;
					testsystemSummary.TestsystemStatus = (int)TestState.NotSet;
				}

				cache.Set(testsystem.ID, testsystemSummary);
				return testsystemSummary;
			}
		}
Esempio n. 2
0
		private static TestJob CreateTestJob(string name, Testsuite testsuite, Testsystem testsystem, Tester tester)
		{
			TestJob testjob = new TestJob
			{
				Name = name,
				ResultCode = TestState.Pending,
				Testsuite = testsuite,
				Testsystem = testsystem,
				Tester = tester,
				StartedAt = DateTime.Now,
				JobType = JobType.Testportal
			};
			return testjob;
		}
		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);
		}