-
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.
Adicionado novos itens reutilizáveis na camada de domínio
- Loading branch information
1 parent
742d110
commit 74b7331
Showing
7 changed files
with
70 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace FoSouzaDev.Common.Domain.Entities; | ||
|
||
public abstract class Entity(Guid id, DateTimeOffset creationDateTime) | ||
{ | ||
public Guid Id { get; private init; } = id; | ||
public DateTimeOffset CreationDateTime { get; private init; } = creationDateTime; | ||
} |
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,8 @@ | ||
using FoSouzaDev.Common.Domain.Entities; | ||
|
||
namespace FoSouzaDev.Common.Domain.Repositories; | ||
|
||
public interface IAddRepository<T> where T : Entity | ||
{ | ||
Task AddAsync(T entity); | ||
} |
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 @@ | ||
using FoSouzaDev.Common.Domain.Entities; | ||
|
||
namespace FoSouzaDev.Common.Domain.Repositories; | ||
|
||
public interface IGetRepository<T> where T : Entity | ||
{ | ||
Task<T> GetByIdAsync(Guid id); | ||
Task<T> GetByIdOrThrowAsync(Guid id); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/FoSouzaDev.Common.Domain/Repositories/IRemoveRepository.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,8 @@ | ||
using FoSouzaDev.Common.Domain.Entities; | ||
|
||
namespace FoSouzaDev.Common.Domain.Repositories; | ||
|
||
public interface IRemoveRepository<T> where T : Entity | ||
{ | ||
Task RemoveAsync(Guid id); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/FoSouzaDev.Common.Domain/Repositories/IUpdateRepository.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,8 @@ | ||
using FoSouzaDev.Common.Domain.Entities; | ||
|
||
namespace FoSouzaDev.Common.Domain.Repositories; | ||
|
||
public interface IUpdateRepository<T> where T : Entity | ||
{ | ||
Task UpdateAsync(T entity); | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/FoSouzaDev.Common.Domain.UnitaryTests/Entities/EntityTest.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,28 @@ | ||
using AutoFixture; | ||
using FluentAssertions; | ||
using FoSouzaDev.Common.Domain.Entities; | ||
|
||
namespace FoSouzaDev.Common.Domain.UnitaryTests.Entities; | ||
|
||
public sealed class EntityTest : BaseTest | ||
{ | ||
private class DummyEntity(Guid id, DateTimeOffset creationDateTime) | ||
: Entity(id, creationDateTime) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void Constructor_Success_CreateAnEntity() | ||
{ | ||
// Arrange | ||
Guid expectedId = Guid.NewGuid(); | ||
DateTimeOffset expectedCreationDateTime = base.Fixture.Create<DateTimeOffset>(); | ||
|
||
// Act | ||
DummyEntity entity = new(expectedId, expectedCreationDateTime); | ||
|
||
// Assert | ||
entity.Id.Should().Be(expectedId); | ||
entity.CreationDateTime.Should().Be(expectedCreationDateTime); | ||
} | ||
} |