-
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.
Merge pull request #195 from Brixel/feature/fix-domain-tests
test: move command tests to domain tests
- Loading branch information
Showing
5 changed files
with
83 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.11.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Domain\Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
19 changes: 19 additions & 0 deletions
19
Domain.Test/FinancialYear/When_closing_a_financial_year.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,19 @@ | ||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
namespace Domain.Test.FinancialYear; | ||
|
||
public class When_closing_a_financial_year | ||
{ | ||
[Fact] | ||
public void It_should_mark_the_year_as_closed() | ||
{ | ||
var startDate = DateTimeOffset.Now; | ||
var financialYear = new Domain.FinancialYear(startDate, startDate.AddYears(1).AddDays(-1), new List<Domain.Transaction>()); | ||
|
||
; financialYear.Close(); | ||
|
||
financialYear.IsClosed.Should().BeTrue(); | ||
} | ||
} |
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,29 @@ | ||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
namespace Domain.Test.Transaction; | ||
public class When_editing_a_transaction | ||
{ | ||
|
||
[Fact] | ||
public void It_should_throw_an_exception_when_locked() | ||
{ | ||
var bankAccountId = Guid.NewGuid(); | ||
|
||
var transaction = new CreditTransaction("Random counter party", bankAccountId, 20m, DateTimeOffset.Now, | ||
"A description", new List<TransactionAttachment>(), null, new List<TransactionTypeAmount>()); | ||
var financialYear = new Domain.FinancialYear(new DateTimeOffset(new DateTime(2022,9,1)), new DateTimeOffset(new DateTime(2023,8,31)), new List<Domain.Transaction>() | ||
{ | ||
transaction | ||
}); | ||
financialYear.Close(); | ||
|
||
var exception = Assert.Throws<InvalidOperationException>(() => financialYear.ChangeTransaction(transaction.Id, | ||
"Changed counter party name", transaction.MemberId, | ||
transaction.BankAccountId, transaction.ReceivedDateTime, transaction.TransactionTypeAmounts, | ||
transaction.Description)); | ||
|
||
exception.Message.Should().Be("Financial year is already closed"); | ||
} | ||
} |
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