Skip to content

Commit

Permalink
Update Contributor PhoneNumber nullability for consistency (ardalis#686)
Browse files Browse the repository at this point in the history
* Adjust PhoneNumber nullability throughout layers

* remove wwwroot from csproj

* add LINQ expression back in for in memory provider
  • Loading branch information
KyleMcMaster authored Feb 29, 2024
1 parent 059bf9c commit dfc4b02
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public async Task<IEnumerable<ContributorDTO>> ListAsync()
{
// NOTE: This will fail if testing with EF InMemory provider
var result = await _db.Database.SqlQuery<ContributorDTO>(
$"SELECT Id, Name, COALESCE(PhoneNumber_Number, '') AS PhoneNumber FROM Contributors") // don't fetch other big columns
//.Select(c => new ContributorDTO(c.Id, c.Name, c.PhoneNumber?.Number ?? ""))
$"SELECT Id, Name, PhoneNumber_Number AS PhoneNumber FROM Contributors") // don't fetch other big columns
//.Select(c => new ContributorDTO(c.Id, c.Name, c.PhoneNumber?.Number))
.ToListAsync();

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
namespace Clean.Architecture.UseCases.Contributors;
public record ContributorDTO(int Id, string Name, string PhoneNumber);
public record ContributorDTO(int Id, string Name, string? PhoneNumber);
4 changes: 0 additions & 4 deletions src/Clean.Architecture.Web/Clean.Architecture.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@
<ProjectReference Include="..\Clean.Architecture.UseCases\Clean.Architecture.UseCases.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Clean.Architecture.Web.ContributorEndpoints;

public record ContributorRecord(int Id, string Name, string PhoneNumber);
public record ContributorRecord(int Id, string Name, string? PhoneNumber);
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class CreateContributorHandlerHandle
{
private readonly string _testName = "test name";
private readonly IRepository<Contributor> _repository = Substitute.For<IRepository<Contributor>>();
private CreateContributorHandler _handler;
private readonly CreateContributorHandler _handler;

public CreateContributorHandlerHandle()
{
_handler = new CreateContributorHandler(_repository);
_handler = new CreateContributorHandler(_repository);
}

private Contributor CreateContributor()
Expand All @@ -30,6 +30,6 @@ public async Task ReturnsSuccessGivenValidName()
.Returns(Task.FromResult(CreateContributor()));
var result = await _handler.Handle(new CreateContributorCommand(_testName, null), CancellationToken.None);

result.IsSuccess.Should().BeTrue();
result.IsSuccess.Should().BeTrue();
}
}

0 comments on commit dfc4b02

Please sign in to comment.