public void DefaultRouteKeyRequestControllerVersionDetector_ThrowsException_WhenNoVersionInApiRoute()
        {
            // given
            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage      msg          = new HttpRequestMessage();

            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary <string, object>());

            // when
            nameDetector.GetVersion(msg);

            // then
            Assert.Inconclusive();
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ReturnsNullVersion_FromNullVersionRequest()
        {
            // given
            const string controllerVersion = "3.93";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage msg = new HttpRequestMessage();
            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary<string, object>() {
                                                                                                       {
                                                                                                           "version",
                                                                                                           null
                                                                                                       }
                                                                                                   });

            // when
            ApiVersion semVerApiVersion = nameDetector.GetVersion(msg);

            // then
            Assert.IsNull(semVerApiVersion, "Expected version number to be null since it is null in the route also");
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ReturnsControllerVersion_FromDoubleVersionRequest()
        {
            // given
            const string controllerVersion = "3.93";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage msg = new HttpRequestMessage();
            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary<string, object>() {
                                                                                                       {
                                                                                                           "version",
                                                                                                           controllerVersion
                                                                                                       }
                                                                                                   });

            // when
            SemVerApiVersion semVerApiVersion = nameDetector.GetVersion(msg) as SemVerApiVersion;

            // then
            Assert.IsNotNull(semVerApiVersion, "Expected version number to be detected");
            Assert.AreEqual(new Version(3, 93), semVerApiVersion.Version);
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ReturnsNullVersion_FromNullVersionRequest()
        {
            // given
            const string controllerVersion = "3.93";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage      msg          = new HttpRequestMessage();

            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary <string, object>()
            {
                {
                    "version",
                    null
                }
            });

            // when
            ApiVersion semVerApiVersion = nameDetector.GetVersion(msg);

            // then
            Assert.IsNull(semVerApiVersion, "Expected version number to be null since it is null in the route also");
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ThrowsException_WhenApiVersionUnparsable()
        {
            // given
            const string controllerVersion = "3.unparsable";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage      msg          = new HttpRequestMessage();

            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary <string, object>()
            {
                {
                    "version",
                    controllerVersion
                }
            });

            // when
            nameDetector.GetVersion(msg);

            // then
            Assert.Inconclusive();
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ReturnsControllerVersion_FromDoubleVersionRequest()
        {
            // given
            const string controllerVersion = "3.93";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage      msg          = new HttpRequestMessage();

            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary <string, object>()
            {
                {
                    "version",
                    controllerVersion
                }
            });

            // when
            SemVerApiVersion semVerApiVersion = nameDetector.GetVersion(msg) as SemVerApiVersion;

            // then
            Assert.IsNotNull(semVerApiVersion, "Expected version number to be detected");
            Assert.AreEqual(new Version(3, 93), semVerApiVersion.Version);
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ThrowsException_WhenApiVersionUnparsable()
        {
            // given
            const string controllerVersion = "3.unparsable";

            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage msg = new HttpRequestMessage();
            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary<string, object>(){
                                                                                                       {
                                                                                                           "version",
                                                                                                           controllerVersion
                                                                                                       }
                                                                                                   });

            // when
            nameDetector.GetVersion(msg);

            // then
            Assert.Inconclusive();
        }
        public void DefaultRouteKeyRequestControllerVersionDetector_ThrowsException_WhenNoVersionInApiRoute()
        {
            // given
            IRequestVersionDetector nameDetector = new DefaultRouteKeyVersionDetector();
            HttpRequestMessage msg = new HttpRequestMessage();
            msg.Properties[RouteContextKey] = GetMockingRouteData(new Dictionary<string, object>());

            // when
            nameDetector.GetVersion(msg);

            // then
            Assert.Inconclusive();
        }