public void Should_not_match_when_value_is_not_in_correct_format() { var constraint = new GuidConstraint(); var matched = constraint.Match(new Mock<HttpContextBase>().Object, new Route("{controller}/{action}", new Mock<IRouteHandler>().Object), "id", new RouteValueDictionary { { "id", "foobar" } }, RouteDirection.IncomingRequest); Assert.False(matched); }
public void Should_match_when_parameter_is_optional() { var constraint = new GuidConstraint(true); var matched = constraint.Match(new Mock<HttpContextBase>().Object, new Route("{controller}/{action}", new Mock<IRouteHandler>().Object), "id", new RouteValueDictionary(), RouteDirection.IncomingRequest); Assert.True(matched); }
public void Should_match_when_parameter_is_optional() { var constraint = new GuidConstraint(true); var matched = constraint.Match(new Mock <HttpContextBase>().Object, new Route("{controller}/{action}", new Mock <IRouteHandler>().Object), "id", new RouteValueDictionary(), RouteDirection.IncomingRequest); Assert.True(matched); }
public void Setup() { _constraint = new GuidConstraint(); _httpContextBase = A.Fake <HttpContextBase>(); _parameterName = "assessmentId"; _route = A.Fake <Route>(); }
private static bool Match(string parameterName, string parameterNameInCollection, object value) { var mockedContext = new Mock <HttpContextBase>(); IRouteConstraint guidConstraint = new GuidConstraint(); var routeValueDictionary = new RouteValueDictionary(new Dictionary <string, object> { { parameterNameInCollection, value } }); return(guidConstraint.Match(mockedContext.Object, new Route(null, null), parameterName, routeValueDictionary, RouteDirection.IncomingRequest)); }
public void Should_not_match_when_value_is_empty() { var constraint = new GuidConstraint(); var matched = constraint.Match(new Mock <HttpContextBase>().Object, new Route("{controller}/{action}", new Mock <IRouteHandler>().Object), "id", new RouteValueDictionary { { "id", Guid.Empty } }, RouteDirection.IncomingRequest); Assert.False(matched); }