public void InsertCommand_Default_IsSuccessfulFalseAndDataIsNull() { var cmd = new CommandInsertRow(_tableNameFixture, _colsFixture); cmd.IsSuccessful.Should().BeFalse(); cmd.Data.Should().BeNull(); }
public async Task ExecuteAsync_HappyPath_IsSuccessfulReturnTrue() { var dbCommand = CreateDbCommandForHappyPath(); var command = new CommandInsertRow(_tableNameFixture, _colsFixture); await command.ExecuteAsync(dbCommand); command.IsSuccessful.Should().BeTrue(); }
public async Task ExecuteAsync_VerifyBehavior() { var dbCommand = CreateDbCommandForHappyPath(); var command = new CommandInsertRow(_tableNameFixture, _colsFixture); await command.ExecuteAsync(dbCommand); dbCommand.CountCallCommandText.Should().Be(1); dbCommand.CountCallDbParameterCollection.Should().Be(1); dbCommand.CountCallExecuteScalarAsync.Should().Be(1); }
public async Task ExecuteAsync_HappyPath_CreateIdReturnGeneratedId() { var expectedId = new Fixture().Create <int>(); var dbCommand = CreateDbCommandForHappyPath(expectedId: expectedId); var command = new CommandInsertRow(_tableNameFixture, _colsFixture); await command.ExecuteAsync(dbCommand); command.CreatedId.Should().Be(expectedId); }
public async Task ExecuteAsync_HappyPath_DataReturnGeneratedResponse() { var expectedResponse = new Fixture().Create <string>(); var dbCommand = CreateDbCommandForHappyPath(expectedResponse: expectedResponse); var command = new CommandInsertRow(_tableNameFixture, _colsFixture); await command.ExecuteAsync(dbCommand); command.Data.Should().Be(expectedResponse); }
public async Task <ActionResult> Create(string name, [FromBody] JsonElement json) { var command = new CommandInsertRow(name, json.ToString()); await _dbCon.ExecuteAsync(command); if (!command.IsSuccessful) { return(BadRequest(command.Error)); } Response.StatusCode = StatusCodes.Status201Created; Response.Headers.Add("Location", $"api/Table/{name}/Row/{command.CreatedId}"); return(Content(command.Data, "application/json")); }