Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e2b8497
CODERUB : Added line break
SlimAhmad Mar 28, 2025
efe9d36
CODERUB : Added line break
SlimAhmad Mar 28, 2025
4b653c5
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
SlimAhmad Mar 31, 2025
0fc58d8
CODERUB : Fixed indentation and naming
SlimAhmad Mar 31, 2025
bc1452a
CODERUB: Fixed naming and indentation
SlimAhmad Mar 31, 2025
89f267f
CODERUB : Fixed indentation and naming
SlimAhmad Apr 4, 2025
995dd00
COODERUB : Fixed naming
SlimAhmad Apr 4, 2025
e6110d6
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
SlimAhmad Apr 4, 2025
171e2f2
CODERUB: Removed space
SlimAhmad Apr 5, 2025
b1d75ed
CODERUB: RemoveContributionTypeByIdAsync to use specific inputId inst…
SlimAhmad Apr 15, 2025
3a01499
CODERUB: Merged conflicts
SlimAhmad Apr 15, 2025
371ac17
CODERUB: Removed extra namespaces
SlimAhmad Apr 15, 2025
c36e20c
CODERUB: Merged conflicts
SlimAhmad Apr 26, 2025
9307354
CODERUB: Fixed method name
SlimAhmad Apr 26, 2025
7a5e74c
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
glhays Apr 26, 2025
8f39d5c
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
glhays Apr 26, 2025
ce5f37d
CODE RUB: Added line breaks and removed extra space
SlimAhmad May 1, 2025
9b475f6
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
SlimAhmad May 1, 2025
74f148f
Merge branch 'users/slimahmad/controllers/contribtionType-Delete' of …
SlimAhmad May 1, 2025
2b16485
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
glhays May 23, 2025
dfb290d
CODERUB: Fixed indentation
SlimAhmad May 23, 2025
0bab5b7
Merge branch 'users/slimahmad/controllers/contribtionType-Delete' of …
SlimAhmad May 23, 2025
57960f2
CODERUB: Merged conflicts
SlimAhmad May 29, 2025
0fff482
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
glhays May 29, 2025
a646c06
Merge branch 'main' into users/slimahmad/controllers/contribtionType-…
glhays May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public partial class ContributionTypesControllerTests
{
[Theory]
[MemberData(nameof(ValidationExceptions))]
public async Task ShouldReturnBadRequestOnDeleteIfValidationErrorOccursAsync(
public async Task ShouldReturnBadRequestOnDeleteIfValidationExceptionOccursAsync(
Xeption validationException)
{
// given
Guid someId = Guid.NewGuid();
Guid someContributionTypeId = Guid.NewGuid();

BadRequestObjectResult expectedBadRequestObjectResult =
BadRequest(validationException.InnerException);
Expand All @@ -36,7 +36,8 @@ public async Task ShouldReturnBadRequestOnDeleteIfValidationErrorOccursAsync(

// when
ActionResult<ContributionType> actualActionResult =
await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId);
await this.contributionTypesController.DeleteContributionTypeByIdAsync(
someContributionTypeId);

// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
Expand All @@ -50,25 +51,26 @@ public async Task ShouldReturnBadRequestOnDeleteIfValidationErrorOccursAsync(

[Theory]
[MemberData(nameof(ServerExceptions))]
public async Task ShouldReturnInternalServerErrorOnDeleteIfServerErrorOccurredAsync(
Xeption validationException)
public async Task ShouldReturnInternalServerErrorOnDeleteIfServerExceptionOccurredAsync(
Xeption serverException)
{
// given
Guid someId = Guid.NewGuid();
Guid someContributionTypeId = Guid.NewGuid();

InternalServerErrorObjectResult expectedBadRequestObjectResult =
InternalServerError(validationException);
InternalServerErrorObjectResult expectedInternalServerErrorObjectResult =
InternalServerError(serverException);

var expectedActionResult =
new ActionResult<ContributionType>(expectedBadRequestObjectResult);
new ActionResult<ContributionType>(expectedInternalServerErrorObjectResult);

this.contributionTypeServiceMock.Setup(service =>
service.RemoveContributionTypeByIdAsync(It.IsAny<Guid>()))
.ThrowsAsync(validationException);
.ThrowsAsync(serverException);

// when
ActionResult<ContributionType> actualActionResult =
await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId);
await this.contributionTypesController.DeleteContributionTypeByIdAsync(
someContributionTypeId);

// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
Expand All @@ -81,10 +83,10 @@ public async Task ShouldReturnInternalServerErrorOnDeleteIfServerErrorOccurredAs
}

[Fact]
public async Task ShouldReturnNotFoundOnDeleteIfItemDoesNotExistAsync()
public async Task ShouldReturnNotFoundOnDeleteIfContributionTypeDoesNotExistAsync()
{
// given
Guid someId = Guid.NewGuid();
Guid someContributionTypeId = Guid.NewGuid();
string someMessage = GetRandomString();

var notFoundContributionTypeException =
Expand All @@ -108,7 +110,8 @@ public async Task ShouldReturnNotFoundOnDeleteIfItemDoesNotExistAsync()

// when
ActionResult<ContributionType> actualActionResult =
await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId);
await this.contributionTypesController.DeleteContributionTypeByIdAsync(
someContributionTypeId);

// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
Expand All @@ -121,10 +124,10 @@ public async Task ShouldReturnNotFoundOnDeleteIfItemDoesNotExistAsync()
}

[Fact]
public async Task ShouldReturnLockedOnDeleteIfRecordIsLockedAsync()
public async Task ShouldReturnLockedOnDeleteIfLockedContributionTypeExceptionOccursAsync()
{
// given
Guid someId = Guid.NewGuid();
Guid someContributionTypeId = Guid.NewGuid();
var someInnerException = new Exception();
string someMessage = GetRandomString();
var someDictionaryData = GetRandomDictionaryData();
Expand All @@ -141,19 +144,20 @@ public async Task ShouldReturnLockedOnDeleteIfRecordIsLockedAsync()
innerException: lockedContributionTypeException,
data: someDictionaryData);

LockedObjectResult expectedConflictObjectResult =
LockedObjectResult expectedLockedObjectResult =
Locked(lockedContributionTypeException);

var expectedActionResult =
new ActionResult<ContributionType>(expectedConflictObjectResult);
new ActionResult<ContributionType>(expectedLockedObjectResult);

this.contributionTypeServiceMock.Setup(service =>
service.RemoveContributionTypeByIdAsync(It.IsAny<Guid>()))
.ThrowsAsync(contributionTypeDependencyValidationException);

// when
ActionResult<ContributionType> actualActionResult =
await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId);
await this.contributionTypesController.DeleteContributionTypeByIdAsync(
someContributionTypeId);

// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
Expand All @@ -166,40 +170,40 @@ public async Task ShouldReturnLockedOnDeleteIfRecordIsLockedAsync()
}

[Fact]
public async Task ShouldReturnFailedDependencyOnDeleteIfReferenceErrorOccursAsync()
public async Task ShouldReturnFailedDependencyOnDeleteIfReferenceExceptionOccursAsync()
{
// given
Guid someId = Guid.NewGuid();
Guid someContributionTypeId = Guid.NewGuid();
ContributionType someContributionType = CreateRandomContributionType();
var someInnerException = new Exception();
string someMessage = GetRandomString();

var invalidReferenceContributionTypeException =
var invalidReferenceContributionTypeException =
Comment thread
glhays marked this conversation as resolved.
new InvalidReferenceContributionTypeException(
message: someMessage,
innerException: someInnerException,
data: someInnerException.Data);

var contributionTypeDependencyValidationException =
var contributionTypeDependencyValidationException =
Comment thread
glhays marked this conversation as resolved.
new ContributionTypeDependencyValidationException(
message: someMessage,
innerException: invalidReferenceContributionTypeException,
data: invalidReferenceContributionTypeException.Data);

FailedDependencyObjectResult expectedConflictObjectResult =
FailedDependency(invalidReferenceContributionTypeException);

var expectedActionResult =
new ActionResult<ContributionType>(expectedConflictObjectResult);
FailedDependencyObjectResult expectedFailedDependencyObjectResult =
FailedDependency(invalidReferenceContributionTypeException);

var expectedActionResult =
new ActionResult<ContributionType>(expectedFailedDependencyObjectResult);

this.contributionTypeServiceMock.Setup(service =>
service.RemoveContributionTypeByIdAsync(It.IsAny<Guid>()))
.ThrowsAsync(contributionTypeDependencyValidationException);

// when
ActionResult<ContributionType> actualActionResult =
await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId);
await this.contributionTypesController.DeleteContributionTypeByIdAsync(
someContributionTypeId);

// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class ContributionTypesControllerTests
{
[Theory]
[MemberData(nameof(ValidationExceptions))]
public async Task ShouldReturnBadRequestOnDeleteIfValidationExceptionOccursAsync(
public async Task ShouldReturnBadRequestOnPostIfValidationExceptionOccursAsync(
Xeption validationException)
{
// given
Expand Down