public void Should_Throw_If_Environment_Is_Null() { // Given var path = new DirectoryPath("/%FOO%/baz"); // When var result = Record.Exception(() => path.ExpandEnvironmentVariables(null)); // Then AssertEx.IsArgumentNullException(result, "environment"); }
public void Should_Throw_If_Environment_Is_Null() { // Given var path = new DirectoryPath("/%FOO%/baz"); // When var result = Record.Exception(() => path.ExpandEnvironmentVariables(null)); // Then result.ShouldBeOfType <ArgumentNullException>() .And().ParamName.ShouldBe("environment"); }
public static DirectoryPath ExpandEnvironmentVariables(this ICakeContext context, DirectoryPath directoryPath) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (directoryPath == null) { throw new ArgumentNullException(nameof(directoryPath)); } return(directoryPath.ExpandEnvironmentVariables(context.Environment)); }
public void Should_Expand_Existing_Environment_Variables() { // Given var environment = FakeEnvironment.CreateWindowsEnvironment(); environment.SetEnvironmentVariable("FOO", "bar"); var path = new DirectoryPath("/%FOO%/baz"); // When var result = path.ExpandEnvironmentVariables(environment); // Then Assert.Equal("/bar/baz", result.FullPath); }