public void DeleteConductor() { conductor = context.Conductor.FirstOrDefaultAsync(c => c.Usuario == conductor.Usuario).Result; Console.WriteLine($"{DateTime.Now.ToLongTimeString()} - Borrando el conductor con Id: {conductor.ConductorId}"); var result = conductorController.Delete(conductor.ConductorId); result.Wait(); var viewResult = result.Result as ViewResult; var conductorResult = viewResult.Model as Conductor; var resultDeleteConfirmed = conductorController.DeleteConfirmed(conductorResult.ConductorId); resultDeleteConfirmed.Wait(); Assert.IsTrue(resultDeleteConfirmed.IsCompletedSuccessfully); }
public async Task DeleteAccount() { //Arrange var BDName = Guid.NewGuid().ToString(); var context = BuildContext(BDName); var fakeaccount = new Conductor() { Nombre = "Hillary", Apellido = "Moscoso", Dni = "76378521", Direccion = "Av. Los Olivos", Celular = "98346982", Correo = "*****@*****.**", }; context.Conductores.Add(fakeaccount); await context.SaveChangesAsync(); var context2 = BuildContext(BDName); //Act var controller = new ConductoresController(context2); var response = await controller.Delete(1); var cancel = response as StatusCodeResult; //Assert Assert.AreEqual(200, cancel.StatusCode); var context3 = BuildContext(BDName); var exist = await context3.Conductores.FindAsync(1); Assert.IsNull(exist); }