public void OwinRequestUtilities_IsAjaxRequest_HasNoXMLHttpRequest_ShouldReturnFalse() { ConcurrentDictionary <string, string[]> dict = new ConcurrentDictionary <string, string[]>( new Dictionary <string, string[]>() { { "X-Requested-With", new[] { "He's a long-legged pissed-off puerto rican" } }, }); HeaderDictionary header = new HeaderDictionary( new Dictionary <string, string[]>() { { "NOT-X-Requested-With", new[] { "False" } }, }); FormCollection form = new FormCollection(dict); var owinRequestMock = new Mock <IOwinRequest>(); owinRequestMock.Setup(x => x.Query).Returns(form); owinRequestMock.Setup(x => x.Headers).Returns(header); IOwinRequest owinRequest = owinRequestMock.Object; Assert.IsTrue(!owinRequest.IsAjaxRequest()); }
public void OwinRequestUtilities_IsAjaxRequest_HasXMLHttpRequest_ShouldReturnTrue() { ConcurrentDictionary <string, string[]> dict = new ConcurrentDictionary <string, string[]>( new Dictionary <string, string[]>() { { "X-Requested-With", new[] { "XMLHttpRequest" } }, }); FormCollection form = new FormCollection(dict); var owinRequestMock = new Mock <IOwinRequest>(); owinRequestMock.Setup(x => x.Query).Returns(form); owinRequestMock.Setup(x => x.Headers).Returns(new Mock <IHeaderDictionary>().Object); IOwinRequest owinRequest = owinRequestMock.Object; Assert.IsTrue(owinRequest.IsAjaxRequest()); }
public void when_this_is_null_shoule_return_false() { IOwinRequest owinRequest = null; Assert.False(owinRequest.IsAjaxRequest()); }