示例#1
0
        protected override void OnStart(string[] ignored)
        {
            try
            {
                if (string.IsNullOrEmpty(bootStrapper) == false)
                {
                    var assembly         = LoadAssembly();
                    var bootStrapperType = LoadBootStrapperType(assembly);
                    host = new RemoteAppDomainHost(bootStrapperType);
                    host.Configuration(cfg);
                }
                else
                {
                    host = new RemoteAppDomainHost(asm, cfg);
                }

                if (string.IsNullOrEmpty(hostType) == false)
                {
                    host.SetHostType(hostType);
                }

                host.Start();
            }
            catch (Exception x)
            {
                Log.Fatal("Hosted service failed to start", x);
                throw;
            }
        }
 protected override void OnStart(string[] ignored)
 {
     host = new RemoteAppDomainHost(asm, cfg);
     if (string.IsNullOrEmpty(hostType) == false)
         host.SetHostType(hostType);
     host.Start();
 }
示例#3
0
 protected override void OnStart(string[] ignored)
 {
     host = new RemoteAppDomainHost(asm, cfg);
     if (string.IsNullOrEmpty(hostType) == false)
     {
         host.SetHostType(hostType);
     }
     host.Start();
 }
        public void prepare_contest_submit_solution_save_result()
        {
            var realProblemDirectory = @".\..\..\Tester\TestPrograms\RealProblem";

            var zip  = File.ReadAllBytes(Path.Combine(realProblemDirectory, "tests2.zip"));
            var user = new User {
                DisplayName = "User"
            };
            var contest = new Contest {
                Beginning = new DateTime(1990, 7, 7), Ending = new DateTime(1990, 7, 7), Type = "Icpc"
            };
            var problem = new Problem
            {
                Contest = contest,
                Limits  = new ResourceUsage
                {
                    MemoryInBytes      = int.MaxValue,
                    TimeInMilliseconds = 100500
                },
                TestInfo = new TestInfo
                {
                    Checker = new ProgramSource
                    {
                        LanguageId = "MSVC90Testlib",
                        Code       = File.ReadAllText(Path.Combine(realProblemDirectory, "check.cpp"))
                    }
                }
            };

            var submission = new Submission
            {
                Author  = user,
                Problem = problem,
                Source  = new ProgramSource
                {
                    Code       = File.ReadAllText(Path.Combine(realProblemDirectory, "tree_ai.cpp")),
                    LanguageId = "MSVC90"
                },
                SubmittedAt = contest.Beginning
            };

            var brokerHost = new RemoteAppDomainHost(typeof(BrokerBootstrapper));

            brokerHost.SetHostType(typeof(TestHost));
            brokerHost.Start();

            var testerHost = new RemoteAppDomainHost(typeof(TesterBootstrapper));

            testerHost.SetHostType(typeof(TestHost));
            testerHost.Start();

            var webHost = new TestHost(@".\..\..\Integration\WebEndpoint.config");

            webHost.Start <TestWebBootstrapper>();

            var bus = webHost.Container.Resolve <IServiceBus>();

            using (var factory = new TestDatabaseConfiguration().DatabaseConfiguration.BuildSessionFactory())
            {
                using (var scope = new SessionScope(factory))
                {
                    var session = scope.Session;
                    session.Save(user);
                    session.Save(contest);
                    session.Save(problem);
                    session.Save(submission);
                }

                bus.Send(new UnpackTestInfo {
                    ProblemId = problem.Id, ZipArchive = zip
                });
                bus.Send(new JudgeSubmission {
                    SubmissionId = submission.Id
                });

                Thread.Sleep(100000);

                using (var scope = new SessionScope(factory))
                {
                    submission = scope.Session.Get <Submission>(submission.Id);
                    Assert.Equal(SubmissionTestingStatus.Finished, submission.TestingStatus);
                    Assert.NotNull(submission.Result);
                    Assert.Contains("Accepted", submission.Result.Verdict);
                }
            }
        }