-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(domain): add initial client example
- Loading branch information
Showing
15 changed files
with
215 additions
and
23 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace DistributionCenter.Domain.Bases; | ||
|
||
using DistributionCenter.Domain.Interfaces; | ||
|
||
public abstract class BaseEntity : BaseRegister, IEntity | ||
{ | ||
public Guid Id { get; init; } = Guid.NewGuid(); | ||
public bool IsActive { get; init; } = true; | ||
} |
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,9 @@ | ||
namespace DistributionCenter.Domain.Bases; | ||
|
||
using DistributionCenter.Domain.Interfaces; | ||
|
||
public abstract class BaseRegister : IRegister | ||
{ | ||
public DateTime CreatedAt { get; init; } = DateTime.Now; | ||
public DateTime? UpdatedAt { get; init; } | ||
} |
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,10 @@ | ||
namespace DistributionCenter.Domain.Concretes; | ||
|
||
using DistributionCenter.Domain.Bases; | ||
|
||
public class Client : BaseEntity | ||
{ | ||
public required string Name { get; init; } | ||
public required string LastName { get; init; } | ||
public required string PhoneNumber { get; init; } | ||
} |
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,7 @@ | ||
namespace DistributionCenter.Domain.Interfaces; | ||
|
||
public interface IEntity | ||
{ | ||
Guid Id { get; } | ||
bool IsActive { get; } | ||
} |
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,7 @@ | ||
namespace DistributionCenter.Domain.Interfaces; | ||
|
||
public interface IRegister | ||
{ | ||
DateTime CreatedAt { get; } | ||
DateTime? UpdatedAt { get; } | ||
} |
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
test/DistributionCenter.Domain.Tests/Bases/BaseEntityTests.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,22 @@ | ||
namespace DistributionCenter.Domain.Tests.Bases; | ||
|
||
using DistributionCenter.Domain.Bases; | ||
|
||
public class BaseEntityTests | ||
{ | ||
[Fact] | ||
public void Test_Base_Entity() | ||
{ | ||
// Define Input and output | ||
bool expectedIsActive = true; | ||
Mock<BaseEntity> entityMock = new() { CallBase = true }; | ||
|
||
// Execute actual operation | ||
Guid id = entityMock.Object.Id; | ||
bool isActive = entityMock.Object.IsActive; | ||
|
||
// Verify actual result | ||
Assert.NotEqual(Guid.Empty, id); | ||
Assert.Equal(expectedIsActive, isActive); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test/DistributionCenter.Domain.Tests/Bases/BaseRegisterTests.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,22 @@ | ||
namespace DistributionCenter.Domain.Tests.Bases; | ||
|
||
using DistributionCenter.Domain.Bases; | ||
|
||
public class BaseRegisterTests | ||
{ | ||
[Fact] | ||
public void Test_Base_Register() | ||
{ | ||
// Define Input and output | ||
DateTime? expectedUpdatedAt = null; | ||
Mock<BaseRegister> entityMock = new() { CallBase = true }; | ||
|
||
// Execute actual operation | ||
DateTime createdAt = entityMock.Object.CreatedAt; | ||
DateTime? updatedAt = entityMock.Object.UpdatedAt; | ||
|
||
// Verify actual result | ||
Assert.True(createdAt <= DateTime.Now); | ||
Assert.Equal(expectedUpdatedAt, updatedAt); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test/DistributionCenter.Domain.Tests/Concretes/ClientTests.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,32 @@ | ||
namespace DistributionCenter.Domain.Tests.Concretes; | ||
|
||
using DistributionCenter.Domain.Concretes; | ||
|
||
public class ClientTests | ||
{ | ||
[Fact] | ||
public void Test_Client() | ||
{ | ||
// Define Input and output | ||
string expectedName = "Client Name"; | ||
string expectedLastName = "Client LastName"; | ||
string expectedPhoneNumber = "Client Phone Number"; | ||
Client entity = | ||
new() | ||
{ | ||
Name = expectedName, | ||
LastName = expectedLastName, | ||
PhoneNumber = expectedPhoneNumber, | ||
}; | ||
|
||
// Execute actual operation | ||
string name = entity.Name; | ||
string lastName = entity.LastName; | ||
string phoneNumber = entity.PhoneNumber; | ||
|
||
// Verify actual result | ||
Assert.Equal(expectedName, name); | ||
Assert.Equal(expectedLastName, lastName); | ||
Assert.Equal(expectedPhoneNumber, phoneNumber); | ||
} | ||
} |