public void Setup() { Mock<IDefaultValueRelationSelector> defaultSourceSelector = new Mock<IDefaultValueRelationSelector>(MockBehavior.Strict); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny<ParameterInfo>(), It.IsAny<Verb>())) .Returns<ParameterInfo, Verb>((parameter, verb) => FromQueryStringAttribute.For(parameter)); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny<ParameterInfo>())) .Returns<ParameterInfo>(parameter => new ToBodyAttribute()); _builder = new ControllerDescriptionBuilder<AnotherTestController<TestController>>(defaultSourceSelector.Object); }
public void Setup() { Mock <IDefaultValueRelationSelector> defaultSourceSelector = new Mock <IDefaultValueRelationSelector>(MockBehavior.Strict); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny <ParameterInfo>(), It.IsAny <Verb>())) .Returns <ParameterInfo, Verb>((parameter, verb) => FromQueryStringAttribute.For(parameter)); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny <ParameterInfo>())) .Returns <ParameterInfo>(parameter => new ToBodyAttribute()); _builder = new ControllerDescriptionBuilder <AnotherTestController <TestController> >(defaultSourceSelector.Object); }
public void Setup() { Mock<IDefaultValueRelationSelector> defaultSourceSelector = new Mock<IDefaultValueRelationSelector>(MockBehavior.Strict); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny<ParameterInfo>(), It.IsAny<Verb>())) .Returns<ParameterInfo, Verb>((parameter, verb) => (parameter.ParameterType == typeof(int) ? (ParameterSourceAttribute)FromUrlAttribute.For(parameter) : FromBodyAttribute.For(parameter))); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny<ParameterInfo>())) .Returns<ParameterInfo>(parameter => new ToBodyAttribute()); _builder = new ControllerDescriptionBuilder<CrudController>(defaultSourceSelector.Object); }
public void Setup() { Mock <IDefaultValueRelationSelector> defaultSourceSelector = new Mock <IDefaultValueRelationSelector>(MockBehavior.Strict); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny <ParameterInfo>(), It.IsAny <Verb>())) .Returns <ParameterInfo, Verb>((parameter, verb) => (parameter.ParameterType == typeof(int) ? (ParameterSourceAttribute)FromUrlAttribute.For(parameter) : FromBodyAttribute.For(parameter))); defaultSourceSelector.Setup(instance => instance.ProvideDefault(It.IsAny <ParameterInfo>())) .Returns <ParameterInfo>(parameter => new ToBodyAttribute()); _builder = new ControllerDescriptionBuilder <CrudController>(defaultSourceSelector.Object); }
public void it_should_handle_Create_request_correctly() { var person = new Person() { Key = 1 }; string callUri; var controllerDescription = new ControllerInfo <CrudController>( null, (HttpUrl)UrlParser.Parse("api/test"), Controller.GetType().GetMethod("Get").ToOperationInfo("api/test", Verb.GET, out callUri, person.Key), Controller.GetType().GetMethod("Create").ToOperationInfo("api/test", Verb.POST, out callUri, person)); ControllerDescriptionBuilder.As <IControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(controllerDescription); var result = Composer.ComposeResponse(CreateRequestMapping("Create", Verb.POST, person), person.Key, person); result.Should().BeOfType <StringResponseInfo>(); result.Status.Should().Be(HttpStatusCode.Created); result.Headers.Should().ContainKey("Location").WhichValue.Should().Be("/api/test/" + person.Key); Converter.Verify(instance => instance.ConvertFrom(person.Key, It.IsAny <IResponseInfo>()), Times.Never); }
public void Teardown() { _builder = null; }
public void Teardown() { _builder = null; }