示例#1
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();
        }
        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();
        }
示例#3
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);
        }
示例#4
0
        public void AppContentInitializeShouldSetupFiles()
        {
            BamConf       conf = new BamConf();
            DirectoryInfo root = new DirectoryInfo("c:\\temp\\{0}_"._Format(MethodBase.GetCurrentMethod().Name).RandomLetters(5));

            conf.ContentRoot = root.FullName;
            ContentResponder    content    = new ContentResponder(conf, CreateLogger());
            AppConf             appConf    = new AppConf("monkey");
            AppContentResponder appContent = new AppContentResponder(content, appConf);
            // should create the folder <conf.ContentRoot>\\apps\\monkey
            string appPath = Path.Combine(conf.ContentRoot, "apps", appConf.Name);

            if (Directory.Exists(appPath))
            {
                Directory.Delete(appPath, true);
            }
            Expect.IsFalse(Directory.Exists(appPath));
            appContent.Initialize();
            Expect.IsTrue(Directory.Exists(appPath));
        }
示例#5
0
        public void AppContentInitializeShouldCreateAppConfDotJson()
        {
            DirectoryInfo root = new DirectoryInfo("c:\\temp\\{0}_"._Format(MethodBase.GetCurrentMethod().Name).RandomLetters(5));
            BamConf       conf = new BamConf();

            conf.ContentRoot = root.FullName;
            ContentResponder content = new ContentResponder(conf);
            AppConf          appConf = new AppConf("monkey");
            string           layout  = "".RandomLetters(4);

            appConf.DefaultLayout = layout;
            AppContentResponder appContent = new AppContentResponder(content, appConf);
            string appConfPath             = Path.Combine(conf.ContentRoot, "apps", appConf.Name, "appConf.json");

            Expect.IsFalse(File.Exists(appConfPath));

            appContent.Initialize();
            Expect.IsTrue(File.Exists(appConfPath), "appConf.json did not get created");
            AppConf check = appConfPath.FromJsonFile <AppConf>();

            Expect.AreEqual(layout, check.DefaultLayout);
        }