this test always return null, and test always fail...but when i run the projet all works fine and return data normally, this project using RavenDB
Controller
[Route("api/[controller]")]
public class CategoryController : Controller
{
private readonly AppDbContext _context = new AppDbContext();
// GET: api/category
[HttpGet("{id}")]
public async Task<JsonResult> Get(string id)
{
using (IAsyncDocumentSession session = _context.SessionAsync){
var result = await session.LoadAsync<Category>(id);
return Json(result);
}
}
}
and using xUnit to testing
[Fact]
public async Task GetShouldReturnCategory()
{
// Arrange
var _categoryController = Substitute.For<CategoryController>();
var category = CreateCategory();
// Act
var result = await _categoryController.Get(category.Result.Id);
//Asserts here
}