public void TestGetCategories() { // Arrange var dbContext = DbContextMocker.GetDbContext(nameof(TestGetCategories)); var controller = new BlogController(dbContext); // Act if (controller.GetCategories() is ObjectResult response) { // Assert that categories are exactly 1 Assert.True(response.Value is IList <CategoryModel> value && value.Count == 1); } dbContext.Dispose(); }