public void IsNoCacheRequested_ContainsNoCache_True() { // Act var result = OwinHttpRequestHelper.IsNoCacheRequested("no-cache"); // Assert Assert.IsTrue(result); }
public void IsNoCacheRequested_NullHeader_False() { // Act var result = OwinHttpRequestHelper.IsNoCacheRequested(null); // Assert Assert.IsFalse(result); }
public void GetRelativeFilePath_EmptyPath_EmptyString() { // Assign var request = new Mock <HttpRequest>(); request.SetupGet(x => x.Path).Returns(new PathString()); // Act var result = OwinHttpRequestHelper.GetRelativeFilePath(request.Object); // Assert Assert.AreEqual("", result); }
public void GetRelativeFilePath_PathWhtStartSlash_StartSlashTrimmed() { // Assign var request = new Mock <HttpRequest>(); request.SetupGet(x => x.Path).Returns(new PathString("/test")); // Act var result = OwinHttpRequestHelper.GetRelativeFilePath(request.Object); // Assert Assert.AreEqual("test", result); }
public void GetIfModifiedSinceTime_NoExists_Null() { // Assign var headers = new Mock <IHeaderDictionary>(); headers.Setup(x => x.ContainsKey(It.Is <string>(p => p == "If-Modified-Since"))).Returns(false); // Act var result = OwinHttpRequestHelper.GetIfModifiedSinceTime(headers.Object); // Assert Assert.IsNull(result); }
public void GetIfModifiedSinceTime_Exists_Parsed() { // Assign var time = new DateTime(2016, 03, 04); var headers = new Mock <IHeaderDictionary>(); headers.SetupGet(x => x[It.Is <string>(p => p == "If-Modified-Since")]).Returns(time.ToString("r")); headers.Setup(x => x.ContainsKey(It.Is <string>(p => p == "If-Modified-Since"))).Returns(true); // Act var result = OwinHttpRequestHelper.GetIfModifiedSinceTime(headers.Object); // Assert Assert.IsNotNull(result); Assert.AreEqual(time, result); }
/// <summary> /// Gets the relative file path of request. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public string GetRelativeFilePath(IOwinRequest request) { return(OwinHttpRequestHelper.GetRelativeFilePath(request)); }
/// <summary> /// Determines whether file can be used from cached. /// </summary> /// <param name="cacheControlHeader">The cache control header.</param> /// <param name="ifModifiedSinceHeader">If modified since header.</param> /// <param name="fileLastModifiedTime">The file last modified time.</param> /// <returns></returns> public bool IsFileCanBeUsedFromCache(string cacheControlHeader, DateTime?ifModifiedSinceHeader, DateTime fileLastModifiedTime) { return(!OwinHttpRequestHelper.IsNoCacheRequested(cacheControlHeader) && ifModifiedSinceHeader != null && fileLastModifiedTime <= ifModifiedSinceHeader.Value); }
/// <summary> /// Gets If-Modified-Since time header from headers collection. /// </summary> /// <param name="headers">The headers.</param> /// <returns></returns> public DateTime?GetIfModifiedSinceTime(IHeaderDictionary headers) { return(OwinHttpRequestHelper.GetIfModifiedSinceTime(headers)); }