-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write user service constructor tests
- Loading branch information
Showing
2 changed files
with
59 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
57 changes: 57 additions & 0 deletions
57
src/Logs.Services.Tests/UserServiceTests/ConstructorTests.cs
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,57 @@ | ||
using System; | ||
using Logs.Data.Contracts; | ||
using Logs.Models; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace Logs.Services.Tests.UserServiceTests | ||
{ | ||
[TestFixture] | ||
public class ConstructorTests | ||
{ | ||
[Test] | ||
public void TestConstructor_PassRepositoryNull_ShouldThrowArgumentNullException() | ||
{ | ||
// Arrange | ||
var mockedUnitOfWork = new Mock<IUnitOfWork>(); | ||
|
||
// Act, Assert | ||
Assert.Throws<ArgumentNullException>(() => new UserService(null, mockedUnitOfWork.Object)); | ||
} | ||
|
||
[Test] | ||
public void TestConstructor_PassUnitOfWorkNull_ShouldThrowArgumentNullException() | ||
{ | ||
// Arrange | ||
var mockedRepository = new Mock<IRepository<User>>(); | ||
|
||
// Act, Assert | ||
Assert.Throws<ArgumentNullException>(() => new UserService(mockedRepository.Object, null)); | ||
} | ||
|
||
[Test] | ||
public void TestConstructor_PassEverythingCorrectly_ShouldNotThrow() | ||
{ | ||
// Arrange | ||
var mockedRepository = new Mock<IRepository<User>>(); | ||
var mockedUnitOfWork = new Mock<IUnitOfWork>(); | ||
|
||
// Act, Assert | ||
Assert.DoesNotThrow(() => new UserService(mockedRepository.Object, mockedUnitOfWork.Object)); | ||
} | ||
|
||
[Test] | ||
public void TestConstructor_PassEverythingCorrectly_ShouldInitializeCorrectly() | ||
{ | ||
// Arrange | ||
var mockedRepository = new Mock<IRepository<User>>(); | ||
var mockedUnitOfWork = new Mock<IUnitOfWork>(); | ||
|
||
// Act | ||
var service = new UserService(mockedRepository.Object, mockedUnitOfWork.Object); | ||
|
||
// Assert | ||
Assert.IsNotNull(service); | ||
} | ||
} | ||
} |