using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LeedsBeerQuest.API.Controllers; using LeedsBeerQuest.API.Data.Models; using LeedsBeerQuest.API.Data.Services.Interfaces; using LeedsBeerQuest.API.Tests.Data.Services; using LeedsBeerQuest.API.Tests.TestHelpers; using NSubstitute; using NUnit.Framework; namespace LeedsBeerQuest.API.Tests.Controllers; [TestFixture] public class CategoryControllerTests { private ICategoryService _categoryService; private CategoryController _categoryController; [SetUp] public void SetUp() { _categoryService = Substitute.For(); _categoryController = new CategoryController(_categoryService); } [Test] public async Task GetCategories_ReturnsOk_WithAllCategories() { _categoryService.GetCategories().Returns(TestData.CategoryTestData); var result = await _categoryController.GetCategories(); var resultObject = ControllerTestHelper.ActionResultToOkResultValue>(result); Assert.AreEqual(TestData.CategoryTestData.Length, resultObject.Count()); } }