Skip to content

Commit

Permalink
refactoring mongoDB (#123)
Browse files Browse the repository at this point in the history
- removal of EntityId implicit conversiont o string
- mongoDB now uses their own model for reading adn storing documents
- removed ModelVersion from Domain Model, as it was a database detail
- remove IsoDateTime completly and use DateTime.UtcNow instead
- rename `namespace server` to `namespace api`
  • Loading branch information
RobinMeow authored Apr 1, 2024
2 parents 6fe0661 + 809ecb0 commit e359346
Show file tree
Hide file tree
Showing 52 changed files with 308 additions and 523 deletions.
2 changes: 1 addition & 1 deletion client/cypress/e2e/recipe/view-recipe.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('create-recipe should', () => {
describe('view-recipe should', () => {
it(`redirect to recipe/{recipeId} recipe is created sucessfully`, () => {
cy.task('db:reset')
cy.createTestUser()
Expand Down
2 changes: 1 addition & 1 deletion server.tests/Auth/CredentialsDtoTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using api.Controllers.Auth;
using System.ComponentModel.DataAnnotations;

namespace server.tests.Auth;
namespace api.tests.Auth;

public sealed class CredentialsDtoTests : DataAnnotationTests
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/Auth/RegisterChefDtoTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using api.Controllers.Auth;
using System.ComponentModel.DataAnnotations;

namespace server.tests.Auth;
namespace api.tests.Auth;

public sealed class RegisterChefDtoTests : DataAnnotationTests
{
Expand Down
5 changes: 4 additions & 1 deletion server.tests/ChefDtoTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using api.Controllers;
using api.Domain;
using System.ComponentModel.DataAnnotations;

namespace server.tests;
namespace api.tests;

public sealed class ChefDtoTests : DataAnnotationTests
{
Expand All @@ -12,6 +13,7 @@ public void fails_all_member_validations(string? name, string? email)
{
var dto = new ChefDto()
{
Id = EntityId.New().ToString(),
Name = name!,
Email = email
};
Expand All @@ -28,6 +30,7 @@ public void successfully_validates_all_members(string name, string? email)
{
var dto = new ChefDto()
{
Id = EntityId.New().ToString(),
Name = name,
Email = email
};
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/Constructor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class Constructor : _testData
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/IsDisallowedId.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class IsDisallowedId
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/IsSatisfiedByTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class IsSatisfiedByTests : _testData
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/IsValidGuidFormat.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class IsValidGuidFormat : _testData
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/New.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class New
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/ToString.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public sealed class ToString
{
Expand Down
2 changes: 1 addition & 1 deletion server.tests/EntityId/_testData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using api.Domain;

namespace server.tests.EntityId_specs;
namespace api.tests.EntityId_specs;

public abstract class _testData
{
Expand Down
17 changes: 0 additions & 17 deletions server.tests/EntityId/implicit_string_conversion.cs

This file was deleted.

28 changes: 28 additions & 0 deletions server.tests/EntityId/string_conversion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using api.Domain;

namespace api.tests.EntityId_specs;

public sealed class string_conversion
{
[Fact]
public void returns_currect_id_string()
{
string validId = "12345678-1234-1234-1234-123456789abc";
EntityId entityId = new EntityId(validId);

string actual = entityId.ToString();

Equal(validId, actual);
}

[Fact]
public void is_case_sensitive()
{
string validId = "12345678-1234-1234-1234-123456789abc";
EntityId entityId = new EntityId(validId);

string actual = entityId.ToString();

NotEqual(validId.ToUpper(), actual);
}
}
2 changes: 1 addition & 1 deletion server.tests/Infrastructure/AspPasswordHasherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using api.Infrastructure;
using Microsoft.AspNetCore.Identity;

namespace server.tests.Infrastructure;
namespace api.tests.Infrastructure;

public sealed class AspPasswordHasherTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using api.Infrastructure.Auth;
using Microsoft.IdentityModel.Tokens;

namespace server.tests.Infrastructure;
namespace api.tests.Infrastructure;

public sealed class IssuerSigningKeyFactoryTests
{
Expand Down
8 changes: 6 additions & 2 deletions server.tests/Infrastructure/JwtFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
using api.Infrastructure.Auth;
using System.Security.Claims;

namespace server.tests.Infrastructure;
namespace api.tests.Infrastructure;

public sealed class JwtFactoryTests
{
readonly static Chef _chef = new()
{
Id = EntityId.New(),
Name = "Chefname",
};

Expand Down Expand Up @@ -60,7 +61,10 @@ public void creation_throws_with_key_which_as_less_than_512_bits(string invalidK
public void throws_when_chefname_is_missing()
{
// Arrange
var namelessChef = new Chef();
var namelessChef = new Chef()
{
Id = EntityId.New(),
};

// Act & Assert
ThrowsAny<Exception>(() => new Claim(ClaimTypes.Name, namelessChef.Name));
Expand Down
117 changes: 0 additions & 117 deletions server.tests/IsoDateTime/Constructor.cs

This file was deleted.

21 changes: 0 additions & 21 deletions server.tests/IsoDateTime/Now.cs

This file was deleted.

21 changes: 0 additions & 21 deletions server.tests/IsoDateTime/ToString.cs

This file was deleted.

2 changes: 1 addition & 1 deletion server.tests/Recipes/NewRecipeDtoTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using api.Controllers.Recipes;
using System.ComponentModel.DataAnnotations;

namespace server.tests.Recipes;
namespace api.tests.Recipes;

public sealed class NewRecipeDtoTests : DataAnnotationTests
{
Expand Down
Loading

0 comments on commit e359346

Please sign in to comment.