Check out example codes for "how to mock abstract httpcontext using moq .net core". It will help you in understanding the concepts better.

Code Example 1

var request = new Mock<HttpRequest>();
request.Setup(x => x.Scheme).Returns("http");
request.Setup(x => x.Host).Returns(HostString.FromUriComponent("http://localhost:8080"));
request.Setup(x => x.PathBase).Returns(PathString.FromUriComponent("/api"));

var httpContext = Mock.Of<HttpContext>(_ => 
    _.Request == request.Object

//Controller needs a controller context 
var controllerContext = new ControllerContext() {
    HttpContext = httpContext,
//assign context to controller
var controller = new SomeController(){
    ControllerContext = controllerContext,

String expected = "expected value here";

String actual = await controller.SomeMethodPost();

Assert.AreEqual(expected, actual);


Learn ReactJs, React Native from