Check out example codes for "adding values to mock IHttpContextAccessor unit test .net core". It will help you in understanding the concepts better.

Code Example 1

public async Task test_GetBookByBookId() {

    //Mock IHttpContextAccessor
    var mockHttpContextAccessor = new Mock<IHttpContextAccessor>();
    var context = new DefaultHttpContext();
    var fakeTenantId = "abcd";
    context.Request.Headers["Tenant-ID"] = fakeTenantId;
    mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);
    //Mock HeaderConfiguration
    var mockHeaderConfiguration = new Mock<IHeaderConfiguration>();
        .Setup(_ => _.GetTenantId(It.IsAny<IHttpContextAccessor>()))

    var book = new Book(mockHttpContextAccessor.Object, mockHeaderConfiguration.Object);

    var bookId = "100";

    var result = await book.GetBookByBookId(bookId);


Learn ReactJs, React Native from