Exemple #1
0
        /// <summary>
        /// Starts the webserver and returns the URL.
        /// </summary>
        public Uri Start()
        {
            //NOTE: WebServer.WebHost is going to load itself AGAIN into another AppDomain,
            // and will be getting it's Assemblies from the BIN, including another copy of itself!
            // Therefore we need to do this step FIRST because I've removed WebServer.WebHost from the GAC
            if (!Directory.Exists(webRoot))
            {
                Directory.CreateDirectory(webRoot);
            }

            if (!Directory.Exists(webBinDir))
            {
                Directory.CreateDirectory(webBinDir);
            }

            CopyAssembliesToWebServerBinDirectory();

            //Start the internal Web Server pointing to our test webroot
            //webServer = new Server(webServerPort, webServerVDir, this.webRoot);
            webServer = new CassiniDevServer();
            webServer.StartServer(webRoot, webServerPort, webServerVDir, "localhost");

            webServerUrl = String.Format("http://localhost:{0}{1}", webServerPort, webServerVDir);

            //webServer.Start();
            started = true;
            Debug.WriteLine(String.Format("Web Server started on port {0} with VDir {1} in physical directory {2}", webServerPort, webServerVDir, this.webRoot));
            return(new Uri(webServerUrl));
        }
Exemple #2
0
        public void SetupWebSite()
        {
            var siteLocation = GetUsableSitePath();

            _server = new CassiniDevServer();
            _server.StartServer(siteLocation);
        }
Exemple #3
0
 public void TestMethod1()
 {
     var server = new CassiniDevServer();
     server.StartServer(Environment.CurrentDirectory);
     var url = server.NormalizeUrl("test-page.htm");
     WebClient client = new WebClient();
     var response = client.DownloadString(url);
     Assert.IsTrue(response.Contains("test page"));
     server.StopServer();
 }
Exemple #4
0
        public void CheckNetLatency()
        {
            Console.WriteLine("Checking .net latency");

            var server = new CassiniDevServer();

            server.StartServer(Environment.CurrentDirectory);

            var ctx = new Client(new Uri(server.NormalizeUrl("/")), new Uri(server.NormalizeUrl("/")), "foo");

            DateTimeOffset            requestRecieved = DateTimeOffset.MinValue;
            RequestCompletedEventArgs requestInfo     = null;

            ctx.RequestCompleted += (i, e) =>
            {
                requestInfo = e;
            };
            server.Server.ProcessRequest += (i, e) =>
            {
                e.Continue       = false;
                e.Response       = LoggedIn;
                e.ResponseStatus = 200;
                requestRecieved  = DateTimeOffset.UtcNow;
            };


            try
            {
                ctx.LogIn(Settings.RpcUserName, Settings.RpcPassword);
            }
            finally
            {
                server.Dispose();
            }

            Console.WriteLine("elapsed   {0}", requestInfo.Info.Watch.ElapsedMilliseconds);

            // #TODO: not sure i like the complete removal of temporal data

            //Console.WriteLine("issued   {0}", requestInfo.Info.Issued.Ticks);
            //Console.WriteLine("recieved {0}", requestRecieved.Ticks);
            //Console.WriteLine("competed {0}", requestInfo.Info.Completed.Ticks);

            //Console.WriteLine("issued to recieved {0}", TimeSpan.FromTicks(requestRecieved.Ticks - requestInfo.Info.Issued.Ticks));
            //Console.WriteLine("recieved to completed {0}", TimeSpan.FromTicks(requestInfo.Info.Completed.Ticks - requestRecieved.Ticks));
            //Console.WriteLine("issued to completed {0}", TimeSpan.FromTicks(requestInfo.Info.Completed.Ticks - requestInfo.Info.Issued.Ticks));



            Assert.IsNotNullOrEmpty(ctx.Session);



            ctx.Dispose();
        }
        public static void Start()
        {
            var security = new SemaphoreSecurity();

            security.AddAccessRule(new SemaphoreAccessRule("Everyone", SemaphoreRights.FullControl, AccessControlType.Allow));

            _server = new CassiniDevServer();
            _server.StartServer(@"..\..\..\FormUI", 54070, "/", "localhost");

            RootUrl = _server.RootUrl;
        }
Exemple #6
0
        public Form1()
        {
            InitializeComponent();

            _server = new CassiniDevServer();

            // our content is Copy Always into bin
            _server.StartServer(Path.Combine(Environment.CurrentDirectory, "WebContent"));

            _webBrowser1.Navigate(_server.NormalizeUrl("Default.aspx"));
        }
Exemple #7
0
        public void TestMethod1()
        {
            var server = new CassiniDevServer();

            server.StartServer(Environment.CurrentDirectory);
            var       url      = server.NormalizeUrl("test-page.htm");
            WebClient client   = new WebClient();
            var       response = client.DownloadString(url);

            Assert.IsTrue(response.Contains("test page"));
            server.StopServer();
        }
Exemple #8
0
        public void Example1()
        {
            CassiniDevServer server = new CassiniDevServer();

            server.StartServer(Path.Combine(Environment.CurrentDirectory, @"..\..\..\CassiniDevHostingExample"));
            string url = server.NormalizeUrl("/");

            Console.WriteLine(url);
            var dom = CsQuery.Server.CreateFromUrl(url);

            Console.WriteLine(dom.Text());
            StringAssert.Contains("Welcome to ASP.NET MVC!", dom.Text());
        }
Exemple #9
0
 /// <summary>
 /// Starts the built in webserver if it is enabled via config.
 /// </summary>
 /// <remarks>
 /// To run the built in webserver, you will need to assign write permissions to the user running the service for the folder :
 /// C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
 ///
 /// You migh also need to add the exceptions via netsh as specified for the admin access point.
 /// </remarks>
 private void SetupWebUI()
 {
     try
     {
         var webserverConfiguration = BackgroundWorkerService.Logic.Helpers.Utils.GetConfigurationSection <Configuration.WebServerConfiguration>();
         if (webserverConfiguration.Enabled)
         {
             webServer = new CassiniDevServer();
             webServer.StartServer(webserverConfiguration.ApplicationPath, IPAddress.Any, webserverConfiguration.Port, webserverConfiguration.VirtualPath, webserverConfiguration.HostName);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(new Exception("BackgroundWorkerService.Service Failed to open hosted webserver.", ex));
     }
 }
Exemple #10
0
        // Cleans up the directories we created.
        private void ReleaseManagedResources()
        {
            if (this.webServer != null)
            {
                //this.webServer.Stop();
                this.webServer.StopServer();
                this.webServer = null;
                this.started   = false;
            }

            //if (Directory.Exists(this.webBinDir))
            //  Directory.Delete(this.webBinDir, true);

            //if (Directory.Exists(this.webRoot))
            //  Directory.Delete(this.webRoot, true);
        }
Exemple #11
0
 /// <summary>
 /// Starts the built in webserver if it is enabled via config.
 /// </summary>
 /// <remarks>
 /// To run the built in webserver, you will need to assign write permissions to the user running the service for the folder :
 /// C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
 ///
 /// You migh also need to add the exceptions via netsh as specified for the admin access point.
 /// </remarks>
 private void SetupWebUI()
 {
     try
     {
         var config = BackgroundWorkerService.Logic.Helpers.Utils.GetConfigurationSection <Configuration.WebServerConfiguration>();
         if (config.Enabled)
         {
             webServer = new CassiniDevServer();
             webServer.StartServer(config.ApplicationPath, config.Port, config.VirtualPath, config.HostName);
         }
     }
     catch (Exception ex)
     {
         LoggingProvider.LogException(new Exception("BackgroundWorkerService.Service Failed to open hosted webserver.", ex));
     }
 }
        public void TestInitialize()
        {
#if !VS2010 && !VS2012
            Playback.PlaybackSettings.AlwaysSearchControls = true;                           // false
#elif !VS2010
            Playback.PlaybackSettings.MaximumRetryCount = 3;                                 // 1
#endif
            Playback.PlaybackSettings.MatchExactHierarchy  = false;                          // false
            Playback.PlaybackSettings.SearchTimeout        = 120000;                         // 120000
            Playback.PlaybackSettings.ShouldSearchFailFast = false;                          // true
            Playback.PlaybackSettings.SmartMatchOptions    = SmartMatchOptions.None;         // SmartMatchOptions.Control
            Playback.PlaybackSettings.WaitForReadyLevel    = WaitForReadyLevel.UIThreadOnly; // .UIThreadOnly
            Playback.PlaybackSettings.WaitForReadyTimeout  = 60000;                          // 60000

            // start the web server for every test because sometimes the web server will stop for whatever reason
            // and display "This page can't be displayed"
            WebServer = new CassiniDevServer();
            WebServer.StartServer(Directory.GetCurrentDirectory());
        }
Exemple #13
0
        public static void AssemblyInitialize(TestContext context)
        {
            try
            {
                _server = new CassiniDevServer();
                _server.StartServer("../../../TechData.EC.Services.WebContent", Port, "/", "localhost");
            }
            // we're already running the service, ignore
            catch (Exception)
            {
                _server = null;
            }

            Container = new WindsorContainer();
            Container.AddFacility <WcfFacility>();

            Container.Register(
                Component.For <IPageService>()
                .AsWcfClient(new DefaultClientModel(WcfEndpoint.FromConfiguration("PageService")))
                );
        }
Exemple #14
0
 private static void Start()
 {
     server = new CassiniDevServer();
     server.StartServer(ApplicationPath, Port, "/", HostName);
 }