public void NotDeployedFileDoesntExist()
        {
            string deploymentDirectory;

            using (var deployer = new XDeploymentHelper(this))
            {
                testOutputWriter.WriteLine($"Deployment directory is {deployer.DeploymentDirectory}");
                // DeploymentDirectory should not exist before first deployment
                Assert.Null(deployer.DeploymentDirectory);

                string pathReturned = deployer.CreateDeploymentDirectory();
                Assert.Equal(pathReturned, deployer.DeploymentDirectory);

                string[] pathsToCheck =
                {
                    "1-line.txt",
                    "2-lines.txt",
                    "thedirectory"
                };

                foreach (string fileOrFolder in pathsToCheck)
                {
                    string fullPath = Path.Combine(deployer.DeploymentDirectory, fileOrFolder);
                    bool   exists   = File.Exists(fullPath);
                    Assert.False(exists, $"File '{fullPath} should not exist.");
                    exists = Directory.Exists(fullPath);
                    Assert.False(exists, $"Directory '{fullPath} should not exist.");
                }

                deploymentDirectory = deployer.DeploymentDirectory;
            }

            Assert.False(Directory.Exists(deploymentDirectory), "Deployment directory should be deleted in Dispose()");
        }
Exemple #2
0
 public void DoesntAllowToDeployToUpperFolder()
 {
     using (var deployer = new XDeploymentHelper(this))
     {
         Assert.Throws <ArgumentException>(() => deployer.DeployEmbeddedResource("1-line.txt", ".."));
         Assert.Throws <ArgumentException>(() => deployer.DeployEmbeddedResource("1-line.txt", @"dir\..\.."));
         Assert.Throws <ArgumentException>(() => deployer.DeployEmbeddedResource("1-line.txt", "dir/../.."));
     }
 }
 public void FileDeployedFromRoot()
 {
     using (var deployer = new XDeploymentHelper(this))
     {
         string fullPathToFile = deployer.DeployEmbeddedResource("1-line.txt");                 // -> Out\1 - line.txt
         testOutputWriter.WriteLine($"Deployment directory is {deployer.DeploymentDirectory}");
         Assert.True(FileOperations.FileExists(fullPathToFile));
     }
 }
 public void FileDeployedFromNestedFolder()
 {
     using (var deployer = new XDeploymentHelper(this))
     {
         string fullPathToFile = deployer.DeployEmbeddedResource(@"SomeFolder\2-lines.txt");                 // -> Out\2-lines.txt
         testOutputWriter.WriteLine($"Deployment directory is {deployer.DeploymentDirectory}");
         Assert.True(FileOperations.FileExists(fullPathToFile),
                     $"File '{fullPathToFile} should be deployed. Did you forget to set 'Embedded resource' property?");
     }
 }
 public void FileDeployedFromRootToSpecifiedNestedDirectory()
 {
     using (var deployer = new XDeploymentHelper(this))
     {
         string fullPathToFile = deployer.DeployEmbeddedResource(
             "1-line.txt", @"thedirectory\nesteddirectory");                     // -> Out\thedirectory\nesteddirectory\1-line.txt
         testOutputWriter.WriteLine($"Deployment directory is {deployer.DeploymentDirectory}");
         Assert.True(FileOperations.FileExists(fullPathToFile),
                     $"File '{fullPathToFile} should be deployed. Did you forget to set 'Embedded resource' property?");
     }
 }