Ejemplo n.º 1
0
        public void CreateAppShouldFireAppropriateEvents()
        {
            BamServer server = CreateServer(MethodBase.GetCurrentMethod().Name);
            bool?     ed     = false;
            bool?     ing    = false;

            server.CreatingApp += (s, ac) =>
            {
                ing = true;
            };

            server.CreatedApp += (s, ac) =>
            {
                ed = true;
            };

            Expect.IsFalse(ing.Value);
            Expect.IsFalse(ed.Value);

            string appName = "TestApp_".RandomLetters(4);

            server.CreateApp(appName, null, RandomNumber.Between(8000, 9999));

            Expect.IsTrue(ing.Value);
            Expect.IsTrue(ed.Value);

            if (Directory.Exists(server.ContentRoot))
            {
                Directory.Delete(server.ContentRoot, true);
            }
        }
Ejemplo n.º 2
0
        public void RegisterApp()
        {
            BamServer     server = new BamServer(BamConf.Load(GetRoot()));
            ConsoleLogger logger = new ConsoleLogger();

            logger.AddDetails = false;
            logger.UseColors  = true;
            server.Subscribe(logger);
            AppContentResponder app = server.CreateApp(GetArgument("appName"));

            app.Subscribe(logger);
            app.Initialize();
        }
Ejemplo n.º 3
0
        public void ShouldBeAbleToCreateAppByName()
        {
            BamServer server  = CreateServer(MethodBase.GetCurrentMethod().Name);
            string    appName = "TestApp_".RandomLetters(4);

            server.CreateApp(appName, null, RandomNumber.Between(8000, 9999));
            DirectoryInfo appDir = new DirectoryInfo(Path.Combine(server.ContentRoot, "apps", appName));

            Expect.IsTrue(appDir.Exists);

            if (Directory.Exists(server.ContentRoot))
            {
                Directory.Delete(server.ContentRoot, true);
            }
        }
        public void CreateClientApplication()
        {
            BamServer     server = new BamServer(BamConf.Load(GetRoot()));
            ConsoleLogger logger = new ConsoleLogger()
            {
                AddDetails = false,
                UseColors  = true
            };

            server.Subscribe(logger);
            AppContentResponder app = server.CreateApp(GetArgument("appName"));

            app.Subscribe(logger);
            app.Initialize();
        }
Ejemplo n.º 5
0
        public void AppContentResponderShouldCombineAppScriptsOnInitialize()
        {
            string        testAppName = MethodBase.GetCurrentMethod().Name;
            DirectoryInfo dir         = new DirectoryInfo("C:\\temp\\{0}_"._Format(testAppName).RandomLetters(4));

            CreateTestRootAndSetDefaultConfig(dir);
            BamServer server = CreateServer(dir.FullName);

            server.Initialize();
            AppContentResponder appResponder = server.CreateApp(testAppName, null, 9191);

            appResponder.Logger = new ConsoleLogger();
            appResponder.Logger.StartLoggingThread();
            string jsGuid        = Guid.NewGuid().ToString().Replace("-", "");
            string pageGuid      = Guid.NewGuid().ToString().Replace("-", "");
            string viewModelGuid = Guid.NewGuid().ToString().Replace("-", "");

            string testJsName          = "testScript_{0}.js"._Format(jsGuid);
            string testPageJsName      = "testPageScript_{0}.js"._Format(pageGuid);
            string testViewModelJsName = "testViewModelScript_{0}.js"._Format(viewModelGuid);

            appResponder.AppRoot.WriteFile("~/js/{0}"._Format(testJsName), "function _" + jsGuid + "(){};");
            appResponder.AppRoot.WriteFile("~/pages/{0}"._Format(testPageJsName), "function _" + pageGuid + "(){};");
            appResponder.AppRoot.WriteFile("~/viewModels/{0}"._Format(testViewModelJsName), "function _" + viewModelGuid + "(){};");
            appResponder.Initialize();
            string scriptPath;
            string minAppScriptPath;

            Expect.IsTrue(appResponder.AppRoot.FileExists("~/{0}.js"._Format(testAppName), out scriptPath));
            Expect.IsTrue(appResponder.AppRoot.FileExists("~/{0}.min.js"._Format(testAppName), out minAppScriptPath));
            string script    = File.ReadAllText(scriptPath);
            string minScript = File.ReadAllText(minAppScriptPath);

            Expect.IsTrue(script.Contains(jsGuid), "js guid wasn't in the script");
            Expect.IsTrue(script.Contains(pageGuid), "page guid wasn't in the script");
            Expect.IsTrue(script.Contains(viewModelGuid), "viewModel guid wasn't in the scirpt");

            Expect.IsTrue(minScript.Contains(jsGuid), "js guid wasn't in the script");
            Expect.IsTrue(minScript.Contains(pageGuid), "page guid wasn't in the script");
            Expect.IsTrue(minScript.Contains(viewModelGuid), "viewModel guid wasn't in the scirpt");

            _directoriesToDelete.Add(dir.FullName);
        }