Example #1
0
    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);
        }
    }
Example #2
0
        public void NoPropertiesAreReturned()
        {
            var raw = "va7dq9,pf\04o123 { Dv$#Tmx \r\nasdvnklser\t asnjbdskldjk ``~~";
            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }
Example #3
0
        public void ItIsNotReturned()
        {
            var raw = @"{""iis"":{""env"":[""=bar"",""=qux""]}}";

            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }
Example #4
0
        public void NoPropertiesAreReturned(string env)
        {
            var raw = $@"{{""iis"":{{""env"":{env}}}}}";

            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }
Example #5
0
        public void NoPropertiesAreReturned()
        {
            var raw = @"{""iis"":{}}";

            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }
Example #6
0
        public void ItIsNotReturned(string envValue)
        {
            var raw = $@"{{""iis"":{{""env"":[{envValue}]}}}}";

            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }
Example #7
0
        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);
        }
Example #8
0
    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);
    }
Example #9
0
        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();
        }
Example #10
0
    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;
    }
Example #11
0
            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();
            }
Example #12
0
 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
         );
 }
Example #13
0
 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"
         }
     });
 }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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();
        }
Example #17
0
 public EnvironmentProperties(EnvironmentProperties parentProperties = null)
 {
     _parentProperties = parentProperties;
     _values           = new Dictionary <string, string>();
 }
Example #18
0
        public void NoPropertiesAreReturned(string raw)
        {
            var actualProperties = EnvironmentProperties.GetEnvironmentProperties(raw);

            actualProperties.Should().BeEmpty();
        }