public async Task <Result> Run(QueryRunnerCommand command) { using (var connection = new SqlConnection(Configuration.ConnectionString)) { var result = await connection.QueryAsync(command.Query, command.Params); return(Result.Ok(result)); } }
public async Task <Result> Run(QueryRunnerCommand command) { try { return(await Next.Run(command)); } catch (Exception ex) { // TODO: log return(Result.Error(ex)); } }
public async Task Run_WhenNoQueryWithThatIdExists_ShouldReturnError( QueryRunnerWithQueryValidation sut, QueryRunnerCommand command) { sut.QueryReader.Get(command.Id) .Returns(null as QueryEntity); var result = await sut.Run(command); result.Errors.Should() .Contain(x => x.Message == QueryErrors.QueryByIdDoesNotExit.Message); result.Data.Should().BeNull(); }
public async Task <Result> Run(QueryRunnerCommand command) { var query = await QueryReader.Get(command.Id); if (query is null) { return(Result.Error(QueryErrors.QueryByIdDoesNotExit)); } command.Query = query.Query; return(await Runner.Run(command)); }
public async Task Run_WhenQueryExists_ShouldExecuteQueryAndReturnResult( QueryRunnerWithQueryValidation sut, QueryRunnerCommand command, QueryEntity query, Result runResult) { sut.QueryReader.Get(command.Id) .Returns(query); sut.Runner.Run(command).Returns(runResult); var result = await sut.Run(command); result.Errors.Should().BeEmpty(); result.Data.Should().Be(runResult); }