void before_each() { output = new Mock<TextWriter>(); HyperMediaRegistry.Instance.FindAllIn<Index>(); ApplicationFormatterRegistry.Instance.FindAllIn<Index>(); headers = new NameValueCollection(); resourceName = "Root"; hyperMediaName = "Index"; objectToSerialize = new { }; response = new Mock<HttpResponseBase>(); requestContext = new Mock<RequestContext>(); response.SetupSet(s => s.ContentType = It.IsAny<string>()).Callback<string>(s => contentType = s); response.Setup(s => s.Output).Returns(output.Object); request = new Mock<HttpRequestBase>(); request.Setup(s => s.Headers).Returns(headers); httpContext = new Mock<HttpContextBase>(); httpContext.Setup(s => s.Response).Returns(response.Object); httpContext.Setup(s => s.Request).Returns(request.Object); controllerContext = new Mock<ControllerContext>(); controllerContext.Setup(s => s.HttpContext).Returns(httpContext.Object); hyperMediaResult = new HyperMediaResult(resourceName, hyperMediaName, new UrlHelper(requestContext.Object), objectToSerialize); }
void when_initializing_hyper_media_result_for_one_that_doesnt_exist() { it["throws exception"] = expect<InvalidOperationException>(() => hyperMediaResult = new HyperMediaResult("Users", "Index", null, null)); }