public void ExcluirRegistroUnico() { // Arrange EstudanteDominio oEstudanteDominio = null; Estudante oEstudante = null; Estudante oEstudanteExcluir = null; Boolean isSucesso; // Act oEstudanteDominio = new EstudanteDominio(); // usuário seleciona o registro pra confirmação de excusão oEstudante = oEstudanteDominio.Selecionar(1); // usuario executa a ação de exclusão (passando a versao do registro para checagem de concorrencia no banco) oEstudanteExcluir = new Estudante(); oEstudanteExcluir.ID = oEstudante.ID; oEstudanteExcluir.RowVersion = oEstudante.RowVersion; isSucesso = oEstudanteDominio.Excluir(oEstudanteExcluir); // Assert Assert.IsTrue(isSucesso); oEstudanteDominio = null; oEstudante = null; oEstudanteExcluir = null; }
public void ExcluirRegistroUnicoRegistroComConcorrencia() { // Arrange EstudanteDominio oEstudanteDominio = null; Estudante oUS1_EstudanteA = null; Estudante oUS2_EstudanteA = null; Estudante oUS2_EstudanteExcluirA = null; // Act oEstudanteDominio = new EstudanteDominio(); // usuario 1 e 2 selecionam o mesmo registro A oUS1_EstudanteA = oEstudanteDominio.Selecionar(2); oUS2_EstudanteA = oEstudanteDominio.Selecionar(2); // usuario 1 altera o registro A oUS1_EstudanteA.Nome = "US1 NOME ALTERADO"; oEstudanteDominio.Atualizar(oUS1_EstudanteA); // usuario 2 tenta excluir o registro e recebe aviso de erro de concorrencia oUS2_EstudanteExcluirA = new Estudante(); oUS2_EstudanteExcluirA.ID = oUS2_EstudanteA.ID; oUS2_EstudanteExcluirA.RowVersion = oUS2_EstudanteA.RowVersion; oEstudanteDominio.Excluir(oUS2_EstudanteExcluirA); oEstudanteDominio = null; oUS1_EstudanteA = null; oUS2_EstudanteA = null; oUS2_EstudanteExcluirA = null; }
public void InsereRegistroUnico() { // Arrange EstudanteDominio oEstudanteDominio = null; Estudante oEstudante = null; Boolean isSucesso; // Act oEstudante = new Estudante() { Nome = "Tiago", Idade = 27 }; oEstudanteDominio = new EstudanteDominio(); isSucesso = oEstudanteDominio.Inserir(oEstudante); // Assert Assert.IsTrue(isSucesso); oEstudanteDominio = null; oEstudante = null; }
public void AtualizaRegistroComConcorrencia_RegistroExcluido() { // Arrange EstudanteDominio oEstudanteDominio = null; Estudante oUsuario1_EstudanteA = null; Estudante oUsuario1_EstudanteExcluirA = null; Estudante oUsuario2_EstudanteA = null; // Act oEstudanteDominio = new EstudanteDominio(); // usuario 1 e 2 seleciona estudante A oUsuario1_EstudanteA = oEstudanteDominio.Selecionar(6); oUsuario2_EstudanteA = oEstudanteDominio.Selecionar(6); // usuario 1 exclui o registro A primeiro oUsuario1_EstudanteExcluirA = new Estudante(); oUsuario1_EstudanteExcluirA.ID = oUsuario1_EstudanteA.ID; oUsuario1_EstudanteExcluirA.RowVersion = oUsuario1_EstudanteA.RowVersion; oEstudanteDominio.Excluir(oUsuario1_EstudanteExcluirA); // usuario 2 edita e salva estudante A depois e recebe um aviso de concorrencia do banco oUsuario2_EstudanteA.Nome = "TESTE CONCORRENCIA US2"; oEstudanteDominio.Atualizar(oUsuario2_EstudanteA); oEstudanteDominio = null; oUsuario1_EstudanteA = null; oUsuario2_EstudanteA = null; }