public void TestApplicationNameRequired() { DfpSoapHeaderInspector inspector = new DfpSoapHeaderInspector() { Config = new DfpAppConfig() }; RequestHeader header = new RequestHeader() { networkCode = "12345" }; inspector.RequestHeader = header; Assert.Throws(typeof(DfpApiException), delegate() { inspector.BeforeSendRequest(ref this.message, this.channel); }, "No exception was thrown for a null application name"); header.applicationName = DfpAppConfig.DEFAULT_APPLICATION_NAME; Assert.Throws(typeof(DfpApiException), delegate() { inspector.BeforeSendRequest(ref this.message, this.channel); }, "No exception was thrown for the default application name"); header.applicationName = ""; Assert.Throws(typeof(DfpApiException), delegate() { inspector.BeforeSendRequest(ref this.message, this.channel); }, "No exception was thrown for an empty string application name"); }
public void TestNullHeaderInvalid() { DfpSoapHeaderInspector inspector = new DfpSoapHeaderInspector() { Config = new DfpAppConfig() }; Assert.Throws(typeof(DfpApiException), delegate() { inspector.BeforeSendRequest(ref this.message, this.channel); }, "No exception was thrown for a null header"); }
public void TestNullConfigInvalid() { DfpSoapHeaderInspector inspector = new DfpSoapHeaderInspector() { Config = null, RequestHeader = new RequestHeader() { networkCode = "12345" } }; Assert.Throws(typeof(DfpApiException), delegate() { inspector.BeforeSendRequest(ref this.message, this.channel); }, "No exception was thrown for a null Config"); }
public void TestValidHeaderApplied() { DfpSoapHeaderInspector inspector = new DfpSoapHeaderInspector(); RequestHeader header = new RequestHeader() { networkCode = "12345", }; DfpAppConfig config = new DfpAppConfig(); config.ApplicationName = "Unit test application"; inspector.Config = config; inspector.RequestHeader = (RequestHeader)header.Clone(); inspector.BeforeSendRequest(ref this.message, this.channel); Assert.AreEqual(1, this.message.Headers.Count); foreach (RequestHeader appliedHeader in this.message.Headers) { Assert.AreEqual("12345", appliedHeader.networkCode); Assert.AreEqual(config.GetUserAgent(), appliedHeader.applicationName); } }