Esempio n. 1
0
        public void before_all()
        {
            // setup
            _command = new NewCommand();
            _fileSystem = new FileSystem();
            _zipService = new ZipFileService(_fileSystem);
            _commandInput = new NewCommandInput();

            tmpDir = FileSystem.Combine("Templating", Guid.NewGuid().ToString());
            repoZip = FileSystem.Combine("Templating", "repo.zip");
            _zipService.ExtractTo(repoZip, tmpDir, ExplodeOptions.DeleteDestination);

            solutionFile = FileSystem.Combine("Templating", "sample", "myproject.txt");
            oldContents = _fileSystem.ReadStringFromFile(solutionFile);
            solutionDir = _fileSystem.GetDirectory(solutionFile);

            _commandInput.GitFlag = "file:///{0}".ToFormat(_fileSystem.GetFullPath(tmpDir).Replace("\\", "/"));
            _commandInput.ProjectName = "MyProject";
            _commandInput.SolutionFlag = solutionFile;
            _commandInput.OutputFlag = solutionDir;
            _commandInput.RakeFlag = "init.rb";

            _commandResult = _command.Execute(_commandInput);

            newSolutionContents = _fileSystem.ReadStringFromFile(solutionFile);
        }
Esempio n. 2
0
        public void can_write_ddl_by_type_smoke_test_for_document_creation()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.RegisterDocumentType<User>();
                _.RegisterDocumentType<Company>();
                _.RegisterDocumentType<Issue>();

                _.Connection(ConnectionSource.ConnectionString);
            }))
            {
                store.Schema.WriteDDLByType("allsql");
            }

            var fileSystem = new FileSystem();
            var files = fileSystem.FindFiles("allsql", FileSet.Shallow("*.sql")).ToArray();

            files.Select(Path.GetFileName)
                .Where(x => x != "all.sql" && x != "database_schemas.sql").OrderBy(x => x)
                .ShouldHaveTheSameElementsAs("company.sql", "issue.sql", "mt_hilo.sql", "user.sql");

            files.Each(file =>
            {
                var contents = fileSystem.ReadStringFromFile(file);

                contents.ShouldContain("CREATE TABLE");
                contents.ShouldContain("CREATE OR REPLACE FUNCTION");
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Read [name].table and [name].function files from the named directory
        /// to serve as templates for extra DDL (GRANT's probably)
        /// </summary>
        /// <param name="directory"></param>
        public void ReadTemplates(string directory)
        {
            var system = new FileSystem();

            system.FindFiles(directory, FileSet.Shallow("*.function")).Each(file =>
            {
                var name = Path.GetFileNameWithoutExtension(file).ToLower();

                Templates[name].FunctionCreation = system.ReadStringFromFile(file);
            });

            system.FindFiles(directory, FileSet.Shallow("*.table")).Each(file =>
            {
                var name = Path.GetFileNameWithoutExtension(file).ToLower();

                Templates[name].TableCreation = system.ReadStringFromFile(file);
            });
        }
Esempio n. 4
0
        public void LoadProjections(string directory)
        {
            var files = new FileSystem();

            using (var connection = new ManagedConnection(_connectionFactory))
            {
                files.FindFiles(directory, FileSet.Deep("*.js")).Each(file =>
                {
                    var body = files.ReadStringFromFile(file);
                    var name = Path.GetFileNameWithoutExtension(file);

                    connection.Execute(cmd =>
                    {
                        cmd.CallsSproc(qualifyName("mt_load_projection_body"))
                            .With("proj_name", name)
                            .With("body", body)
                            .ExecuteNonQuery();

                    });
                });
            }
        }
Esempio n. 5
0
        public void copy_with_preserve()
        {
            var system = new FileSystem();
            system.WriteStringToFile("a.txt", "something");
            system.WriteStringToFile("b.txt", "else");
            system.Copy("a.txt", "b.txt", CopyBehavior.preserve);

            system.ReadStringFromFile("b.txt").ShouldEqual("else");
        }
Esempio n. 6
0
        public void WriteAndReadText()
        {
            string theString = Guid.NewGuid().ToString();

            var system = new FileSystem();
            system.WriteStringToFile(theString, "test.txt");

            Assert.AreEqual(theString, system.ReadStringFromFile("test.txt"));
        }
Esempio n. 7
0
        public void copy_with_overwrite()
        {
            var system = new FileSystem();
            system.WriteStringToFile("a.txt", "something");
            system.WriteStringToFile("b.txt", "else");
            system.Copy("a.txt", "b.txt", CopyBehavior.overwrite);

            system.ReadStringFromFile("b.txt").ShouldBe("something");
        }
Esempio n. 8
0
        public void LoadProjections(string directory)
        {
            _schema.EnsureStorageExists(typeof(EventStream));

            var files = new FileSystem();

            using (var connection = new ManagedConnection(_connectionFactory))
            {
                files.FindFiles(directory, FileSet.Deep("*.js")).Each(file =>
                {
                    var body = files.ReadStringFromFile(file);
                    var name = Path.GetFileNameWithoutExtension(file);

                    connection.Execute(cmd =>
                    {
                        cmd.CallsSproc(LoadProjectionBodyFunction)
                            .With("proj_name", name)
                            .With("body", body)
                            .ExecuteNonQuery();

                    });
                });
            }
        }
Esempio n. 9
0
        public void can_write_ddl_by_type_with_schema_creation()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.DatabaseSchemaName = "yet_another";

                _.RegisterDocumentType<Company>();
                _.Schema.For<User>().DatabaseSchemaName("other");

                _.Events.DatabaseSchemaName = "event_store";
                _.Events.EventMappingFor<MembersJoined>();

                _.Connection(ConnectionSource.ConnectionString);
            }))
            {
                store.Schema.WriteDDLByType("allsql");
            }

            const string filename = @"allsql\database_schemas.sql";

            var fileSystem = new FileSystem();
            fileSystem.FileExists(filename).ShouldBeTrue();

            var contents = fileSystem.ReadStringFromFile(filename);

            contents.ShouldContain("CREATE SCHEMA event_store");
            contents.ShouldContain("CREATE SCHEMA other");
            contents.ShouldContain("CREATE SCHEMA yet_another");
        }