Exemplo n.º 1
0
        public void ExportTo(string directory, Topic root, Func<Topic, string> pathing)
        {
            var fileSystem = new FileSystem();

            string sourceContent = _settings.Root.AppendPath("content");
            if (fileSystem.DirectoryExists(sourceContent))
            {
                fileSystem.CopyToDirectory(sourceContent, directory.AppendPath("content"));
            }

            root.AllTopicsInOrder().Each(topic =>
            {
                var path = pathing(topic);
                var parentDirectory = path.ParentUrl();

                if (parentDirectory.IsNotEmpty())
                {
                    fileSystem.CreateDirectory(directory.AppendPath(parentDirectory));
                }
                

                var text = _generator.Generate(topic);

                // Hoakum
                topic.Substitutions.Each((key, value) =>
                {
                    text = text.Replace(key, value);
                });

                fileSystem.WriteStringToFile(directory.AppendPath(path), text);
            });
        }
        public void should_thrown_when_file_is_not_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, "not xml!");

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFile<SerializeMe>(fileName));
        }
        public void find_file_with_rakefile()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory("oak");
            fileSystem.CreateDirectory("oak");

            fileSystem.WriteStringToFile("oak".AppendPath("rakefile"), "something");

            RakeFileTransform.FindFile("oak").ToLower()
                .ShouldEqual("oak".AppendPath("rakefile").ToFullPath().ToLower());
        }
        public void should_deserialize_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, SerializeMe.SerializedXml);

            var result = fileSystem.LoadFromFile<SerializeMe>(fileName);

            result.Name.ShouldEqual("Serialized Name");
            result.Index.ShouldEqual(42);
        }
Exemplo n.º 5
0
        public void copy_directory()
        {
            var system = new FileSystem();

            system.ResetDirectory("dagobah");
            system.WriteStringToFile("dagobah".AppendPath("f1", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f2", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f3", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "f1b", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("a.txt"), "something");

            system.DeleteDirectory("rhenvar");
            system.Copy("dagobah", "rhenvar");

            system.FindFiles("rhenvar", FileSet.Everything()).Select(x => x.PathRelativeTo("rhenvar")).OrderBy(x => x)
                .ShouldHaveTheSameElementsAs(
                    "a.txt",
                    FileSystem.Combine("f1", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "f1b", "a.txt"),
                    FileSystem.Combine("f2", "a.txt"),
                    FileSystem.Combine("f3", "a.txt")
                );
        }
        public void use_web_config_if_it_exists()
        {
            var fileSystem = new FileSystem();

            fileSystem.DeleteDirectory("Service");

            fileSystem.CreateDirectory("Service");
            fileSystem.CreateDirectory("Service", "bin");
            fileSystem.WriteStringToFile("Service".AppendPath("Web.config"), "foo");

            var expression = new RemoteDomainExpression();
            expression.ServiceDirectory = "Service";
            Path.GetFileName(expression.Setup.ConfigurationFile).ShouldEqual("web.config");
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            theCodeDir = ".".AppendPath("code");
            theSolutionDir = theCodeDir.AppendPath("ripple");
            theCurrentDir = theSolutionDir.AppendPath("src", "project1");

            var fileSystem = new FileSystem();
            fileSystem.CreateDirectory(theCodeDir);
            fileSystem.CreateDirectory(theSolutionDir);
            fileSystem.CreateDirectory(theCurrentDir);

            fileSystem.WriteStringToFile(Path.Combine(theSolutionDir, SolutionFiles.ConfigFile), "");

            RippleFileSystem.StubCurrentDirectory(theCurrentDir);
        }
Exemplo n.º 8
0
        public void create_test_zip_to_a_nonexistent_path()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory(".\\nonexist");

            fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeFalse();

            fileSystem.WriteStringToFile(".\\bob.txt","hi");
            var service = new ZipFileService(fileSystem);
            service.CreateZipFile(".\\nonexist\\silly.zip", f=>
            {
                f.AddFile(".\\bob.txt","");
            });

            fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeTrue();
        }
        public void SetUp()
        {
            theFileSystem = new FileSystem();
            theSolutionDir = Guid.NewGuid().ToString().ToFullPath();

            theFileSystem.CreateDirectory(theSolutionDir);
            theFileSystem.CreateDirectory(theSolutionDir, "src");
            theFileSystem.WriteStringToFile(Path.Combine(theSolutionDir, "src", "Solution.sln"), "");

            createProject("ProjectA");
            createProject("ProjectB");
            createProject("ProjectC");

            RippleFileSystem.StopTraversingAt(theSolutionDir.ParentDirectory());
            RippleFileSystem.StubCurrentDirectory(theSolutionDir);

            new InitCommand().Execute(new InitInput { Name = "Test" });
        }
Exemplo n.º 10
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");
        }
Exemplo n.º 11
0
 public void WriteToFileSmokeTest()
 {
     string sometext = "as;lkdjf;lsakdjf;lksaddjf;lkjdsf;lkjads;lfkhsad;lkjfjh";
     var system = new FileSystem();
     system.WriteStringToFile(sometext, "sometext.txt");
 }
Exemplo n.º 12
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"));
        }
Exemplo n.º 13
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");
        }
Exemplo n.º 14
0
            public PublishesExpression Assembly(string assembly, string name = null)
            {
                // TODO -- Need to create the binary on the fly
                if (name.IsEmpty())
                {
                    name = assembly.Replace(".dll", "");
                }
               
                
                // Fake the binaries
                var binaryPath = "src{0}{1}{0}bin{0}Debug".ToFormat(Path.DirectorySeparatorChar, name);
                var binaryFile = "{0}{1}{2}".ToFormat(binaryPath, Path.DirectorySeparatorChar, assembly);

                // ..\..\src\Bottles\bin\Debug\Bottles.dll
                var relativePath = "..{0}..{0}{1}".ToFormat(Path.DirectorySeparatorChar, binaryFile);

                _spec.AddPublishedAssembly(relativePath);

                var files = new FileSystem();
                files.CreateDirectory(_solution.Directory.AppendPath(binaryPath));
                files.WriteStringToFile(_solution.Directory.AppendPath(binaryFile), "");

                return this;
            }
Exemplo n.º 15
0
        public void WriteFiles()
        {
            var fileSystem = new FileSystem();

            var directory = NamespacedDirectory();
            writeSparkFile(directory, fileSystem);

            var classFile = directory.AppendPath(TopicName + ".cs");
            if (!fileSystem.FileExists(classFile))
            {
                Console.WriteLine("Writing " + classFile);
                var content = TopicClassTemplate.ToFormat(typeof (Topic).Namespace, FullNamespace, TopicName, Title);
                fileSystem.WriteStringToFile(classFile, content);
            }
        }
        public void SetUp()
        {
            var system = new FileSystem();
            system.DeleteDirectory("package1");

            system.CreateDirectory("package1");
            system.CreateDirectory("package1", "bin");
            system.WriteStringToFile(Path.Combine("package1", "bin", "a.dll"), "I'm a managed assembly");
            system.WriteStringToFile(Path.Combine("package1", "bin", "b.dll"), "I'm a native assembly");
            system.CreateDirectory("package1", "WebContent");
            system.CreateDirectory("package1", "Data");

            theOriginalManifest = new PackageManifest
            {
                Assemblies = new[] { "a" },
                NativeAssemblies = new[] { "b" },
                Name = "Extraordinary"
            };

            theOriginalManifest.WriteTo("package1");

            thePackage = new PackageManifestReader(new FileSystem(), directory => directory.AppendPath("WebContent")).LoadFromFolder("package1");
        }
Exemplo n.º 17
0
        private void writeSparkFile(string directory, FileSystem fileSystem)
        {
            var sparkFile = directory.AppendPath(TopicName + ".spark");
            if (!fileSystem.FileExists(sparkFile))
            {
                Console.WriteLine("Writing " + sparkFile);
                var content = SparkTemplate.ToFormat(FullTopicClassName, Environment.NewLine);

                fileSystem.WriteStringToFile(sparkFile, content);
            }
        }
Exemplo n.º 18
0
        public void SetUp()
        {
			rootDir = Path.GetTempPath().AppendRandomPath();
            theCodeDir = rootDir.AppendPath("code");
            theSolutionDir = theCodeDir.AppendPath("ripple");

            var fileSystem = new FileSystem();
            fileSystem.CreateDirectory(theCodeDir);
            fileSystem.CreateDirectory(theSolutionDir);

            fileSystem.WriteStringToFile(Path.Combine(theSolutionDir, SolutionFiles.ConfigFile), "");

            RippleFileSystem.StubCurrentDirectory(theCodeDir);
            RippleFileSystem.StopTraversingAt(theCodeDir);
        }