示例#1
0
        public void BootstrapsBasicApplicationFileChange()
        {
            string           path     = ApplicationUtils.CreateValidExampleApplication();
            string           filePath = Path.Combine(path, Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".dll");
            ManualResetEvent handle   = new ManualResetEvent(false);

            try
            {
                using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
                {
                    bootstraps.ApplicationFilesChanged += (sender, e) =>
                    {
                        Assert.AreEqual(filePath, e.FullPath);
                        handle.Set();
                    };

                    Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);

                    using (File.Create(filePath))
                    {
                    }

                    WaitHandle.WaitAll(new WaitHandle[] { handle });
                }
            }
            finally
            {
                handle.Close();
            }
        }
示例#2
0
        public void BootstrapsPullUpAndExecuteJob()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp(true).ResultType);

                CreateFileJob job = new CreateFileJob()
                {
                    Path = Path.Combine(path, Path.GetRandomFileName())
                };

                Assert.IsFalse(File.Exists(job.Path));

                // The default configuration specifies a SQLite repository pointing
                // to BlueCollar.sqlite in the application's root directory.
                using (IRepository repository = new SQLiteRepository(string.Format(CultureInfo.InvariantCulture, "data source={0};journal mode=Off;synchronous=Off;version=3", Path.Combine(path, "BlueCollar.sqlite"))))
                {
                    job.Enqueue("Default", null, repository);
                }

                // Default worker heartbeat is 5 seconds.
                Thread.Sleep(6000);
                Assert.IsTrue(File.Exists(job.Path));
            }
        }
示例#3
0
        /// <summary>
        /// Executes tests that ensure assemblies are not locked when the remote app domain
        /// is loaded by <see cref="Bootstraps"/>.
        /// </summary>
        /// <param name="path">The path of the application to test.</param>
        /// <param name="pathToDelete">The path of the assembly file to delete.</param>
        private static void AssembliesNotLocked(string path, string pathToDelete)
        {
            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);
                Assert.IsTrue(File.Exists(pathToDelete));

                ProcessStartInfo info = new ProcessStartInfo()
                {
                    Arguments              = string.Format(CultureInfo.InvariantCulture, @"/C del ""{0}""", pathToDelete),
                    CreateNoWindow         = true,
                    FileName               = "cmd.exe",
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    UseShellExecute        = false
                };

                using (Process process = new Process())
                {
                    process.StartInfo = info;
                    Assert.IsTrue(process.Start());

                    process.WaitForExit();
                    Assert.AreEqual(0, process.ExitCode);
                    Assert.AreEqual(string.Empty, process.StandardError.ReadToEnd());
                    Assert.IsFalse(File.Exists(pathToDelete));
                }
            }
        }
示例#4
0
        public void BootstrapsWebApplicationConfigFileChange()
        {
            string           path   = ApplicationUtils.CreateValidExampleWebApplication();
            ManualResetEvent handle = new ManualResetEvent(false);

            try
            {
                using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
                {
                    bootstraps.ApplicationFilesChanged += (sender, e) =>
                    {
                        Assert.AreEqual(Path.Combine(path, "Web.config"), e.FullPath);
                        handle.Set();
                    };

                    Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);

                    using (File.Create(Path.Combine(path, "Web.config")))
                    {
                    }

                    WaitHandle.WaitAll(new WaitHandle[] { handle });
                }
            }
            finally
            {
                handle.Close();
            }
        }
示例#5
0
        public void BootstrapsPullUpAndExcecuteJobWithHttpApplicationEntryPoint()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp(true).ResultType);

                CreateFileJob job = new CreateFileJob()
                {
                    Path = Path.Combine(path, Path.GetRandomFileName())
                };

                Assert.IsFalse(File.Exists(job.Path));

                using (IRepository repository = new SQLiteRepository(string.Format(CultureInfo.InvariantCulture, "data source={0};journal mode=Off;synchronous=Off;version=3", Path.Combine(path, "BlueCollar.sqlite"))))
                {
                    job.Enqueue("Default", null, repository);
                }

                Thread.Sleep(6000);
                Assert.IsTrue(File.Exists("HttpApplicationStart"));

                bootstraps.Pushdown(true);
                Assert.IsTrue(File.Exists("HttpApplicationEnd"));
            }
        }
示例#6
0
        public void BootstrapsPullUpBasicWebApplication()
        {
            string path = ApplicationUtils.CreateValidExampleWebApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);
                Assert.IsTrue(bootstraps.IsLoaded);
            }
        }
示例#7
0
        public void BootstrapsPullUpFail()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            File.Delete(Path.Combine(path, "BlueCollar.dll"));

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                BootstrapsPullupResult result = bootstraps.PullUp();
                Assert.AreEqual(BootstrapsPullupResultType.Exception, result.ResultType);
                Assert.IsNotNull(result.Exception);
            }
        }