Exemplo n.º 1
0
        public void Deploy_WithSourceAndDestinationDirectories_CopiesOneToTheOther()
        {
            // arrange
            var webroot = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            webroot.Create();

            var destination = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            destination.Create();

            var dir = webroot.Combine(Guid.NewGuid().ToString());
            dir.Create();

            var file = webroot.CombineFile(Guid.NewGuid().ToString());
            using (var sw = new StreamWriter(file.OpenWrite()))
                sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            var fileDeployer = new FileDeployer(webroot, destination);

            // act
            fileDeployer.Deploy();

            // assert
            Assert.IsTrue(destination.CombineFile(file.Name).Exists);
            Assert.IsTrue(destination.Combine(dir.Name).Exists);
        }
        public void CopyTo_WithDestinationDirectory_CopiesFiles()
        {
            // arrange
            var source = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            source.Create();

            var destination = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            destination.Create();

            var file1 = source.CombineFile(Guid.NewGuid().ToString());
            using (var sw = new StreamWriter(file1.OpenWrite()))
                sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            var file2 = source.CombineFile(Guid.NewGuid().ToString());
            using (var sw = new StreamWriter(file2.OpenWrite()))
                sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            // act
            source.CopyTo(destination);

            // assert
            FileAssert.Exists(destination.CombineFile(file1.Name).Path);
            FileAssert.Exists(destination.CombineFile(file2.Name).Path);
        }