Ejemplo n.º 1
0
        public JasmineConfiguration Configure(string file, ISerenityJasmineApplication application)
        {
            file = file.ToFullPath();

            JasmineConfiguration config;

            if (_fileSystem.IsFile(file))
            {
                Console.WriteLine("Reading directives from " + file);
                if (!_fileSystem.FileExists(file))
                {
                    throw new CommandFailureException(
                              "Designated serenity/jasmine file at {0} does not exist".ToFormat(file));
                }

                config = _configLoader.LoadFrom(file);
            }
            else
            {
                config = new JasmineConfiguration(file);
                config.AddContentFolder(file);
            }

            ProcessConfiguration(config, application);

            return(config);
        }
Ejemplo n.º 2
0
        private void addContentFolder(string dir, ISpecFileListener listener, JasmineConfiguration configuration)
        {
            var watcher = new FileSystemWatcher(dir);
            watcher.Changed += (x, file) =>
            {
                if (configuration.ShouldExclude(file.FullPath)) return;
                Console.WriteLine("Detected a change to " + file.FullPath);

                _cache.FlushAll();
                listener.Changed();
            };

            watcher.Created += (x, y) =>
            {
                if (configuration.ShouldExclude(y.FullPath)) return;
                Console.WriteLine("Detected a new file at " + y.FullPath);
                listener.Added();
            };

            watcher.Deleted += (x, y) =>
            {
                if (configuration.ShouldExclude(y.FullPath)) return;
                Console.WriteLine("Detected a file deletion at " + y.FullPath);
                listener.Deleted();
            };

            watcher.EnableRaisingEvents = true;
            watcher.IncludeSubdirectories = true;
        }
Ejemplo n.º 3
0
        public JasmineConfiguration LoadFrom(string path)
        {
            var file     = path.ToFullPath();
            var contents = _fileSystem.ReadStringFromFile(file);
            var config   = new JasmineConfiguration(file);

            using (var reader = new StringReader(contents))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.IsEmpty())
                    {
                        continue;
                    }

                    if (line.StartsWith("include:"))
                    {
                        include(line, config);
                    }

                    else if (line.StartsWith("exclude:"))
                    {
                        exclude(line, config);
                    }
                }
            }

            return(config);
        }
Ejemplo n.º 4
0
        public JasmineConfiguration Configure(string file, ISerenityJasmineApplication application)
        {
            file = file.ToFullPath();

            JasmineConfiguration config;
            if (_fileSystem.IsFile(file))
            {
                Console.WriteLine("Reading directives from " + file);
                if (!_fileSystem.FileExists(file))
                {
                    throw new CommandFailureException(
                        "Designated serenity/jasmine file at {0} does not exist".ToFormat(file));
                }

                config = _configLoader.LoadFrom(file);
            }
            else
            {
                config = new JasmineConfiguration(file);
                config.AddContentFolder(file);
            }

            ProcessConfiguration(config, application);

            return config;
        }
Ejemplo n.º 5
0
        private static void exclude(string text, JasmineConfiguration config)
        {
            var filter = text.Split(':').Last();

            Console.WriteLine("Adding exclude filter " + filter);
            config.AddExclude(filter);
        }
Ejemplo n.º 6
0
 public void ProcessConfiguration(JasmineConfiguration config, ISerenityJasmineApplication application)
 {
     config
         .ContentFolders
         .Each(folder => {
             Console.WriteLine("Adding content from folder " + folder);
             application.AddContentFolder(folder);
         });
 }
Ejemplo n.º 7
0
 public void ProcessConfiguration(JasmineConfiguration config, ISerenityJasmineApplication application)
 {
     config
     .ContentFolders
     .Each(folder => {
         Console.WriteLine("Adding content from folder " + folder);
         application.AddContentFolder(folder);
     });
 }
Ejemplo n.º 8
0
        public void StartWatching(ISpecFileListener listener, JasmineConfiguration configuration)
        {
            PackageRegistry.Packages.Each(pak => pak.ForFolder(BottleFiles.WebContentFolder, dir =>
            {
                var contentFolder = dir.AppendPath("content");
                if (_fileSystem.DirectoryExists(contentFolder))
                {
                    addContentFolder(contentFolder, listener, configuration);
                }

                var watcher = new FileSystemWatcher(dir, "*.config");
                watcher.Changed += (x, y) => listener.Recycle();
                watcher.Deleted += (x, y) => listener.Recycle();
                watcher.EnableRaisingEvents = true;
                watcher.IncludeSubdirectories = true;

                _watchers.Add(watcher);
            }));
        }
Ejemplo n.º 9
0
        public void StartWatching(ISpecFileListener listener, JasmineConfiguration configuration)
        {
            PackageRegistry.Packages.Each(pak => pak.ForFolder(BottleFiles.WebContentFolder, dir =>
            {
                var contentFolder = dir.AppendPath("content");
                if (_fileSystem.DirectoryExists(contentFolder))
                {
                    addContentFolder(contentFolder, listener, configuration);
                }

                var watcher                   = new FileSystemWatcher(dir, "*.config");
                watcher.Changed              += (x, y) => listener.Recycle();
                watcher.Deleted              += (x, y) => listener.Recycle();
                watcher.EnableRaisingEvents   = true;
                watcher.IncludeSubdirectories = true;

                _watchers.Add(watcher);
            }));
        }
Ejemplo n.º 10
0
        private void buildApplication()
        {
            _application = new SerenityJasmineApplication();
            var fileSystem   = new FileSystem();
            var loader       = new JasmineConfigLoader(fileSystem);
            var configurator = new JasmineConfigurator(fileSystem, loader);

            _configuration = configurator.Configure(_input.SerenityFile, _application);


            var applicationSettings = new ApplicationSettings
            {
                RootUrl = "http://localhost:" + _input.PortFlag
            };

            IBrowserLifecycle browserBuilder = _input.GetBrowser();

            _applicationUnderTest = new ApplicationUnderTest(_application, applicationSettings, browserBuilder);

            _driver = new NavigationDriver(_applicationUnderTest);
        }
Ejemplo n.º 11
0
        private void addContentFolder(string dir, ISpecFileListener listener, JasmineConfiguration configuration)
        {
            var watcher = new FileSystemWatcher(dir);

            watcher.Changed += (x, file) =>
            {
                if (configuration.ShouldExclude(file.FullPath))
                {
                    return;
                }
                Console.WriteLine("Detected a change to " + file.FullPath);

                _cache.FlushAll();
                listener.Changed();
            };

            watcher.Created += (x, y) =>
            {
                if (configuration.ShouldExclude(y.FullPath))
                {
                    return;
                }
                Console.WriteLine("Detected a new file at " + y.FullPath);
                listener.Added();
            };

            watcher.Deleted += (x, y) =>
            {
                if (configuration.ShouldExclude(y.FullPath))
                {
                    return;
                }
                Console.WriteLine("Detected a file deletion at " + y.FullPath);
                listener.Deleted();
            };

            watcher.EnableRaisingEvents   = true;
            watcher.IncludeSubdirectories = true;
        }
Ejemplo n.º 12
0
        public JasmineConfiguration LoadFrom(string path)
        {
            var file = path.ToFullPath();
            var contents = _fileSystem.ReadStringFromFile(file);
            var config = new JasmineConfiguration(file);

            using(var reader = new StringReader(contents))
            {
                string line;
                while((line = reader.ReadLine()) != null)
                {
                    if (line.IsEmpty()) continue;

                    if (line.StartsWith("include:"))
                        include(line, config);

                    else if (line.StartsWith("exclude:"))
                        exclude(line, config);
                }
            }

            return config;
        }
Ejemplo n.º 13
0
        private static void include(string text, JasmineConfiguration config)
        {
            var folder = text.Split(':').Last();

            config.AddContentFolder(folder);
        }
        public void SetUp()
        {
            theFileSystem = MockRepository.GenerateStub<IFileSystem>();
            theFile = TestFileHelper.RelativePath("serenity.txt");

            theFileContents = new StringBuilder()
                .AppendLine("include:MyProject.Web")
                .AppendLine("include:MyProject.Web2")
                .ToString();

            theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents);

            theLoader = new JasmineConfigLoader(theFileSystem);
            theConfiguration = theLoader.LoadFrom(theFile);
        }
Ejemplo n.º 15
0
 private static void include(string text, JasmineConfiguration config)
 {
     var folder = text.Split(':').Last();
     config.AddContentFolder(folder);
 }
Ejemplo n.º 16
0
        private void buildApplication()
        {
            _application = new SerenityJasmineApplication();
            var fileSystem = new FileSystem();
            var loader = new JasmineConfigLoader(fileSystem);
            var configurator = new JasmineConfigurator(fileSystem, loader);
            _configuration = configurator.Configure(_input.SerenityFile, _application);

            var applicationSettings = new ApplicationSettings
            {
                RootUrl = "http://localhost:" + _input.PortFlag
            };

            IBrowserLifecycle browserBuilder = _input.GetBrowser();

            _applicationUnderTest = new ApplicationUnderTest(_application, applicationSettings, browserBuilder);

            _driver = new NavigationDriver(_applicationUnderTest);
        }
Ejemplo n.º 17
0
 private static void exclude(string text, JasmineConfiguration config)
 {
     var filter = text.Split(':').Last();
     Console.WriteLine("Adding exclude filter " + filter);
     config.AddExclude(filter);
 }
 public void SetUp()
 {
     theConfiguration = new JasmineConfiguration(TestFileHelper.RelativePath("serenity.txt"));
 }
        public void SetUp()
        {
            theFileSystem = MockRepository.GenerateStub<IFileSystem>();
            theFile = TestFileHelper.RelativePath("serenity.txt");

            theFileContents = "exclude:MyProject.Web{0}.idea".ToFormat(Path.DirectorySeparatorChar);

            theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents);

            theLoader = new JasmineConfigLoader(theFileSystem);
            theConfiguration = theLoader.LoadFrom(theFile);
        }