public void TestInitialize() { string teamProject = "Team Project"; string definitionName = "Definition Name"; string configuration = "Configuration"; string platform = "Platform"; this.key = string.Format("{0};{1}", teamProject, definitionName); this.mockService = new MockBuildServerService(); this.mockBuildInfo = new MockBuildInfo(BuildStatus.Stopped, "Requested For", DateTime.MinValue, true, DateTime.MinValue); this.model = new BuildInfoModel(teamProject, definitionName, configuration, platform, this.mockService); this.viewModel = new BuildInfoViewModel(this.model); }
private void Query(Object stateInfo) { Hashtable latestBuilds = new Hashtable(); Random random = new Random(); lock (this.builds) { foreach (string key in this.builds.Keys) { string[] build = key.Split(';'); string teamProject = build[0]; string definitionName = build[1]; int rand = random.Next(8); BuildStatus?status = BuildStatus.NotStarted; switch (rand) { case 0: status = BuildStatus.InProgress; break; case 1: status = BuildStatus.Succeeded; break; case 2: status = BuildStatus.Succeeded; break; case 3: status = BuildStatus.Failed; break; case 4: status = BuildStatus.Stopped; break; case 5: status = BuildStatus.NotStarted; break; case 6: status = BuildStatus.Succeeded; break; case 7: status = BuildStatus.PartiallySucceeded; break; //this.OnError(); //return; } MockBuildInfo latestBuild = null; if (status.HasValue) { var start = GetRandomDateTimeForStart(); latestBuild = new MockBuildInfo(status.Value, "DOMAIN\\Joe Bloggs", start, true, GetRandomDateTimeForEnd(start)); latestBuild.FailedTests.Clear(); switch (status) { case BuildStatus.Succeeded: latestBuild.TestsFailed = 0; latestBuild.TestsPassed = 1337; break; case BuildStatus.PartiallySucceeded: latestBuild.TestsFailed = 42; latestBuild.TestsPassed = 1066; latestBuild.FailedTests.Add("TestDatabase"); latestBuild.FailedTests.Add("TestLogin"); latestBuild.FailedTests.Add("TestPurchase"); break; } } latestBuilds.Add(key, latestBuild); } foreach (string key in latestBuilds.Keys) { this.builds[key] = latestBuilds[key]; } } this.OnQueryCompleted(); }
private void Query(Object stateInfo) { Hashtable latestBuilds = new Hashtable(); Random random = new Random(); lock (this.builds) { foreach (string key in this.builds.Keys) { string[] build = key.Split(';'); string teamProject = build[0]; string definitionName = build[1]; int rand = random.Next(8); BuildStatus? status = BuildStatus.NotStarted; switch (rand) { case 0: status = BuildStatus.InProgress; break; case 1: status = BuildStatus.Succeeded; break; case 2: status = BuildStatus.PartiallySucceeded; break; case 3: status = BuildStatus.Failed; break; case 4: status = BuildStatus.Stopped; break; case 5: status = BuildStatus.NotStarted; break; case 6: status = null; break; case 7: this.OnError(); return; } MockBuildInfo latestBuild = null; if (status.HasValue) { latestBuild = new MockBuildInfo(status.Value, "DOMAIN\\Joe Bloggs", GetRandomDateTime(), true, GetRandomDateTime()); switch (status) { case BuildStatus.Succeeded: latestBuild.TestsFailed = 0; latestBuild.TestsPassed = 1770; break; case BuildStatus.PartiallySucceeded: latestBuild.TestsFailed = 100; latestBuild.TestsPassed = 1670; break; } } latestBuilds.Add(key, latestBuild); } foreach (string key in latestBuilds.Keys) { this.builds[key] = latestBuilds[key]; } } this.OnQueryCompleted(); }