public void ParsesARealFileAndSetsActualEnvironmentVariables() { try { var a = Environment.GetEnvironmentVariable("this.one.is.a.num"); var b = Environment.GetEnvironmentVariable("test:variable"); var c = Environment.GetEnvironmentVariable("test-var"); a.Should().BeNull(); b.Should().BeNull(); c.Should().BeNull(); EnvironmentProperties.MapToEnvironmentVariables("config.json"); a = Environment.GetEnvironmentVariable("this.one.is.a.num"); b = Environment.GetEnvironmentVariable("test:variable"); c = Environment.GetEnvironmentVariable("test-var"); a.Should().Be("1234"); b.Should().Be("another one"); c.Should().Be("a variable"); } finally { Environment.SetEnvironmentVariable("this.one.is.a.num", null); Environment.SetEnvironmentVariable("test:variable", null); Environment.SetEnvironmentVariable("test-var", null); } }
public void NoPropertiesAreReturned() { var raw = "va7dq9,pf\04o123 { Dv$#Tmx \r\nasdvnklser\t asnjbdskldjk ``~~"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }
public void ItIsNotReturned() { var raw = @"{""iis"":{""env"":[""=bar"",""=qux""]}}"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }
public void NoPropertiesAreReturned(string env) { var raw = $@"{{""iis"":{{""env"":{env}}}}}"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }
public void NoPropertiesAreReturned() { var raw = @"{""iis"":{}}"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }
public void ItIsNotReturned(string envValue) { var raw = $@"{{""iis"":{{""env"":[{envValue}]}}}}"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }
public void TheEmbeddedEnvironmentPropertiesAreReturned() { var expectedProperties = new List <(string, string)> { ("foo", "bar"), ("baz", "qux") }; var raw = @"{""iis"":{""env"":[""foo=bar"",""baz=qux""]}}"; var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEquivalentTo(expectedProperties); }
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 RenderDocumentResponse RenderDocument(string base64DocumentContent) // this is the API we call it render document { var client = EnvironmentProperties.GetBrokerRenderDocumentRestURL(); // here we would have the URL of the api endpoint and the route var renderDocumentRequest = BrokerRequest.GetRenderDocumentRequest(base64DocumentContent); // the function here return the request var renderDocumentRequestJSON = JsonConvert.SerializeObject(renderDocumentRequest); // serializing the request. var renderDocumentResponse = RestUtils.CallService<RenderDocumentResponse>(client, Method.POST, renderDocumentRequestJSON); // uses the restSharp framework return renderDocumentResponse; }
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 BuildEnvironment(BuildEnvironment parent = null, string name = null) { _name = name; _parent = parent; _properties = new EnvironmentProperties( _parent?._properties ); _output = new EnvironmentProperties( _parent?.Output ); _items = new EnvironmentItemLists( _parent?._items ); }
public static RenderDocumentRequest GetRenderDocumentRequest(string base64DocumentContent) { return(new RenderDocumentRequest() { correlationID = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddmmHHssfff")), // id for the request systemOfOrigin = "DOCMGMTAUTOMATION", // origin system of the request Account = EnvironmentProperties.GetAutomationUser(), // this is the account performing the action, the method returns sensitive data inputXml = new InputXml() // the document that will be used and his data { content = base64DocumentContent, mimetype = "text/xml", name = "automation_test_document.xml" } }); }
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(); }
public EnvironmentProperties(EnvironmentProperties parentProperties = null) { _parentProperties = parentProperties; _values = new Dictionary <string, string>(); }
public void NoPropertiesAreReturned(string raw) { var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw); actualProperties.Should().BeEmpty(); }