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);
                              });
        }
Example #2
0
 public Run(Job job, string name, string url)
 {
     Job = job;
     Url = url;
     Name = name;
     RunStatus = RunStatusType.NotStarted;
     ClientRuns = new HashSet<ClientRun>();
     RunUserAgents = new HashSet<RunUserAgent>();
 }
 public Job GetPreviousCompleteJob(Job job)
 {
     // this assumes one job suite for the entire system
     // TODO incorporate SuiteId
     return (from jobs in _db.All<Job>()
             where jobs.Status == JobStatusType.Complete && jobs.Finished < job.Finished
             orderby jobs.Finished descending
             select jobs).Take(1).SingleOrDefault();
 }
Example #4
0
        public Job AddJob(string name, string correlation)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name", "name is required");
            }

            var job = new Job(name)
            {
                Correlation = correlation
            };

            Jobs.Add(job);

            return job;
        }
Example #5
0
        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);
        }
Example #6
0
 public CreateJobResult(Job job)
 {
     JobId = job.Id;
 }
 public JobCompleted(Job job)
 {
     JobId = job.Id;
 }