public void ProjectFile_ExternalAbsoluteFileCreationTest()
        {
            //Arrange
            const string absolutePath1 = "D:\\Valentin\\Videos\\Wildlife.wmv";
            const string basePath = "D:\\Test\\RelTest2";
            const string expectedRelativePath1 = "../../Valentin/Videos/Wildlife.wmv";

            ProjectFile pf1;
            ProjectFile pf1a;

            //Act
            pf1 = ProjectFile.FromAbsolutePath(absolutePath1, basePath);
            pf1a = new ProjectFile { AbsolutePath = absolutePath1 };
            pf1a.MakeRelativeTo(basePath);

            //Assert
            Assert.AreEqual(expectedRelativePath1, pf1.RelativePath);
            Assert.AreEqual(expectedRelativePath1, pf1a.RelativePath);
        }
Пример #2
0
 /// <summary>
 /// Creates a ProjectFile with a given absolute(rooted) path, and a base path. The
 /// ProjectFile's RelativePath will be set relative to the given base path. Use this when
 /// given an absolute path but not a relative path. Note that the basePath does not have to
 /// contain the relative path.
 /// </summary>
 /// <param name="absolutePath">A rooted path.</param>
 /// <param name="basePath">A base path to make the file relative to.</param>
 /// <returns></returns>
 public static ProjectFile FromAbsolutePath(string absolutePath, string basePath)
 {
     var pf = new ProjectFile { AbsolutePath = absolutePath };
     pf.MakeRelativeTo(basePath);
     return pf;
 }
        public void ProjectFile_InternalAbsoluteFileCreationTest()
        {
            //Arrange
            const string pathToProjectFolder = "D:\\Test\\Wildlife";
            const string absolutePath1 = "D:\\Test\\Wildlife\\Wildlife.wmv";
            const string absolutePath2 = "D:\\Test\\Wildlife\\projectCache\\waveform.bin";
            const string expectedRelativePath1 = "Wildlife.wmv";
            const string expectedRelativePath2 = "projectCache/waveform.bin";

            ProjectFile pf1;
            ProjectFile pf1a;
            ProjectFile pf2;
            ProjectFile pf2a;

            //Act
            pf1 = ProjectFile.FromAbsolutePath(absolutePath1, pathToProjectFolder);
            pf1a = new ProjectFile { AbsolutePath = absolutePath1 };
            pf1a.MakeRelativeTo(pathToProjectFolder);

            pf2 = ProjectFile.FromAbsolutePath(absolutePath2, pathToProjectFolder);
            pf2a = new ProjectFile { AbsolutePath = absolutePath2 };
            pf2a.MakeRelativeTo(pathToProjectFolder);

            //Assert
            Assert.AreEqual(expectedRelativePath1, pf1.RelativePath);
            Assert.AreEqual(expectedRelativePath1, pf1a.RelativePath);
            Assert.AreEqual(expectedRelativePath2, pf2.RelativePath);
            Assert.AreEqual(expectedRelativePath2, pf2a.RelativePath);
        }