37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
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<ICategoryService>();
|
|
_categoryController = new CategoryController(_categoryService);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetCategories_ReturnsAllCategories()
|
|
{
|
|
_categoryService.GetCategories().Returns(TestData.CategoryTestData);
|
|
|
|
var result = await _categoryController.GetCategories();
|
|
var resultObject = ControllerTestHelper.ActionResultToOkResultValue<IEnumerable<Category>>(result);
|
|
|
|
Assert.AreEqual(TestData.CategoryTestData.Length, resultObject.Count());
|
|
}
|
|
} |