-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Tests/SellerAPI.Tests/SellerControllerTests.cs
- Loading branch information
1 parent
fcd9860
commit 2f116f9
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |