From 2f116f9ebadf9771bcfc68c86d28a27bd60212ce Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 00:25:22 +0000 Subject: [PATCH] Update Tests/SellerAPI.Tests/SellerControllerTests.cs --- .../SellerAPI.Tests/SellerControllerTests.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Tests/SellerAPI.Tests/SellerControllerTests.cs diff --git a/Tests/SellerAPI.Tests/SellerControllerTests.cs b/Tests/SellerAPI.Tests/SellerControllerTests.cs new file mode 100644 index 000000000..9d7c1e8f5 --- /dev/null +++ b/Tests/SellerAPI.Tests/SellerControllerTests.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc; +using Src.Controllers; +using Src.Models; +using Src.Repositories; +using Xunit; + +namespace Tests.SellerAPI.Tests +{ + public class SellerControllerTests + { + private readonly SellerController _controller; + private readonly SellerRepository _repository; + + public SellerControllerTests() + { + _repository = new SellerRepository(); + _controller = new SellerController(_repository); + } + + [Fact] + public void GetSeller_ReturnsNotFound_WhenSellerDoesNotExist() + { + var result = _controller.GetSeller(1); + Assert.IsType(result.Result); + } + + [Fact] + public void CreateSeller_ReturnsCreatedAtActionResult() + { + var seller = new Seller { Id = 1, Name = "Test Seller", ContactInfo = "test@example.com" }; + var result = _controller.CreateSeller(seller); + Assert.IsType(result); + } + + [Fact] + public void GetSeller_ReturnsSeller_WhenSellerExists() + { + var seller = new Seller { Id = 1, Name = "Test Seller", ContactInfo = "test@example.com" }; + _repository.AddSeller(seller); + var result = _controller.GetSeller(1); + Assert.IsType(result.Result); + } + } +}