Exemple #1
0
        public void TestTheValidationForASingleHeader()
        {
            var gen = new ODataT4CodeGenerator();

            gen.CustomHttpHeaders = null;
            var testHeaderName  = "testHeaderName";
            var testHeaderValue = "testHeaderValue";

            gen.ValidateAndSetCustomHttpHeadersFromString("{" + testHeaderName + ":" + testHeaderValue + "}");

            Assert.IsNotNull(gen.CustomHttpHeaders);
            Assert.AreEqual(1, gen.CustomHttpHeaders.Count);
            Assert.AreEqual(testHeaderName, gen.CustomHttpHeaders.FirstOrDefault().Key);
            Assert.AreEqual(testHeaderValue, gen.CustomHttpHeaders.FirstOrDefault().Value);
        }
Exemple #2
0
        public void TestTheValidationErrorForMissingCurlyBreaketsAtTheBeginInHeaders()
        {
            var gen = new ODataT4CodeGenerator();

            gen.CustomHttpHeaders = null;
            var firstHeaderName  = "firstHeaderName";
            var firstHeaderValue = "firstHeaderValue";

            try
            {
                gen.ValidateAndSetCustomHttpHeadersFromString(firstHeaderName + firstHeaderValue + "}");
            }
            catch (ArgumentException ex)
            {
                Assert.IsNotNull(ex);
                return;
            }
            Assert.Fail();
        }
Exemple #3
0
        public void TestTheValidationForMultipleHeaders()
        {
            var gen = new ODataT4CodeGenerator();

            gen.CustomHttpHeaders = null;
            var firstHeaderName   = "firstHeaderName";
            var firstHeaderValue  = "firstHeaderValue";
            var secondHeaderName  = "secondHeaderName";
            var secondHeaderValue = "secondHeaderValue";

            gen.ValidateAndSetCustomHttpHeadersFromString("{" + firstHeaderName + ":" + firstHeaderValue + "},{" + secondHeaderName + ":" + secondHeaderValue + "}");

            Assert.IsNotNull(gen.CustomHttpHeaders);
            Assert.AreEqual(2, gen.CustomHttpHeaders.Count);
            Assert.AreEqual(firstHeaderName, gen.CustomHttpHeaders.FirstOrDefault().Key);
            Assert.AreEqual(firstHeaderValue, gen.CustomHttpHeaders.FirstOrDefault().Value);
            Assert.AreEqual(secondHeaderName, gen.CustomHttpHeaders.LastOrDefault().Key);
            Assert.AreEqual(secondHeaderValue, gen.CustomHttpHeaders.LastOrDefault().Value);
        }
Exemple #4
0
        public void TestTheValidationErrorForMissingCommaBetweenHeaders()
        {
            var gen = new ODataT4CodeGenerator();

            gen.CustomHttpHeaders = null;
            var firstHeaderName   = "firstHeaderName";
            var firstHeaderValue  = "firstHeaderValue";
            var secondHeaderName  = "secondHeaderName";
            var secondHeaderValue = "secondHeaderValue";

            try
            {
                gen.ValidateAndSetCustomHttpHeadersFromString("{" + firstHeaderName + ":" + firstHeaderValue + "}{" + secondHeaderName + ":" + secondHeaderValue + "}");
            }
            catch (ArgumentException ex)
            {
                Assert.IsNotNull(ex);
                return;
            }
            Assert.Fail();
        }