Skip to content

Commit

Permalink
Increase covered use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ghanam committed Oct 9, 2024
1 parent 88b03e0 commit 2891cc7
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PersonRepositoryTests : IDisposable
private readonly ProfileDbContext _context;
private readonly PersonRepository _registerRepository;
private readonly List<Person> _personContactAndReservationTestData;

public PersonRepositoryTests()
{
var options = new DbContextOptionsBuilder<ProfileDbContext>()
Expand All @@ -32,7 +32,7 @@ public PersonRepositoryTests()
_context = new ProfileDbContext(options);
_registerRepository = new PersonRepository(_context);

_personContactAndReservationTestData = [.. PersonTestData.GetContactAndReservationTestData()];
_personContactAndReservationTestData = new List<Person>(PersonTestData.GetContactAndReservationTestData());

_context.People.AddRange(_personContactAndReservationTestData);
_context.SaveChanges();
Expand Down Expand Up @@ -81,12 +81,23 @@ public async Task GetUserContactInfoAsync_ReturnsEmpty_WhenNoneFound()
Assert.Empty(result);
}

[Fact]
public async Task GetUserContactInfoAsync_ReturnsEmpty_WhenNotFound()
{
// Act
var result = await _registerRepository.GetContactDetailsAsync(["nonexistent", "11044314120"]);

// Assert
Assert.Empty(result);
}

[Fact]
public async Task GetUserContactInfoAsync_ReturnsMultipleContacts_WhenFound()
{
// Act
var result = await _registerRepository.GetContactDetailsAsync(["24064316776", "11044314101"]);
var expected = _personContactAndReservationTestData.Where(e => e.FnumberAk == "24064316776" || e.FnumberAk == "11044314101");
var expected = _personContactAndReservationTestData
.Where(e => e.FnumberAk == "24064316776" || e.FnumberAk == "11044314101");

// Assert
Assert.Equal(2, result.Count);
Expand All @@ -100,10 +111,10 @@ public async Task GetUserContactInfoAsync_ReturnsMultipleContacts_WhenFound()
}

[Fact]
public async Task GetUserContactInfoAsync_ReturnsEmpty_WhenNotFound()
public async Task GetUserContactInfoAsync_ReturnsEmpty_WhenNoNationalIdentityNumbersProvided()
{
// Act
var result = await _registerRepository.GetContactDetailsAsync(["nonexistent", "11044314120"]);
var result = await _registerRepository.GetContactDetailsAsync([]);

// Assert
Assert.Empty(result);
Expand Down

0 comments on commit 2891cc7

Please sign in to comment.