Skip to content

Commit

Permalink
Merge pull request #195 from Brixel/feature/fix-domain-tests
Browse files Browse the repository at this point in the history
test: move command tests to domain tests
  • Loading branch information
vyruz1986 authored Sep 8, 2023
2 parents 5655db2 + a1b3d27 commit efbe865
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 62 deletions.
62 changes: 0 additions & 62 deletions Commands.Test/Transaction/When_editing_a_transaction.cs

This file was deleted.

21 changes: 21 additions & 0 deletions Domain.Test/Domain.Test.csproj
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 Domain.Test/FinancialYear/When_closing_a_financial_year.cs
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();
}
}
29 changes: 29 additions & 0 deletions Domain.Test/Transaction/When_editing_a_transaction.cs
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");
}
}
14 changes: 14 additions & 0 deletions HaSpMan.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain.Test", "Domain.Test\Domain.Test.csproj", "{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -144,6 +146,18 @@ Global
{09963342-F8AA-405E-90C7-1B3F0F66D8DD}.Release|x64.Build.0 = Release|Any CPU
{09963342-F8AA-405E-90C7-1B3F0F66D8DD}.Release|x86.ActiveCfg = Release|Any CPU
{09963342-F8AA-405E-90C7-1B3F0F66D8DD}.Release|x86.Build.0 = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|x64.ActiveCfg = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|x64.Build.0 = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|x86.ActiveCfg = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Debug|x86.Build.0 = Debug|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|Any CPU.Build.0 = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|x64.ActiveCfg = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|x64.Build.0 = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|x86.ActiveCfg = Release|Any CPU
{AFD477E3-A4CB-474C-B2F1-340B8FEBD0C9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit efbe865

Please sign in to comment.