Ejemplo n.º 1
0
 public void TearDown()
 {
     if (Host != null)
     {
         Host.CloseHttp();
         Host = null;
     }
 }
Ejemplo n.º 2
0
        public static void PreAppStart()
        {
            if (HostingEnvironment.InClientBuildManager)
            {
                // If we're in the VS app domain then do nothing
                return;
            }

            var kernel = new StandardKernel();

            kernel.Bind <JabbrContext>()
            .To <JabbrContext>()
            .InRequestScope();

            kernel.Bind <IJabbrRepository>()
            .To <PersistedRepository>()
            .InRequestScope();

            kernel.Bind <IChatService>()
            .To <ChatService>()
            .InRequestScope();

            kernel.Bind <ICryptoService>()
            .To <CryptoService>()
            .InSingletonScope();

            kernel.Bind <IResourceProcessor>()
            .To <ResourceProcessor>()
            .InSingletonScope();

            kernel.Bind <IApplicationSettings>()
            .To <ApplicationSettings>()
            .InSingletonScope();

            Kernel = kernel;

            var resolver = new NinjectDependencyResolver(kernel);

            AspNetHost.SetResolver(resolver);

            // Perform the required migrations
            DoMigrations();

            // Start the sweeper
            var repositoryFactory = new Func <IJabbrRepository>(() => kernel.Get <IJabbrRepository>());

            _timer = new Timer(_ => Sweep(repositoryFactory, resolver), null, _sweepInterval, _sweepInterval);

            SetupErrorHandling();

            ClearConnectedClients(repositoryFactory());

            SetupRoutes(kernel);
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            if (_aspNetHost == null)
            {
                lock (_lockObj)
                {
                    if (_aspNetHost == null)
                    {
                        SandboxHelper.ExecuteInFullTrust(
                            () =>
                        {
                            var aspNetRootFolder = WorkerConfiguration.Current.AspNetRootFolder;
                            if (!aspNetRootFolder.EndsWith("\\"))
                            {
                                aspNetRootFolder += "\\";
                            }

                            CopySiteRoot(aspNetRootFolder);

                            string virtualFolder = "/MvcPageAction/" + WorkerConfiguration.Current.ID + "/";

                            _aspNetHost = new AspNetHost(aspNetRootFolder, virtualFolder);

                            try
                            {
                                _aspNetHost.Start();
                            }
                            catch (Exception ex)
                            {
                                ex.ToString();
                                throw;
                            }
                            HostingEnvironment.RegisterVirtualPathProvider(new FakeVirtualPathProvider());

                            // we just do empty request to not existing file, so Asp.Net would initialize Http Application in full trust, and next request can be processed in sandbox
                            StringWriter writer        = new StringWriter();
                            SimpleWorkerRequest worker = new SimpleWorkerRequest("static/Warmup.aspx", null, writer);
                            HttpRuntime.ProcessRequest(worker);
                            writer.Flush();

                            string html = writer.ToString();
                            html.ToString();
                        });
                    }
                }
            }
            base.Initialize();
        }
Ejemplo n.º 4
0
 public void BadRequestsGenerateValidErrorResponsesHosted()
 {
     try {
         using (AspNetHost host = AspNetHost.CreateHost(TestWebDirectory)) {
             Uri opEndpoint       = new Uri(host.BaseUri, "/OpenIdProviderEndpoint.ashx");
             var rp               = new OpenIdRelyingParty(null);
             var nonOpenIdMessage = new Mocks.TestDirectedMessage();
             nonOpenIdMessage.Recipient   = opEndpoint;
             nonOpenIdMessage.HttpMethods = HttpDeliveryMethods.PostRequest;
             MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, nonOpenIdMessage);
             var response = rp.Channel.Request <DirectErrorResponse>(nonOpenIdMessage);
             Assert.IsNotNull(response.ErrorMessage);
         }
     } catch (FileNotFoundException ex) {
         Assert.Inconclusive("Unable to execute hosted ASP.NET tests because {0} could not be found.  {1}", ex.FileName, ex.FusionLog);
     }
 }
		protected override void Initialize()
		{
			if (_aspNetHost == null)
			{
				lock (_lockObj)
				{
					if (_aspNetHost == null)
					{
						SandboxHelper.ExecuteInFullTrust(
							() =>
							{
								var aspNetRootFolder = WorkerConfiguration.Current.AspNetRootFolder;
								if (!aspNetRootFolder.EndsWith("\\"))
									aspNetRootFolder += "\\";

								CopySiteRoot(aspNetRootFolder);

								string virtualFolder = "/MvcPageAction/" + WorkerConfiguration.Current.ID + "/";

								_aspNetHost = new AspNetHost(aspNetRootFolder, virtualFolder);

								try
								{
									_aspNetHost.Start();
								}
								catch (Exception ex)
								{
									ex.ToString();
									throw;
								}
								HostingEnvironment.RegisterVirtualPathProvider(new FakeVirtualPathProvider());

								// we just do empty request to not existing file, so Asp.Net would initialize Http Application in full trust, and next request can be processed in sandbox
								StringWriter writer = new StringWriter();
								SimpleWorkerRequest worker = new SimpleWorkerRequest("static/Warmup.aspx", null, writer);
								HttpRuntime.ProcessRequest(worker);
								writer.Flush();

								string html = writer.ToString();
								html.ToString();
							});
					}
				}
			}
			base.Initialize();
		}
 static OpenRastaModule()
 {
     Host = new AspNetHost();
 }
Ejemplo n.º 7
0
 static OpenRastaModule()
 {
     Host = new AspNetHost();
     Log = NullLogger<AspNetLogSource>.Instance;
 }
Ejemplo n.º 8
0
 public void concrete()
 {
     AspNetHost.FindTypeInOpenRastaProject <SeekedType>().ShouldNotBeNull();
 }
Ejemplo n.º 9
0
 public void interface_implementation()
 {
     AspNetHost.FindTypeInOpenRastaProject <ISeekedInterface>()
     .ShouldBeOfType <SeekedImplementer>()
     .ShouldNotBeNull();
 }
Ejemplo n.º 10
0
 public void SetUp()
 {
     Host = AspNetHost.CreateHost(TestSupport.TestWebDirectory);
 }
Ejemplo n.º 11
0
 public HomeController(AspNetHost host)
 {
     _host = host;
 }