Skip to content

Commit

Permalink
Fix: Moved name to BaseFinancial because it's used in all models, Exp…
Browse files Browse the repository at this point in the history
…ense, ExpenseItem and Income.
  • Loading branch information
Felipe Soares committed Jan 20, 2024
1 parent ab9a40b commit 41ff9b2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
6 changes: 6 additions & 0 deletions EasyFinance.Common.Tests/Financial/BaseFinancialBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ protected BaseFinancialBuilder(TEntity baseFinancial)
this.entity = baseFinancial;
}

public BaseFinancialBuilder<TEntity> AddName(string name)
{
this.entity.Name = name;
return this;
}

public BaseFinancialBuilder<TEntity> AddDate(DateTime date)
{
this.entity.Date = date;
Expand Down
6 changes: 0 additions & 6 deletions EasyFinance.Common.Tests/Financial/ExpenseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ public ExpenseBuilder() : base(new Expense())
{
}

public ExpenseBuilder AddName(string name)
{
this.entity.Name = name;
return this;
}

public ExpenseBuilder AddGoal(decimal goal)
{
this.entity.Goal = goal;
Expand Down
11 changes: 11 additions & 0 deletions EasyFinance.Common.Tests/Financial/ExpenseItemBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using EasyFinance.Domain.Models.Financial;

namespace EasyFinance.Common.Tests.Financial
{
public class ExpenseItemBuilder : BaseExpenseBuilder<ExpenseItem>
{
public ExpenseItemBuilder() : base(new ExpenseItem())
{
}
}
}
6 changes: 0 additions & 6 deletions EasyFinance.Common.Tests/Financial/IncomeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@ public class IncomeBuilder : BaseFinancialBuilder<Income>
public IncomeBuilder() : base(new Income())
{
}

public IncomeBuilder AddTitle(string title)
{
this.entity.Title = title;
return this;
}
}
}
19 changes: 16 additions & 3 deletions EasyFinance.Domain.Tests/FinancialProject/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ public class ProjectTests
public void CreateAProjectAndValidateProperties()
{
var income = new IncomeBuilder()
.AddTitle("Income Name")
.AddAmount(200)
.AddName("Income Name")
.Build();

var expenseItem = new ExpenseItemBuilder()
.AddAmount(20)
.AddName("Expense Item Name")
.Build();

var expense = new ExpenseBuilder()
.AddName("Expense Name")
.AddGoal(50)
.AddItems(new List<ExpenseItem> { expenseItem })
.AddAmount(20)
.AddName("Expense Name")
.Build();

var category = new CategoryBuilder()
Expand All @@ -39,8 +47,13 @@ public void CreateAProjectAndValidateProperties()
project.Categories.First().Expenses.First().Should().NotBeNull();
project.Categories.First().Expenses.First().Name.Should().Be("Expense Name");
project.Categories.First().Expenses.First().Goal.Should().Be(50);
project.Categories.First().Expenses.First().Amount.Should().Be(20);
project.Categories.First().Expenses.First().Items.First().Should().NotBeNull();
project.Categories.First().Expenses.First().Items.First().Name.Should().Be("Expense Item Name");
project.Categories.First().Expenses.First().Items.First().Amount.Should().Be(20);
project.Incomes.First().Should().NotBeNull();
project.Incomes.First().Title.Should().Be("Income Name");
project.Incomes.First().Name.Should().Be("Income Name");
project.Incomes.First().Amount.Should().Be(200);
}
}
}
1 change: 1 addition & 0 deletions EasyFinance.Domain/Financial/BaseFinancial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace EasyFinance.Domain.Models.Financial
{
public abstract class BaseFinancial : BaseEntity
{
public string Name { get; set; } = string.Empty;
public DateTime Date { get; set; }
public decimal Amount { get; set; }
public User CreatedBy { get; set; } = new User();
Expand Down
1 change: 0 additions & 1 deletion EasyFinance.Domain/Financial/Expense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
public class Expense : BaseExpense
{
public string Name { get; set; } = string.Empty;
public decimal Goal { get; set; }
}
}
1 change: 0 additions & 1 deletion EasyFinance.Domain/Financial/Income.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
{
public class Income : BaseFinancial
{
public string Title { get; set; } = string.Empty;
}
}

0 comments on commit 41ff9b2

Please sign in to comment.