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); }
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(); }
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); }
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(); }