Esempio n. 1
0
        // PUT: api/Hey/5
        public IHttpActionResult Put(string id, [FromBody] HeyRememberDto heyRemember)
        {
            heyRemember.Id = id;
            IHeyResponse heyResponse = _heyService.Update(id, heyRemember);

            return(heyResponse.Execute(this));
        }
Esempio n. 2
0
        public void TestThatIfTheMethodIsNotCallableICreatesTheNotOkResponse()
        {
            HeyResponseFactory factory  = new HeyResponseFactory(new MethodNotFound(new HeyRememberDto()));
            IHeyResponse       response = factory.Make(BackgroundScheduleType.MakePrototype());

            Assert.IsInstanceOf <MethodNotFoundHeyResponse>(response);
        }
Esempio n. 3
0
        public void TestThatIfTheMethodHasErrorOnParameterItReturnsNotOkResponse()
        {
            MethodInfo   method = typeof(FactoryBindingTest).GetMethod(nameof(FactoryBindingTest.WithParametersBindableMethod));
            MethodBinder binder = new MethodBinder(method, new HeyRememberDto());

            HeyResponseFactory factory  = new HeyResponseFactory(binder);
            IHeyResponse       response = factory.Make(BackgroundScheduleType.MakePrototype());

            Assert.IsInstanceOf <ParametersErrorHeyResponse>(response);
        }
Esempio n. 4
0
        public void TestThatIfTheMethodIsCallableICreatesTheOkResponse()
        {
            MethodInfo   method = typeof(FactoryBindingTest).GetMethod(nameof(FactoryBindingTest.EmptyBindableMethod));
            MethodBinder binder = new MethodBinder(method, new HeyRememberDto());

            HeyResponseFactory factory  = new HeyResponseFactory(binder);
            IHeyResponse       response = factory.Make(BackgroundScheduleType.MakePrototype(), new CreatedHttpReturn());

            Assert.IsInstanceOf <OkHeyResponse>(response);
        }
Esempio n. 5
0
        public void TestThatIfTheMethodHasErrorOnParameterTypeItReturnsNotOkResponseWithTheNumberOfTheParameterThatGotError()
        {
            MethodInfo   method = typeof(FactoryBindingTest).GetMethod(nameof(FactoryBindingTest.WithParametersBindableMethod));
            MethodBinder binder = new MethodBinder(method, new HeyRememberDto()
            {
                DomainSpecificData = "[1, \"banana\"]"
            });

            HeyResponseFactory factory  = new HeyResponseFactory(binder);
            IHeyResponse       response = factory.Make(BackgroundScheduleType.MakePrototype());

            Assert.IsInstanceOf <ParametersErrorHeyResponse>(response);
            Assert.AreEqual(1, ((ParametersErrorHeyResponse)response).ParamNum);
        }
Esempio n. 6
0
        // DELETE: api/Hey/5
        public IHttpActionResult Delete(string id)
        {
            IHeyResponse heyResponse = _heyService.Delete(id);

            return(heyResponse.Execute(this));
        }
Esempio n. 7
0
        public IHttpActionResult Post([FromBody] HeyRememberDto heyRemember)
        {
            IHeyResponse heyResponse = _heyService.Create(heyRemember);

            return(heyResponse.Execute(this));
        }