public void When_entity_is_IHasETag() { var hashETag = new HashETag(); var expectedEtagValue = hashETag.ETag; var result = _eTagProvider.GetETag(hashETag); Assert.AreEqual(expectedEtagValue, result); }
public override void ExecuteResult(ControllerContext context) { HttpResponseBase response = context.HttpContext.Response; try { response.ClearHeaders(); response.ClearContent(); } catch { } response.TrySkipIisCustomErrors = true; if (this.Resource == null) { response.ContentType = "text/plain"; response.StatusCode = (int)HttpStatusCode.NotFound; response.Write(response.Status); return; } HttpContext httpContext = HttpContext.Current; // check if client has cached copy ETag etag = new HashETag(this.Resource.Hash); if (etag.HandleETag(httpContext, HttpCacheability.ServerAndPrivate, this.IsDebug)) { return; } if (String.IsNullOrEmpty(this.Resource.ContentType)) { response.ContentType = "text/plain"; } else { response.ContentType = this.Resource.ContentType; } // this helps IE determine the Content-Type // http://tools.ietf.org/html/rfc2183#section-2.3 ContentDisposition disposition = new ContentDisposition { Inline = !this.IsAttachment, FileName = String.IsNullOrEmpty(this.Filename) ? Path.GetFileNameWithoutExtension(this.ResourcePath) + '.' + this.Resource.FileExtension : this.Filename }; response.AddHeader("Content-Disposition", disposition.ToString()); ResourceHandler.WriteResponse(httpContext, this.Resource, this.IsDebug); }