public void AcceptTrueWhenDisableVersioningTrue() { var acc = MockHelpers.HttpContext(ctx => { ctx.Setup(x => x.RequestServices.GetService(typeof(IOptions <ApiExtensionOptions>))).Returns <object>(x => new TestApiExtensionOptions(new ApiExtensionOptions { DisableVersioning = false })); }).ActionConstraintContext(); var versions = new VersionConstraint(new string[] { "v1" }); Assert.False(versions.Accept(acc)); }
public void AcceptFalseWhenDisableVersioningFalseAndInValid() { var acc = MockHelpers.HttpContext(ctx => { ctx.Setup(x => x.RequestServices.GetService(typeof(IOptions <ApiExtensionOptions>))).Returns <object>(x => new TestApiExtensionOptions(new ApiExtensionOptions { DisableVersioning = false })); }).ActionConstraintContext(); acc.RouteContext.RouteData.Values["apiVersion"] = "v2"; var versions = new VersionConstraint(new string[] { "v1" }); Assert.False(versions.Accept(acc)); }