public void ValidateUriShouldThrowExceptionWithIncorrectString()
        {
            var actionResultWithLocation = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().AndProvideTheController());

            LocationValidator.ValidateUri(
                actionResultWithLocation,
                new Uri("http://somehost.com/"),
                TestObjectFactory.GetFailingValidationAction());
        }
        public void ValidateMediaTypeFormatterShouldThrowExceptionWithIncorrectMediaTypeFormatter()
        {
            var actionResultWithFormatters = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().AndProvideTheController());

            MediaTypeFormatterValidator.ValidateMediaTypeFormatter(
                actionResultWithFormatters,
                TestObjectFactory.GetCustomMediaTypeFormatter(),
                TestObjectFactory.GetFailingValidationAction());
        }
        public void ValidateUriShouldNotThrowExceptionWithProperUriWithCorrectString()
        {
            var actionResultWithLocation = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().AndProvideTheController());

            LocationValidator.ValidateUri(
                actionResultWithLocation,
                TestObjectFactory.GetUri(),
                TestObjectFactory.GetFailingValidationAction());
        }
        public void ValidateBindingShouldThrowExceptionWithInvalidPropertyCall()
        {
            var actionResultWithFormatters = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().Controller);

            RuntimeBinderValidator.ValidateBinding(() =>
            {
                var contentNegotiator = (actionResultWithFormatters as dynamic).ModelState;
                Assert.IsNotNull(contentNegotiator);
            });
        }
        public void ValidateLocationShouldNotThrowExceptionWithCorrectLocationBuilder()
        {
            var actionResultWithLocation = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().Controller);

            LocationValidator.ValidateLocation(
                actionResultWithLocation,
                location =>
                    location
                        .WithHost("somehost.com")
                        .AndAlso()
                        .WithAbsolutePath("/someuri/1")
                        .AndAlso()
                        .WithPort(80)
                        .AndAlso()
                        .WithScheme("http")
                        .AndAlso()
                        .WithFragment(string.Empty)
                        .AndAlso()
                        .WithQuery("?query=Test"),
                TestObjectFactory.GetFailingValidationAction());
        }
        public void ValidateMediaTypeFormattersBuilderShouldNotThrowExceptionWithCorrectBuilder()
        {
            var actionResultWithFormatters = new CreatedNegotiatedContentResult<int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller<WebApiController>().AndProvideTheController());

            MediaTypeFormatterValidator.ValidateMediaTypeFormattersBuilder(
                actionResultWithFormatters,
                formatters => formatters
                        .ContainingMediaTypeFormatter(new JsonMediaTypeFormatter())
                        .AndAlso()
                        .ContainingMediaTypeFormatterOfType<FormUrlEncodedMediaTypeFormatter>(),
                TestObjectFactory.GetFailingValidationAction());
        }
            public void When_A_Successful_Post_Had_Occurred()
            {
                apiSettingsData.Setup(f => f.GetByApiKeyAsync("creates-entry")).Returns(Task.FromResult(new ApiHostForwardingSettings() { ForwardApiHostName = "somedomain.test.com" }));

                configurationController.Request = new HttpRequestMessage();

                result = configurationController.Post(new UpdateClientProxyConfigurationRequest() { ApiKey = "creates-entry" }).Result as CreatedNegotiatedContentResult<ClientProxyApiConfiguration>;                
            }