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);
                              });
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        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);
        }