public void PassesPathToFileExists() { const string expectedPath = "foo_path"; string pathValue = null; bool fileExists(string path) => (pathValue = path) != pathValue; EnvironmentProperties.Map(expectedPath, fileExists, null, null, null); pathValue.Should().Be(expectedPath); }
public void DoesNotCallReadAllText() { string pathValue = null; bool fileExists(string path) => false; string readAllText(string path) => "all_text"; EnvironmentProperties.Map( "foo_path", fileExists, readAllText, null, null); pathValue.Should().BeNull(); }
public void GetEnvironmentPropertiesIsNotCalled() { string rawValue = null; bool fileExists(string path) => true; string readAllText(string path) => throw new Exception(); IEnumerable <(string, string)> getEnvironmentProperties(string raw) => (rawValue = raw) == rawValue?Enumerable.Empty <(string, string)>() : null; EnvironmentProperties.Map( "foo_path", fileExists, readAllText, getEnvironmentProperties, null); rawValue.Should().BeNull(); }
public void PassesAllTextToGetEnvironmentProperties() { const string allText = "all_text"; string rawValue = null; bool fileExists(string path) => true; string readAllText(string path) => allText; IEnumerable <(string, string)> getEnvironmentProperties(string raw) => (rawValue = raw) == rawValue?Enumerable.Empty <(string, string)>() : null; EnvironmentProperties.Map( "foo_path", fileExists, readAllText, getEnvironmentProperties, null); rawValue.Should().Be(allText); }
public void PassesPathToReadAllText() { const string expectedPath = "foo_path"; string pathValue = null; bool fileExists(string path) => true; string readAllText(string path) => pathValue = path; IEnumerable <(string, string)> getEnvironmentProperties(string raw) => Enumerable.Empty <(string, string)>(); EnvironmentProperties.Map( expectedPath, fileExists, readAllText, getEnvironmentProperties, null); pathValue.Should().Be(expectedPath); }
public void DoesNotCallSetEnvironmentVariable() { var expectedEnvironmentProperties = new List <(string, string)> { ("foo", "bar"), ("baz", "qux") }; var actualEnvironmentProperties = new List <(string, string)>(); bool fileExists(string path) => false; string readAllText(string path) => "all_text"; IEnumerable <(string, string)> getEnvironmentProperties(string raw) => expectedEnvironmentProperties; void setEnvironmentVariable(string variable, string value) => actualEnvironmentProperties.Add((variable, value)); EnvironmentProperties.Map( "foo_path", fileExists, readAllText, getEnvironmentProperties, setEnvironmentVariable); actualEnvironmentProperties.Should().BeEmpty(); }