public void ResolveEnvironmentVariableShouldResolvePathWhenPassedRelativePathWithDot() { string path = @".\MsTest\Adapter"; string baseDirectory = @"C:\unitTesting"; string expectedResult = @"C:\unitTesting\MsTest\Adapter"; var adapterSettings = new TestableMSTestAdapterSettings(); adapterSettings.DoesDirectoryExistSetter = (str) => { return(true); }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); Assert.IsNotNull(result); Assert.AreEqual(string.Compare(result, expectedResult, true), 0); }
public void ResolveEnvironmentVariableShouldResolvePathWithAnEnvironmentVariable() { string path = @"%temp%\unitTesting\MsTest\Adapter"; string baseDirectory = null; string expectedResult = @"C:\foo\unitTesting\MsTest\Adapter"; var adapterSettings = new TestableMSTestAdapterSettings(); adapterSettings.ExpandEnvironmentVariablesSetter = (str) => { return(str.Replace("%temp%", "C:\\foo")); }; adapterSettings.DoesDirectoryExistSetter = (str) => { return(true); }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); Assert.IsNotNull(result); Assert.AreEqual(string.Compare(result, expectedResult, true), 0); }
public void ResolveEnvironmentVariableShouldResolvePathWhenPassedRelativePath() { string path = @"\MsTest\Adapter"; string baseDirectory = @"C:\unitTesting"; // instead of returning "C:\unitTesting\MsTest\Adapter", it will return "(Drive from where test is running):\MsTest\Adapter", // because path is starting with "\" // this is how Path.GetFullPath works string currentDirectory = Environment.CurrentDirectory; string currentDrive = currentDirectory.Split('\\').First() + "\\"; string expectedResult = Path.Combine(currentDrive, @"MsTest\Adapter"); var adapterSettings = new TestableMSTestAdapterSettings(); adapterSettings.DoesDirectoryExistSetter = (str) => { return(true); }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); Assert.IsNotNull(result); Assert.AreEqual(string.Compare(result, expectedResult, true), 0); }