public void should_record_a_successful_run() { var userAgent = new UserAgent("browser", "Browser", null); var job = new Job("job"); var run = new Run(job, "run", "http://foo"); var runUserAgent = new RunUserAgent(run, userAgent); Client client = userAgent.SpawnNewClient("ip", "os"); run.BeginClientRun(client); Save(userAgent, job, run, runUserAgent, client, run.ClientRuns.Single()); var runCompleted = new CompleteRun { Client_Id = client.Id, Run_id = run.Id, Total = 10 }; // WithDbContext(context => GetInstance<CompleteRunHandler>().Handle(runCompleted)); WithDbContext(context => { GetInstance<CompleteRunHandler>().Handle(runCompleted); var foundRun = context.Find<Run>(run.Id); var single = foundRun.RunUserAgents.Single(); var clientRun = single.Run.ClientRuns.Where(x => x.Client.UserAgent.Id == single.UserAgent.Id).FirstOrDefault() ?? new ClientRun(); clientRun.IndicatesSuccess().ShouldBeTrue(); single.RemainingRuns.ShouldEqual(0); single.RunStatus.ShouldEqual(RunStatusType.Finished); }); }
public RunUserAgent(Run run, UserAgent userAgent, int? maxRuns = 1) { Run = run; UserAgent = userAgent; RunStatus = RunStatusType.NotStarted; RemainingRuns = MaxRuns = maxRuns.GetValueOrDefault(); Result = new RunUserAgentResult(); }
public void When_there_is_one_run_and_one_user_agent_and_the_run_user_agent_has_not_started() { run = new Run(new Job("job"){Id = 4}, "run", "url"){Id = 1}; userAgent = new UserAgent("chrome", "chrome", null) {Id = 2}; runUserAgent = new RunUserAgent(run, userAgent, 1){Id = 3}; result = runUserAgent.ToResult(); var results = new[] { result }; status = new JobStatusResult(results); }
protected override void TestFixtureSetUp() { var now = new DateTime(2000, 3, 3, 3, 15, 0); var almost5MinutesAgo = now.AddMinutes(-5).AddSeconds(1); SetTime(almost5MinutesAgo); // set up a clientrun that is in progress but has been running for five minutes var userAgent = new UserAgent("browser", "Browser", null); var job = new Job("job"); var run = new Run(job, "run", "http://foo"); var runUserAgent = new RunUserAgent(run, userAgent); Client client = userAgent.SpawnNewClient("ip", "os"); run.BeginClientRun(client); Save(userAgent, job, run, runUserAgent, client, run.ClientRuns.Single()); // create a wipe handler in the present var wipeHandler = new WipeHandler(DbContext(), SetTime(now)); // wipe wipeHandler.Handle(null); }
Run GetRun(Run run) { return _context.AllIncluding<Run>(x => x.RunUserAgents.Select(r => r.UserAgent), x => x.ClientRuns, x => x.Job).Single(x => x.Id == run.Id); }
public ClientRun(Client client, Run run) { Client = client; Run = run; }
public void When_there_are_three_runs_and_four_user_agents_and_the_run_user_agents_have_not_started() { run1 = new Run(new Job("job") { Id = 1 }, "run a", "url a") { Id = 2 }; run2 = new Run(new Job("job") { Id = 1 }, "run b", "url b") { Id = 3 }; run3 = new Run(new Job("job") { Id = 1 }, "run c", "url c") { Id = 4 }; run4 = new Run(new Job("job") { Id = 1 }, "run d", "url d") { Id = 5 }; chrome = new UserAgent("chrome", "chrome", null) { Id = 14 }; ie6 = new UserAgent("ie", "ie 6", 6) { Id = 11 }; ie7 = new UserAgent("ie", "ie 7", 7) { Id = 12 }; ie8 = new UserAgent("ie", "ie 8", 8) { Id = 13 }; status = new JobStatusResult(GetResults(new[] { run4, run2, run1, run3, }, new[] { chrome, ie6, ie7, ie8 })); }
public void When_there_is_one_runs_and_four_user_agents_and_the_run_user_agents_have_not_started() { run = new Run(new Job("job") { Id = 1 }, "run", "url") { Id = 2 }; chrome = new UserAgent("chrome", "chrome", null) { Id = 3 }; ie6 = new UserAgent("ie", "ie 6", 6) { Id = 11 }; ie7 = new UserAgent("ie", "ie 7", 7) { Id = 12 }; ie8 = new UserAgent("ie", "ie 8", 8) { Id = 13 }; chrome_run = new RunUserAgent(run, chrome, 1) { Id = 101 }; ie6_run = new RunUserAgent(run, ie6, 1) { Id = 102 }; ie7_run = new RunUserAgent(run, ie7, 1) { Id = 103 }; ie8_run = new RunUserAgent(run, ie8, 1) { Id = 104 }; result1 = chrome_run.ToResult(); result2 = ie6_run.ToResult(); result3 = ie7_run.ToResult(); result4 = ie8_run.ToResult(); var results = new[] { result3, result2, result4, result1 }; status = new JobStatusResult(results); }