public void RetrieveTokenHeaderTest_MultipleHeaders_Success() { Mock <HttpClient> moqHttpClient = new Mock <HttpClient>(MockBehavior.Strict); BadsecClient client = new BadsecClient(moqHttpClient.Object); IList <string> headerValues = new List <string> { "headernumber1", "headernumber2" }; HttpResponseMessage response = new HttpResponseMessage(); response.Headers.Add(BadsecClient.AuthTokenHeader, headerValues); string tokenHeader = client.RetrieveTokenHeader(response); Assert.AreEqual( expected: headerValues.First(), actual: tokenHeader, message: "The token header is not the same as what was expected."); }
public void RetrieveTokenHeaderTests_Success() { Mock <HttpClient> moqHttpClient = new Mock <HttpClient>(MockBehavior.Strict); BadsecClient client = new BadsecClient(moqHttpClient.Object); var testData = new[] { new { HeaderValue = "thisisatest", Expected = "thisisatest" }, new { HeaderValue = String.Empty, Expected = String.Empty } }; foreach (var data in testData) { Console.WriteLine("Running the scenario - Auth Token Header = " + data.HeaderValue); HttpResponseMessage response = new HttpResponseMessage(); if (!String.IsNullOrWhiteSpace(data.HeaderValue)) { response.Headers.Add(BadsecClient.AuthTokenHeader, data.HeaderValue); } string tokenHeader = client.RetrieveTokenHeader(response); Assert.AreEqual( expected: data.Expected, actual: tokenHeader, message: "The token header is not the same as what was expected."); } }