-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e788eb7
commit f43a1ad
Showing
6 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
VirtualMind.Application.Tests/Commands/CreateOperationCommandTests.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,51 @@ | ||
using System.Linq; | ||
using VirtualMind.Application.Commands; | ||
using Xunit; | ||
|
||
namespace VirtualMind.Application.Tests.Commands | ||
{ | ||
public class CreateOperationCommandTests | ||
{ | ||
[Fact(DisplayName = "Add new VALID Operation Command")] | ||
[Trait("Category", "Commands")] | ||
public void CreateOperation_IsValid_ShouldPass() | ||
{ | ||
//Arrange | ||
var command = new CreateOperationCommand() | ||
{ | ||
CurrencyType = "USD", | ||
RequestedAmount = 100, | ||
UserId = 1 | ||
}; | ||
|
||
//Act | ||
var validation = new CreateOperationCommandValidator().Validate(command).IsValid; | ||
|
||
//Assert | ||
Assert.True(validation); | ||
} | ||
|
||
[Fact(DisplayName = "Add new INVALID Operation Command")] | ||
[Trait("Category", "Commands")] | ||
public void CreateOperation_IsNotValid_ShouldNotPass() | ||
{ | ||
//Arrange | ||
var command = new CreateOperationCommand() | ||
{ | ||
CurrencyType = "", | ||
RequestedAmount = 0, | ||
UserId = 0 | ||
}; | ||
|
||
//Act | ||
var validation = new CreateOperationCommandValidator().Validate(command); | ||
|
||
//Assert | ||
Assert.False(validation.IsValid); | ||
Assert.Contains("[UserId] must be greater Than 0", validation.Errors.Select(c => c.ErrorMessage)); | ||
Assert.Contains("[RequestedAmount] must be greater Than 0", validation.Errors.Select(c => c.ErrorMessage)); | ||
Assert.Contains("[CurrencyType] can't be empty", validation.Errors.Select(c => c.ErrorMessage)); | ||
Assert.Contains("Invalid [CurrencyType]", validation.Errors.Select(c => c.ErrorMessage)); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
VirtualMind.Application.Tests/Queries/GetCurrencyExchangeQueryTests.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,53 @@ | ||
using System.Linq; | ||
using VirtualMind.Application.Queries; | ||
using Xunit; | ||
|
||
namespace VirtualMind.Application.Tests.Queries | ||
{ | ||
public class GetCurrencyExchangeQueryTests | ||
{ | ||
[Fact(DisplayName = "Execute VALID Query")] | ||
[Trait("Category", "Queries")] | ||
public void GetExchange_IsValid_ShouldPass() | ||
{ | ||
//Arrange | ||
var query = new GetCurrencyExchangeQuery() | ||
{ | ||
CurrencyType = "USD" | ||
}; | ||
|
||
//Act | ||
var validation = new GetCurrencyExchangeValidator().Validate(query); | ||
|
||
//Assert | ||
Assert.True(validation.IsValid); | ||
} | ||
|
||
[Fact(DisplayName = "Execute INVALID Query")] | ||
[Trait("Category", "Queries")] | ||
public void GetExchange_IsNotValid_ShouldNotPass() | ||
{ | ||
//Arrange | ||
var query = new GetCurrencyExchangeQuery() | ||
{ | ||
CurrencyType = null | ||
}; | ||
|
||
var emptyQuery = new GetCurrencyExchangeQuery() | ||
{ | ||
CurrencyType = "" | ||
}; | ||
|
||
//Act | ||
var validation = new GetCurrencyExchangeValidator().Validate(query); | ||
var secondValidation = new GetCurrencyExchangeValidator().Validate(emptyQuery); | ||
|
||
//Assert | ||
Assert.False(validation.IsValid); | ||
|
||
Assert.Contains("[CurrencyType] can't be null!", validation.Errors.Select(c => c.ErrorMessage)); | ||
Assert.Contains("[CurrencyType] field is required!", validation.Errors.Select(c => c.ErrorMessage)); | ||
Assert.Contains("Invalid [CurrencyType]!", secondValidation.Errors.Select(c => c.ErrorMessage)); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
VirtualMind.Application.Tests/VirtualMind.Application.Tests.csproj
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,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> | ||
<PackageReference Include="MOQ" Version="4.16.0" /> | ||
<PackageReference Include="MOQ.automock" Version="2.3.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.3.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\VirtualMind.Application\VirtualMind.Application.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
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
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