public void GetModuleFilePaths() { List <string> modulesPath = PowerShellFunctionInvoker.GetModuleFilePaths(_fixture.TestRootScriptPath, _fixture.TestFunctionName); Assert.Equal(_fixture.TestModulesPath.Count, modulesPath.Count); foreach (var modulePath in modulesPath) { Assert.True(_fixture.TestModulesPath.Contains(modulePath)); } }
public void GetRelativePath() { string functionRootPath = "C:\\"; string moduleRelativePath = Path.Combine(_fixture.TestFunctionName, "modules\\test-module.psm1"); string moduleFilePath = Path.Combine(functionRootPath, moduleRelativePath); string expectedModuleFilePath = string.Format("/{0}", moduleRelativePath.Replace('\\', '/')); string result = PowerShellFunctionInvoker.GetRelativePath(_fixture.TestFunctionName, moduleFilePath); Assert.Equal(expectedModuleFilePath, result, StringComparer.OrdinalIgnoreCase); }
public void GetStackTrace() { string scriptFileName = "test.ps1"; string scriptStackTrace = string.Format( @"at Get-DateToday, C:\git\azure-webjobs-sdk-script\sample\{0}\modules\Get-DateToday.psm1: line 4 at <ScriptBlock>, <No file>: line 3", _fixture.TestFunctionName); string expectedScriptStackTrace = string.Format(@"at Get-DateToday, /{0}/modules/Get-DateToday.psm1: line 4 at {1}: line 3", _fixture.TestFunctionName, scriptFileName); string result = PowerShellFunctionInvoker.GetStackTrace(_fixture.TestFunctionName, scriptStackTrace, scriptFileName); Assert.Equal(expectedScriptStackTrace, result, StringComparer.OrdinalIgnoreCase); }
public void GetErrorMessage() { string scriptFilePath = "C:\\test.ps1"; ErrorRecord errorRecord = new ErrorRecord( new Exception("Object not found."), "ObjectNotFound", ErrorCategory.ObjectNotFound, "TestObject"); string startMessage = "test.ps1 : Object not found."; string result = PowerShellFunctionInvoker.GetErrorMessage(_fixture.TestFunctionName, scriptFilePath, errorRecord); Assert.True(result.StartsWith(startMessage)); Assert.True(result.Contains("+ CategoryInfo : ObjectNotFound: (TestObject:String) [], Exception")); Assert.True(result.Contains("+ FullyQualifiedErrorId : ObjectNotFound")); }
public void GetScript() { string result = PowerShellFunctionInvoker.GetScript(_fixture.TestScriptPath); Assert.Equal(_fixture.TestScriptContent, result.Trim(), StringComparer.OrdinalIgnoreCase); }