public void DeleteAddressBookEntry_ShouldReturn400BadRequest_WhenEntryNotFound() { // Arrange _addressCommandsApiController = _addressCommandsApiControllerBuilder.Build(); // Act var response = _addressCommandsApiController.DeleteAddressBookEntry(null); // Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public void DeleteAddressBookEntry_ShouldReturn403Forbidden_WhenUserIsNotFound() { // Arrange _mockCurrentUserService.Setup(cus => cus.GetCurrentUserId()).Returns((string)null); _addressCommandsApiController = _addressCommandsApiControllerBuilder.WithCurrentUserService(_mockCurrentUserService.Object).Build(); // Act var response = _addressCommandsApiController.DeleteAddressBookEntry("AddressBookEntries/123"); // Assert response.StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public void DeleteAddressBookEntry_ShouldReturn403Forbidden_WhenUserIsNotAuthorized() { // Arrange var userId = "Users/007"; _mockCurrentUserService.Setup(cus => cus.GetCurrentUserId()).Returns(userId); _mockAuthorizationService.Setup(a => a.IsAuthorized(userId, ActivityEnum.View)).Returns(false); _addressCommandsApiController = _addressCommandsApiControllerBuilder.WithCurrentUserService(_mockCurrentUserService.Object).Build(); // Act var response = _addressCommandsApiController.DeleteAddressBookEntry("AddressBookEntries/123"); // Assert response.StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public void DeleteAddressBookEntry_ShouldReturn500Error_WhenUnhandledExceptionOccurs() { // Arrange const string addressBookEntryId = "AddressBookEntries/123"; _mockAddressBookService.Setup(ab => ab.DeleteAddressBookEntry(addressBookEntryId)).Throws <NotImplementedException>(); _addressCommandsApiController = _addressCommandsApiControllerBuilder .WithAddressBookService(_mockAddressBookService.Object) .WithUser("Users/007") .WithAllAuthority() .Build(); // Act var response = _addressCommandsApiController.DeleteAddressBookEntry(addressBookEntryId); // Assert response.StatusCode.Should().Be(HttpStatusCode.InternalServerError); }
public void DeleteAddressBookEntry_ShouldReturn500_WhenDeleteResultIsError() { // Arrange const string addressBookEntryId = "AddressBookEntries/123"; var deleteAddressBookEntryResult = new DeleteAddressBookEntryResult { ResultType = AddressBookCommandResultType.Error }; _mockAddressBookService.Setup(ab => ab.DeleteAddressBookEntry(addressBookEntryId)).Returns(deleteAddressBookEntryResult); _addressCommandsApiController = _addressCommandsApiControllerBuilder .WithAddressBookService(_mockAddressBookService.Object) .WithUser("Users/007") .WithAllAuthority() .Build(); // Act var response = _addressCommandsApiController.DeleteAddressBookEntry(addressBookEntryId); // Assert response.StatusCode.Should().Be(HttpStatusCode.InternalServerError); }