Esempio n. 1
0
        public void HttpOkResult_InitializesStatusCode()
        {
            // Arrange & Act
            var result = new OkResult();

            // Assert
            Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
        }
        public void Convert_ReturnsResultIfSet()
        {
            // Arrange
            var expected              = new OkResult();
            var actionResultOfT       = new ActionResult <string>(expected);
            var convertToActionResult = (IConvertToActionResult)actionResultOfT;

            // Act
            var result = convertToActionResult.Convert();

            // Assert
            Assert.Same(expected, result);
        }
Esempio n. 3
0
        public async Task HttpOkResult_SetsStatusCode()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();
            httpContext.RequestServices = CreateServices().BuildServiceProvider();

            var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
            var result = new OkResult();

            // Act
            await result.ExecuteResultAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status200OK, context.HttpContext.Response.StatusCode);
        }
Esempio n. 4
0
        public async Task HttpOkResult_SetsStatusCode()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();

            httpContext.RequestServices = CreateServices().BuildServiceProvider();

            var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
            var result  = new OkResult();

            // Act
            await result.ExecuteResultAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status200OK, context.HttpContext.Response.StatusCode);
        }