Skip to content

Commit

Permalink
Update Tests/SellerAPI.Tests/SellerControllerTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
gitauto-ai[bot] authored Nov 6, 2024
1 parent fcd9860 commit 2f116f9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Tests/SellerAPI.Tests/SellerControllerTests.cs
Original file line number Diff line number Diff line change
@@ -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<NotFoundResult>(result.Result);
}

[Fact]
public void CreateSeller_ReturnsCreatedAtActionResult()
{
var seller = new Seller { Id = 1, Name = "Test Seller", ContactInfo = "[email protected]" };
var result = _controller.CreateSeller(seller);
Assert.IsType<CreatedAtActionResult>(result);
}

[Fact]
public void GetSeller_ReturnsSeller_WhenSellerExists()
{
var seller = new Seller { Id = 1, Name = "Test Seller", ContactInfo = "[email protected]" };
_repository.AddSeller(seller);
var result = _controller.GetSeller(1);
Assert.IsType<OkObjectResult>(result.Result);
}
}
}

0 comments on commit 2f116f9

Please sign in to comment.