Beispiel #1
0
        public void OnActionExecuted_DoesntChangeTheResponse_IfNonODataRequests()
        {
            HttpRequestMessage        request        = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");
            ODataNullValueAttribute   odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage       response       = SetUpResponse(HttpStatusCode.OK, null, typeof(object));
            HttpActionExecutedContext context        = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
        public void OnActionExecuted_DoesntChangeTheResponse_IfResponseIsntSuccessful()
        {
            IEdmModel model = new Mock<IEdmModel>().Object;
            ODataPath path = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                           new KeyValuePathSegment("FakeKey"),
                                           new PropertyAccessPathSegment("FakeProperty"),
                                           new ValuePathSegment());
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");
            request.ODataProperties().Model = model;
            request.ODataProperties().Path = path;
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage response = SetUpResponse(HttpStatusCode.InternalServerError, null, typeof(object));
            HttpActionExecutedContext context = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
Beispiel #3
0
        public void OnActionExecuted_DoesntChangeTheResponse_OfOtherODataRequests()
        {
            IEdmModel model = new Mock <IEdmModel>().Object;
            ODataPath path  = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                            new KeyValuePathSegment("FakeKey"),
                                            new PropertyAccessPathSegment("FakeProperty"));
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");

            request.ODataProperties().Model          = model;
            request.ODataProperties().Path           = path;
            ODataNullValueAttribute   odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage       response       = SetUpResponse(HttpStatusCode.InternalServerError, null, typeof(object));
            HttpActionExecutedContext context        = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
        public void OnActionExecuted_DoesntChangeTheResponse_IfContentIsntNull()
        {
            IEdmModel model = new Mock<IEdmModel>().Object;
            ODataPath path = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                           new KeyValuePathSegment("FakeKey"),
                                           new PropertyAccessPathSegment("FakeProperty"),
                                           new ValuePathSegment());
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");
            request.SetEdmModel(model);
            request.SetODataPath(path);
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage response = SetUpResponse(HttpStatusCode.OK, 5, typeof(int));
            HttpActionExecutedContext context = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
        public void OnActionExecuted_DoesntChangeTheResponse_IfContentIsntNull()
        {
            IEdmModel model = new Mock <IEdmModel>().Object;
            ODataPath path  = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                            new KeyValuePathSegment("FakeKey"),
                                            new PropertyAccessPathSegment("FakeProperty"),
                                            new ValuePathSegment());
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");

            request.SetEdmModel(model);
            request.SetODataPath(path);
            ODataNullValueAttribute   odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage       response       = SetUpResponse(HttpStatusCode.OK, 5, typeof(int));
            HttpActionExecutedContext context        = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
        public void OnActionExecuted_Generates404_IfContentIsNull()
        {
            IEdmModel model = new Mock<IEdmModel>().Object;
            ODataPath path = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                           new KeyValuePathSegment("FakeKey"),
                                           new PropertyAccessPathSegment("FakeProperty"),
                                           new ValuePathSegment());
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");
            request.ODataProperties().Model = model;
            request.ODataProperties().Path = path;
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage response = SetUpResponse(HttpStatusCode.OK, null, typeof(object));
            HttpActionExecutedContext context = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.NotNull(context.Response);
            Assert.Equal(HttpStatusCode.NotFound, context.Response.StatusCode);
        }
Beispiel #7
0
        public void OnActionExecuted_Generates404_IfContentIsNull()
        {
            IEdmModel model = new Mock <IEdmModel>().Object;
            ODataPath path  = new ODataPath(new EntitySetPathSegment("FakeEntitySet"),
                                            new KeyValuePathSegment("FakeKey"),
                                            new PropertyAccessPathSegment("FakeProperty"),
                                            new ValuePathSegment());
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");

            request.ODataProperties().Model          = model;
            request.ODataProperties().Path           = path;
            ODataNullValueAttribute   odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage       response       = SetUpResponse(HttpStatusCode.OK, null, typeof(object));
            HttpActionExecutedContext context        = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.NotNull(context.Response);
            Assert.Equal(HttpStatusCode.NotFound, context.Response.StatusCode);
        }
Beispiel #8
0
        public void Ctor_ThrowsArgumentNull_ActionExecutedContext()
        {
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();

            Assert.ThrowsArgumentNull(() => { odataNullValue.OnActionExecuted(null); }, "actionExecutedContext");
        }
        public void OnActionExecuted_DoesntChangeTheResponse_IfNonODataRequests()
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/");
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();
            HttpResponseMessage response = SetUpResponse(HttpStatusCode.OK, null, typeof(object));
            HttpActionExecutedContext context = SetUpContext(request, response);

            odataNullValue.OnActionExecuted(context);

            Assert.Equal(response, context.Response);
        }
        public void Ctor_ThrowsArgumentNull_ActionExecutedContext()
        {
            ODataNullValueAttribute odataNullValue = new ODataNullValueAttribute();

            Assert.ThrowsArgumentNull(() => { odataNullValue.OnActionExecuted(null); }, "actionExecutedContext");
        }