This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6571de
commit 2b1e3cb
Showing
5 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
...ayrollProcessor.Core.Domain.Tests/Features/Employees/EmployeePayrollCreateCommandTests.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,29 @@ | ||
using System; | ||
using AutoFixture.Idioms; | ||
using FluentAssertions; | ||
using PayrollProcessor.Core.Domain.Features.Employees; | ||
using PayrollProcessor.Tests.Fixtures; | ||
using Xunit; | ||
|
||
namespace PayrollProcessor.Core.Domain.Tests.Features.Employees; | ||
|
||
public class EmployeePayrollCreateCommandTests | ||
{ | ||
[Fact] | ||
public void Constructor_Guards_Against_Invalid_Parameters() | ||
{ | ||
var assertion = new GuardClauseAssertion(new DomainFixture()); | ||
|
||
assertion.Verify(typeof(EmployeePayrollCreateCommand).GetConstructors()); | ||
} | ||
|
||
[Theory, AutoDomainData] | ||
public void ConstructorAssignsPropertiesFromParameters(Guid newPayrollId, Employee employee, EmployeePayrollNew employeePayroll) | ||
{ | ||
var sut = new EmployeePayrollCreateCommand(employee, newPayrollId, employeePayroll); | ||
|
||
sut.Employee.Should().Be(employee); | ||
sut.NewPayrollId.Should().Be(newPayrollId); | ||
sut.NewPayroll.Should().Be(employeePayroll); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
api/PayrollProcessor.Data.Persistence.Tests/Features/Employees/EmployeeRecordMapTests.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,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using AutoFixture; | ||
using FluentAssertions; | ||
using PayrollProcessor.Data.Persistence.Features.Employees; | ||
using Xunit; | ||
|
||
namespace PayrollProcessor.Data.Persistence.Tests.Features.Employees; | ||
|
||
public class EmployeeRecordMapTests | ||
{ | ||
private readonly EmployeeRecord employeeRecord; | ||
private readonly IEnumerable<EmployeePayrollRecord> employeePayrolls; | ||
|
||
public EmployeeRecordMapTests() | ||
{ | ||
var fixture = new Fixture(); | ||
|
||
employeeRecord = fixture.Create<EmployeeRecord>(); | ||
|
||
employeePayrolls = fixture | ||
.Build<EmployeePayrollRecord>() | ||
.With(epr => epr.PartitionKey, employeeRecord.Id.ToString()) | ||
.With(epr => epr.PartitionKey, Guid.NewGuid().ToString()) | ||
.CreateMany(); | ||
} | ||
|
||
[Fact] | ||
public void ToEmployeeMapsValues() | ||
{ | ||
var employee = EmployeeRecord.Map.ToEmployee(employeeRecord); | ||
|
||
employee.Id.Should().Be(employeeRecord.Id); | ||
employee.Department.Should().Be(employeeRecord.Department); | ||
employee.Email.Should().Be(employeeRecord.Email); | ||
employee.EmploymentStartedOn.Should().Be(employeeRecord.EmploymentStartedOn); | ||
employee.FirstName.Should().Be(employeeRecord.FirstName); | ||
employee.LastName.Should().Be(employeeRecord.LastName); | ||
employee.Phone.Should().Be(employeeRecord.Phone); | ||
employee.Status.Should().Be(employeeRecord.Status); | ||
employee.Title.Should().Be(employeeRecord.Title); | ||
} | ||
|
||
[Fact] | ||
public void ToEmployeeDetailsMapsValues() | ||
{ | ||
var employee = EmployeeRecord.Map.ToEmployeeDetails(employeeRecord, employeePayrolls); | ||
|
||
employee.Id.Should().Be(employeeRecord.Id); | ||
employee.Department.Should().Be(employeeRecord.Department); | ||
employee.Email.Should().Be(employeeRecord.Email); | ||
employee.EmploymentStartedOn.Should().Be(employeeRecord.EmploymentStartedOn); | ||
employee.FirstName.Should().Be(employeeRecord.FirstName); | ||
employee.LastName.Should().Be(employeeRecord.LastName); | ||
employee.Phone.Should().Be(employeeRecord.Phone); | ||
employee.Status.Should().Be(employeeRecord.Status); | ||
employee.Title.Should().Be(employeeRecord.Title); | ||
|
||
employee.Payrolls.Should().HaveCount(employeePayrolls.Count()); | ||
|
||
var employeePayroll = employee.Payrolls.First(); | ||
employeePayroll.Id.Should().Be(employeePayrolls.First().Id); | ||
employeePayroll.CheckDate.Should().Be(employeePayrolls.First().CheckDate); | ||
employeePayroll.EmployeeId.Should().Be(Guid.Parse(employeePayrolls.First().PartitionKey)); | ||
employeePayroll.GrossPayroll.Should().Be(employeePayrolls.First().GrossPayroll); | ||
employeePayroll.PayrollPeriod.Should().Be(employeePayrolls.First().PayrollPeriod); | ||
} | ||
} |
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
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