-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
310 additions
and
43 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,38 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
env: | ||
DOTNET_VERSION: '8.x' # Global environment variables | ||
|
||
jobs: | ||
build: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: GitHub metadata | ||
run: | | ||
printf "%s on %s by %s\n" "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" "$GITHUB_ACTOR" | ||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build -c Release | ||
|
||
- name: Run Tests | ||
run: dotnet test -c Release --no-build --verbosity normal |
This file was deleted.
Oops, something went wrong.
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
187 changes: 187 additions & 0 deletions
187
test/oed-authz.UnitTests/Services/ProxyManagementServiceTests.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,187 @@ | ||
using FakeItEasy; | ||
using Microsoft.Extensions.Logging; | ||
using oed_authz.Interfaces; | ||
using oed_authz.Models; | ||
using oed_authz.Services; | ||
using oed_authz.UnitTests.TestUtils; | ||
|
||
namespace oed_authz.UnitTests.Services | ||
{ | ||
public class ProxyManagementServiceTests | ||
{ | ||
private readonly IRoleAssignmentsRepository _fakeRoleAssignmentRepository = A.Fake<IRoleAssignmentsRepository>(); | ||
private readonly ILogger<ProxyManagementService> _fakeLogger = A.Fake<ILogger<ProxyManagementService>>(); | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_AllHeirsHaveFormuesfullmaktRole_ShouldNot_AddOrRemoveRoles() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.FormuesfulmaktRole("12345678901"), | ||
factory.FormuesfulmaktRole("12345678902"), | ||
factory.FormuesfulmaktRole("12345678903"), | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_AllHeirsHaveProbateRole_ShouldNot_AddOrRemoveRoles() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.ProbateRole("12345678901"), | ||
factory.ProbateRole("12345678902"), | ||
factory.ProbateRole("12345678903"), | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_AllHeirsHaveProbateOrFormuesfullmaktRoles_ShouldNot_AddOrRemoveRoles() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.ProbateRole("12345678901"), | ||
factory.ProbateRole("12345678902"), | ||
factory.FormuesfulmaktRole("12345678903"), | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_AllHeirsHaveProbateRole_And_OneHeirHasAppointedAnotherHeirAsIndividualProxy_ShouldNot_AddOrRemoveRoles() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.ProbateRole("12345678901"), | ||
factory.ProbateRole("12345678902"), | ||
factory.ProbateRole("12345678903"), | ||
factory.IndividualProxyRole("12345678902", "12345678901") | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_TwoHeirsHaveProbateRole_And_OneHeirHasAppointedTheOtherHeirAsIndividualProxy_Should_AddCollectiveProxyRole() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.ProbateRole("12345678901"), | ||
factory.ProbateRole("12345678902"), | ||
factory.FormuesfulmaktRole("12345678903"), | ||
factory.IndividualProxyRole("12345678902", "12345678901") | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateProxyRoleAssignments_EstateWithThreeHeirs_When_AllHeirsHaveProbateRole_And_TwoHeirsHaveBothAppointedTheThirdHeirAsIndividualProxy_Should_AddCollectiveProxyRole() | ||
{ | ||
// Arrange | ||
A.CallTo(() => _fakeRoleAssignmentRepository.GetRoleAssignmentsForEstate(A<string>._)) | ||
.ReturnsLazily((call) => | ||
{ | ||
var estateSsn = call.Arguments.Get<string>("estateSsn")!; | ||
var factory = new RoleAssignmentFactory(estateSsn); | ||
return Task.FromResult(new List<RoleAssignment> | ||
{ | ||
factory.ProbateRole("12345678901"), | ||
factory.ProbateRole("12345678902"), | ||
factory.ProbateRole("12345678903"), | ||
factory.IndividualProxyRole("12345678902", "12345678901"), | ||
factory.IndividualProxyRole("12345678903", "12345678901") | ||
}); | ||
}); | ||
|
||
var sut = new ProxyManagementService(_fakeRoleAssignmentRepository, _fakeLogger); | ||
|
||
// Act | ||
await sut.UpdateProxyRoleAssigments("11111111111"); | ||
|
||
// Assert | ||
A.CallTo(() => _fakeRoleAssignmentRepository.AddRoleAssignment(A<RoleAssignment>._)).MustHaveHappened(); | ||
A.CallTo(() => _fakeRoleAssignmentRepository.RemoveRoleAssignment(A<RoleAssignment>._)).MustNotHaveHappened(); | ||
} | ||
} | ||
} |
Oops, something went wrong.