Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }