Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.preferCSharpExtension": true
}
57 changes: 28 additions & 29 deletions RefactorThis.Domain.Tests/InvoicePaymentProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public void ProcessPayment_Should_ThrowException_When_NoInoiceFoundForPaymentRef
{
var repo = new InvoiceRepository( );

Invoice invoice = null;
var paymentProcessor = new InvoiceService( repo );

var payment = new Payment( );
Expand All @@ -28,7 +27,7 @@ public void ProcessPayment_Should_ThrowException_When_NoInoiceFoundForPaymentRef
failureMessage = e.Message;
}

Assert.AreEqual( "There is no invoice matching this payment", failureMessage );
Assert.That(failureMessage, Is.EqualTo("There is no invoice matching this payment"));
}

[Test]
Expand All @@ -51,7 +50,7 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_NoPaymentNeeded( )

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "no payment needed", result );
Assert.That("no payment needed", Is.EqualTo(result));
}

[Test]
Expand All @@ -63,13 +62,13 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_InvoiceAlreadyFullyP
{
Amount = 10,
AmountPaid = 10,
Payments = new List<Payment>
{
new Payment
Payments =
[
new Payment
{
Amount = 10
}
}
]
};
repo.Add( invoice );

Expand All @@ -79,7 +78,7 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_InvoiceAlreadyFullyP

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "invoice was already fully paid", result );
Assert.That( "invoice was already fully paid", Is.EqualTo(result) );
}

[Test]
Expand All @@ -90,13 +89,13 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_PartialPaymentExists
{
Amount = 10,
AmountPaid = 5,
Payments = new List<Payment>
{
new Payment
Payments =
[
new Payment
{
Amount = 5
}
}
]
};
repo.Add( invoice );

Expand All @@ -109,7 +108,7 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_PartialPaymentExists

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "the payment is greater than the partial amount remaining", result );
Assert.That( "the payment is greater than the partial amount remaining", Is.EqualTo(result) );
}

[Test]
Expand All @@ -120,7 +119,7 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_NoPartialPaymentExis
{
Amount = 5,
AmountPaid = 0,
Payments = new List<Payment>( )
Payments = []
};
repo.Add( invoice );

Expand All @@ -133,7 +132,7 @@ public void ProcessPayment_Should_ReturnFailureMessage_When_NoPartialPaymentExis

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "the payment is greater than the invoice amount", result );
Assert.That( "the payment is greater than the invoice amount", Is.EqualTo(result) );
}

[Test]
Expand All @@ -144,13 +143,13 @@ public void ProcessPayment_Should_ReturnFullyPaidMessage_When_PartialPaymentExis
{
Amount = 10,
AmountPaid = 5,
Payments = new List<Payment>
{
new Payment
Payments =
[
new Payment
{
Amount = 5
}
}
]
};
repo.Add( invoice );

Expand All @@ -163,7 +162,7 @@ public void ProcessPayment_Should_ReturnFullyPaidMessage_When_PartialPaymentExis

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "final partial payment received, invoice is now fully paid", result );
Assert.That( "final partial payment received, invoice is now fully paid", Is.EqualTo(result) );
}

[Test]
Expand All @@ -173,8 +172,8 @@ public void ProcessPayment_Should_ReturnFullyPaidMessage_When_NoPartialPaymentEx
var invoice = new Invoice( repo )
{
Amount = 10,
AmountPaid = 0,
Payments = new List<Payment>( ) { new Payment( ) { Amount = 10 } }
AmountPaid = 10,
Payments = [new Payment( ) { Amount = 10 }]
};
repo.Add( invoice );

Expand All @@ -187,7 +186,7 @@ public void ProcessPayment_Should_ReturnFullyPaidMessage_When_NoPartialPaymentEx

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "invoice was already fully paid", result );
Assert.That( "invoice was already fully paid", Is.EqualTo(result) );
}

[Test]
Expand All @@ -198,13 +197,13 @@ public void ProcessPayment_Should_ReturnPartiallyPaidMessage_When_PartialPayment
{
Amount = 10,
AmountPaid = 5,
Payments = new List<Payment>
{
new Payment
Payments =
[
new Payment
{
Amount = 5
}
}
]
};
repo.Add( invoice );

Expand All @@ -217,7 +216,7 @@ public void ProcessPayment_Should_ReturnPartiallyPaidMessage_When_PartialPayment

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "another partial payment received, still not fully paid", result );
Assert.That( "another partial payment received, still not fully paid", Is.EqualTo(result) );
}

[Test]
Expand All @@ -241,7 +240,7 @@ public void ProcessPayment_Should_ReturnPartiallyPaidMessage_When_NoPartialPayme

var result = paymentProcessor.ProcessPayment( payment );

Assert.AreEqual( "invoice is now partially paid", result );
Assert.That( "invoice is now partially paid", Is.EqualTo(result) );
}
}
}
90 changes: 25 additions & 65 deletions RefactorThis.Domain.Tests/RefactorThis.Domain.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,67 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7971BDEC-EAD1-4FB8-A4F5-B1F67E4F6355}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RefactorThis.Domain.Tests</RootNamespace>
<AssemblyName>RefactorThis.Domain.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InvoicePaymentProcessorTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RefactorThis.Domain\RefactorThis.Domain.csproj">
<Project>{5310b2fe-e26d-414e-b656-1f74c5a70368}</Project>
<Name>RefactorThis.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\RefactorThis.Persistence\RefactorThis.Persistence.csproj">
<Project>{33cdc796-ff75-449c-9637-59c2efc46361}</Project>
<Name>RefactorThis.Persistence</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- pick the same TFM you use in the code being tested -->
<TargetFramework>net9.0</TargetFramework>

<!-- if this is an xUnit project, tell the SDK to generate a test host -->
<IsPackable>false</IsPackable>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<!-- whichever test runner you use -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.6.0-preview.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.6.0-preview.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RefactorThis.Domain\RefactorThis.Domain.csproj" />
<ProjectReference Include="..\RefactorThis.Persistence\RefactorThis.Persistence.csproj" />
</ItemGroup>

</Project>
Loading