diff --git a/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Delete.cs b/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Delete.cs index a25c1037..b6353322 100644 --- a/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Delete.cs +++ b/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Delete.cs @@ -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); @@ -36,7 +36,8 @@ public async Task ShouldReturnBadRequestOnDeleteIfValidationErrorOccursAsync( // when ActionResult actualActionResult = - await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId); + await this.contributionTypesController.DeleteContributionTypeByIdAsync( + someContributionTypeId); // then actualActionResult.ShouldBeEquivalentTo(expectedActionResult); @@ -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(expectedBadRequestObjectResult); + new ActionResult(expectedInternalServerErrorObjectResult); this.contributionTypeServiceMock.Setup(service => service.RemoveContributionTypeByIdAsync(It.IsAny())) - .ThrowsAsync(validationException); + .ThrowsAsync(serverException); // when ActionResult actualActionResult = - await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId); + await this.contributionTypesController.DeleteContributionTypeByIdAsync( + someContributionTypeId); // then actualActionResult.ShouldBeEquivalentTo(expectedActionResult); @@ -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 = @@ -108,7 +110,8 @@ public async Task ShouldReturnNotFoundOnDeleteIfItemDoesNotExistAsync() // when ActionResult actualActionResult = - await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId); + await this.contributionTypesController.DeleteContributionTypeByIdAsync( + someContributionTypeId); // then actualActionResult.ShouldBeEquivalentTo(expectedActionResult); @@ -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(); @@ -141,11 +144,11 @@ public async Task ShouldReturnLockedOnDeleteIfRecordIsLockedAsync() innerException: lockedContributionTypeException, data: someDictionaryData); - LockedObjectResult expectedConflictObjectResult = + LockedObjectResult expectedLockedObjectResult = Locked(lockedContributionTypeException); var expectedActionResult = - new ActionResult(expectedConflictObjectResult); + new ActionResult(expectedLockedObjectResult); this.contributionTypeServiceMock.Setup(service => service.RemoveContributionTypeByIdAsync(It.IsAny())) @@ -153,7 +156,8 @@ public async Task ShouldReturnLockedOnDeleteIfRecordIsLockedAsync() // when ActionResult actualActionResult = - await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId); + await this.contributionTypesController.DeleteContributionTypeByIdAsync( + someContributionTypeId); // then actualActionResult.ShouldBeEquivalentTo(expectedActionResult); @@ -166,32 +170,31 @@ 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 = new InvalidReferenceContributionTypeException( message: someMessage, innerException: someInnerException, data: someInnerException.Data); - var contributionTypeDependencyValidationException = + var contributionTypeDependencyValidationException = new ContributionTypeDependencyValidationException( message: someMessage, innerException: invalidReferenceContributionTypeException, data: invalidReferenceContributionTypeException.Data); - FailedDependencyObjectResult expectedConflictObjectResult = - FailedDependency(invalidReferenceContributionTypeException); - - var expectedActionResult = - new ActionResult(expectedConflictObjectResult); + FailedDependencyObjectResult expectedFailedDependencyObjectResult = + FailedDependency(invalidReferenceContributionTypeException); + var expectedActionResult = + new ActionResult(expectedFailedDependencyObjectResult); this.contributionTypeServiceMock.Setup(service => service.RemoveContributionTypeByIdAsync(It.IsAny())) @@ -199,7 +202,8 @@ public async Task ShouldReturnFailedDependencyOnDeleteIfReferenceErrorOccursAsyn // when ActionResult actualActionResult = - await this.contributionTypesController.DeleteContributionTypeByIdAsync(someId); + await this.contributionTypesController.DeleteContributionTypeByIdAsync( + someContributionTypeId); // then actualActionResult.ShouldBeEquivalentTo(expectedActionResult); diff --git a/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Post.cs b/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Post.cs index aff250c9..e843ba0e 100644 --- a/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Post.cs +++ b/GitFyle.Core.Api.Tests.Unit/Controllers/ContributionTypes/ContributionTypesControllerTests.Exceptions.Post.cs @@ -18,7 +18,7 @@ public partial class ContributionTypesControllerTests { [Theory] [MemberData(nameof(ValidationExceptions))] - public async Task ShouldReturnBadRequestOnDeleteIfValidationExceptionOccursAsync( + public async Task ShouldReturnBadRequestOnPostIfValidationExceptionOccursAsync( Xeption validationException) { // given