Skip to content

Commit

Permalink
Create RegisterNotExistsException. Adjust ProductServiceTest structur…
Browse files Browse the repository at this point in the history
…e. Create delete product tests
  • Loading branch information
José Clodoalves da Silva Júnior committed Feb 16, 2023
1 parent 59a6705 commit cf255dd
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFSample.Service.Exceptions.Product
{
public class RegisterNotExistsException : BusinessException
{
public RegisterNotExistsException(string message) : base(message)
{
}
}
}
3 changes: 3 additions & 0 deletions WPFSample/WPFSample.Service/Implementation/ProductService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public void DeleteProduct(int id)
{
Product product = _productRepository.GetById(id);

if (product == null)
throw new RegisterNotExistsException("Register non-existing");

_productRepository.Delete(product);
}

Expand Down
1 change: 1 addition & 0 deletions WPFSample/WPFSample.Service/WPFSample.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Compile Include="Exceptions\DatabaseException.cs" />
<Compile Include="Exceptions\Product\FieldExceedCharacterLimitException.cs" />
<Compile Include="Exceptions\Product\NumericFieldLessThanZeroException.cs" />
<Compile Include="Exceptions\Product\RegisterNotExistsException.cs" />
<Compile Include="Exceptions\Product\RequiredFieldException.cs" />
<Compile Include="Implementation\ProductService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Loading

0 comments on commit cf255dd

Please sign in to comment.