public PermissaoControllerTest() { _mediator = new Mock <IMediator>(); _notifications = new DomainNotificationHandler(); _controller = new PermissoesController(_mediator.Object, _notifications); _list = new List <PermissaoViewModel>() { ViewModelBuilder.PermissaoViewFake(), ViewModelBuilder.PermissaoViewFake(), ViewModelBuilder.PermissaoViewFake(), ViewModelBuilder.PermissaoViewFake(), }; }
public async Task Deve_Retornar_Ok_Ao_Editar_Permissao() { //arrange var permissao = ViewModelBuilder.PermissaoViewFake(); var command = new AtualizarPermissaoCommand(permissao.Id, permissao.Tipo, permissao.Valor); _mediator.Setup(s => s.Send(It.IsAny <IRequest <CommandResponse> >(), new System.Threading.CancellationToken())) .ReturnsAsync(CommandResponse.Ok); //act var result = await _controller.AtualizarPermissaoAsync(command); //assert result.Should().BeAssignableTo <OkResult>(); var vr = result as OkResult; vr.StatusCode.Should().Be(StatusCodes.Status200OK); }
public async Task Deve_Retornar_BadRequest_Ao_Criar_Permissao() { //arrange var permissao = ViewModelBuilder.PermissaoViewFake(); var command = new CriarPermissaoCommand(permissao.Tipo, permissao.Valor); _mediator.Setup(s => s.Send(It.IsAny <IRequest <CommandResponse> >(), new System.Threading.CancellationToken())) .ReturnsAsync(CommandResponse.Fail.AddError("Erro Fake")).Verifiable(); //act var result = await _controller.CriarPermissaoAsync(command); //assert result.Should().BeAssignableTo <BadRequestObjectResult>(); var vr = result as BadRequestObjectResult; vr.StatusCode.Should().Be(StatusCodes.Status400BadRequest); }
public async Task Deve_Retornar_Uma_Permissao_Por_Id() { // arrange var permissaoViewModel = ViewModelBuilder.PermissaoViewFake(); _mediator.Setup(s => s.Send(It.IsAny <IRequest <PermissaoViewModel> >(), new System.Threading.CancellationToken())) .ReturnsAsync(permissaoViewModel); //act var result = await _controller.GetPermissaoAsync(Guid.NewGuid()); var vr = result as OkObjectResult; //assert result.Should().BeAssignableTo <OkObjectResult>(); vr.Value.Should().Be(permissaoViewModel); }