public async Task TestSuspendHandler_ToThrowNotFound_WhenGroupNotFound() { var identity = new BizflyIdentity(); string groupId = "test-group-id"; string ownerId = "test-user-id"; _mockGroupRepository .Setup(repo => repo.GetByIdAsync(groupId)) .Throws(new ResourceNotFoundException()) .Verifiable(); // _mockGroupRepository //.Setup(repo => repo.AddOrUpdateAsync(It.IsAny<Group>(), null)) //.Throws(new ResourceNotFoundException()); SuspendGroupCommand command = new SuspendGroupCommand(identity, groupId, ownerId); await _suspendGroupHandler.Handle(command); _mockGroupRepository.Verify(); }
public async Task <IActionResult> PostToSuspendGroup( string id, [FromServices] ICommandHandler <SuspendGroupCommand> _suspendGroupCommandHandler) { _logger.LogInformation("Running POST method to SUSPEND group by ID"); //Gets Bizfly identity from header. BizflyIdentity bizflyIdentity = Request.Headers.GetIdentityFromHeaders(); SuspendGroupCommand command = new SuspendGroupCommand(bizflyIdentity, id, bizflyIdentity.UserId); await _suspendGroupCommandHandler.Handle(command); if (ModelState.IsValid) { return(Ok()); } return(BadRequest(ModelState)); }