예제 #1
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            ServerWiring.initServer(new FakeMedTrainDBContext(1));
            IServer a = ServerWiring.getInstance();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
예제 #2
0
        public void TestInitialize()
        {
            ServerWiring.initServer(new FakeMedTrainDBContext());

            // We need to setup the Current HTTP Context as follows:

            // Step 1: Setup the HTTP Request
            var httpRequest = new HttpRequest("", "http://localhost/", "");

            // Step 2: Setup the HTTP Response
            var httpResponce = new HttpResponse(new StringWriter());

            // Step 3: Setup the Http Context
            var httpContext      = new HttpContext(httpRequest, httpResponce);
            var sessionContainer =
                new HttpSessionStateContainer("id",
                                              new SessionStateItemCollection(),
                                              new HttpStaticObjectsCollection(),
                                              10,
                                              true,
                                              HttpCookieMode.AutoDetect,
                                              SessionStateMode.InProc,
                                              false);

            httpContext.Items["AspSession"] =
                typeof(HttpSessionState)
                .GetConstructor(
                    BindingFlags.NonPublic | BindingFlags.Instance,
                    null,
                    CallingConventions.Standard,
                    new[] { typeof(HttpSessionStateContainer) },
                    null)
                .Invoke(new object[] { sessionContainer });

            // Step 4: Assign the Context
            HttpContext.Current = httpContext;
        }