public void CookiesAreCopied() { var value = CommonTestHelpers.GenerateList(5); var dictionary = CommonTestHelpers.GenerateDictionary(value); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetUrl(UrlParser.GenerateUri("/Home/Index")); httpRequest.Setup(p => p.Method).Returns("GET"); httpRequest.Setup(p => p.Cookies).Returns(new CustomRequestCookieCollection(dictionary)); var result = HttpRequestFactory.Create(httpRequest.Object); Assert.AreEqual(JsonSerializer.Serialize(value), JsonSerializer.Serialize(result.Properties.Cookies)); }
public void QueryStringIsCopied() { var value = CommonTestHelpers.GenerateList(5); var qs = new FormUrlEncodedContent(value).ReadAsStringAsync().Result; var dictionary = CommonTestHelpers.GenerateDictionary(value); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetUrl(UrlParser.GenerateUri("/Home/Index?" + qs)); httpRequest.Setup(p => p.Method).Returns("GET"); var result = HttpRequestFactory.Create(httpRequest.Object); Assert.AreEqual(JsonSerializer.Serialize(value), JsonSerializer.Serialize(result.Properties.QueryString)); }
public void FormDataIsCopied() { KissLog.Tests.Common.CommonTestHelpers.ResetContext(); var value = CommonTestHelpers.GenerateList(5); var dictionary = CommonTestHelpers.GenerateDictionary(value); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetUrl(UrlParser.GenerateUri("/Home/Index")); httpRequest.Setup(p => p.Method).Returns("GET"); httpRequest.Setup(p => p.HasFormContentType).Returns(true); httpRequest.Setup(p => p.Form).Returns(new CustomFormCollection(value.ToStringValuesDictionary())); var result = HttpRequestFactory.Create(httpRequest.Object); Assert.AreEqual(JsonSerializer.Serialize(value), JsonSerializer.Serialize(result.Properties.FormData)); }
public void EvaluatesOptionsShouldLogFormData() { KissLog.Tests.Common.CommonTestHelpers.ResetContext(); KissLogConfiguration.Options.ShouldLogFormData((KissLog.Http.HttpRequest args) => false); var value = CommonTestHelpers.GenerateList(5); var dictionary = CommonTestHelpers.GenerateDictionary(value); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetUrl(UrlParser.GenerateUri("/Home/Index")); httpRequest.Setup(p => p.Method).Returns("GET"); httpRequest.Setup(p => p.HasFormContentType).Returns(true); httpRequest.Setup(p => p.Form).Returns(new CustomFormCollection(value.ToStringValuesDictionary())); var result = HttpRequestFactory.Create(httpRequest.Object); Assert.AreEqual(0, result.Properties.FormData.Count()); }