vendredi 14 juin 2019

I want to Create Xunit test for this controller. How can i do that

I have created small kind of xunit test case but I don't know how to create this controller which i have mention below.

    public class PropertyController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ILogger<PropertyController> _logger;

        public PropertyController(IMediator mediator, ILogger<PropertyController> logger)
        {
            _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
        public async Task<IActionResult> AddProperty([FromBody] AddPropertyCommand command)
        {
            bool commandResult = false;
            _logger.LogInformation(
                "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
                command.GetGenericTypeName(),
                nameof(command.ModifiedUserId),
                command.ModifiedUserId,
                command);
            commandResult = await _mediator.Send(command);
            if (!commandResult)
            {
                return BadRequest();
            }
            return Ok();
        }

Aucun commentaire:

Enregistrer un commentaire