-
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.
# Description This PR includes the following proposed change(s): - Add update permit licence function in LicenceRepo - Add unit test and integration test
- Loading branch information
1 parent
e146e94
commit e28ecc6
Showing
8 changed files
with
111 additions
and
9 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
43 changes: 43 additions & 0 deletions
43
src/Spd.Resource.Repository.IntegrationTest/LicenceRepositoryTest.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,43 @@ | ||
using Microsoft.Dynamics.CRM; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Spd.Resource.Repository.Licence; | ||
using Spd.Utilities.Dynamics; | ||
|
||
namespace Spd.Resource.Repository.IntegrationTest; | ||
|
||
public class LicenceRepositoryTest : IClassFixture<IntegrationTestSetup> | ||
{ | ||
private readonly ILicenceRepository _licRepo; | ||
private DynamicsContext _context; | ||
|
||
public LicenceRepositoryTest(IntegrationTestSetup testSetup) | ||
{ | ||
_licRepo = testSetup.ServiceProvider.GetRequiredService<ILicenceRepository>(); | ||
_context = testSetup.ServiceProvider.GetRequiredService<IDynamicsContextFactory>().CreateChangeOverwrite(); | ||
} | ||
|
||
[Fact] | ||
public async Task ManageAsync_UpdateLicence_Correctly() | ||
{ | ||
//Arrange | ||
spd_licence lic = new(); | ||
lic.spd_licenceid = Guid.NewGuid(); | ||
lic.spd_employercontactname = IntegrationTestSetup.DataPrefix + "employername"; | ||
lic.spd_employeremail = "test@test.com"; | ||
_context.AddTospd_licences(lic); | ||
await _context.SaveChangesAsync(CancellationToken.None); | ||
PermitLicence pl = new() | ||
{ | ||
EmployerName = "newEmployerName", | ||
SupervisorPhoneNumber = "222222222" | ||
}; | ||
UpdateLicenceCmd cmd = new(pl, (Guid)lic.spd_licenceid); | ||
|
||
//Action | ||
var response = await _licRepo.ManageAsync(cmd, CancellationToken.None); | ||
|
||
//Assert | ||
Assert.NotNull(response); | ||
Assert.Equal("newEmployerName", response.EmployerName); | ||
} | ||
} |
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