public async Task coleta_controller_post_should_return_accepted() { var queueServiceMock = new Mock <IQueueService>(); var coletaRepositoryMock = new Mock <IColetaRepository>(); var controller = new ColetaController(coletaRepositoryMock.Object, queueServiceMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); controller.ControllerContext.HttpContext.Connection.RemoteIpAddress = new System.Net.IPAddress(12312312); var command = new ColetaCommand { IP = "127.0.0.1", Browser = "Chrome", Pagina = "Home", Data = DateTime.UtcNow, Parametros = String.Empty }; var result = await controller.Post(command); var contentResult = result as AcceptedResult; contentResult.Should().NotBeNull(); }
public async Task <IActionResult> Post([FromBody] ColetaCommand command) { command.Data = DateTime.UtcNow; command.IP = this.HttpContext.Connection.RemoteIpAddress.ToString(); await _queueService.SendAsync <ColetaCommand>(@object : command, exchangeName : "coleta.exchange", routingKey : "coletaqueue"); return(Accepted()); }