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

            // Assert
            Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo 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);
        }
Exemplo 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);
        }