public void Delete() { bool result = false; BUserCompany bUserCompany = new BUserCompany(); EUserCompany eUserCompany = new EUserCompany(); EUserCompany insertedUserCompany = new EUserCompany(); EUserCompany deletedUserCompany = new EUserCompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); BUser bUser = new BUser(); EUser eUser = new EUser(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(15); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.Ruc = Aleatory.GetString(11); eCompany.LongName = Aleatory.GetString(15); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); eUser.CodeUser = Aleatory.GetString(8); eUser.Name = Aleatory.GetString(8); eUser.Password = Aleatory.GetString(8); eUser.State = Aleatory.GetShort(); eUser.Audit.UserRegister = Aleatory.GetString(8); bUser.Insert(eUser); eUserCompany.CodeUser = eUser.CodeUser; eUserCompany.CodeCompany = eCompany.CodeCompany; bUserCompany.Insert(eUserCompany); insertedUserCompany = bUserCompany.Select(eUserCompany); if (insertedUserCompany != null) { bUserCompany.Delete(eUserCompany); } deletedUserCompany = bUserCompany.Select(eUserCompany); if (deletedUserCompany == null) { result = true; } Assert.IsTrue(result); }
public void Update() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); ECompany updatedCompany = new ECompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.Ruc = Aleatory.GetString(11); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Update(eCompany); updatedCompany = bCompany.Select(eCompany); if (updatedCompany != null && updatedCompany.CodeCompany == eCompany.CodeCompany && updatedCompany.CodeCorporation == eCompany.CodeCorporation && updatedCompany.LongName != eCompany.LongName && updatedCompany.State == eCompany.State) { routes++; } eAudit = bAudit.Select(eCompany.Audit). Where(x => x.UserRegister == eCompany.Audit.UserRegister && x.Code == eCompany.Audit.Code && x.TypeEvent == "Update").FirstOrDefault(); if (eAudit != null) { routes++; } ts.Dispose(); }
public void Delete() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = 1; eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.Ruc = Aleatory.GetString(11); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); if (bCompany.Select(eCompany) != null) { routes++; } bCompany.Delete(eCompany); if (bCompany.Select(eCompany) == null) { routes++; } eAudit = bAudit.Select(eCompany.Audit). Where(x => x.UserRegister == eCompany.Audit.UserRegister && x.TypeEvent == "Delete" && x.Code == eCompany.Audit.Code).FirstOrDefault(); if (eAudit != null) { routes++; } ts.Dispose(); Assert.AreEqual(routes, 3); }
public void Select() { short routes = 0; BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); ECompany selectCompany = new ECompany(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.Ruc = Aleatory.GetString(11); eCompany.LongName = Aleatory.GetString(8); eCompany.ShortName = Aleatory.GetString(8); eCompany.State = 1; eCompany.Audit.UserRegister = Aleatory.GetString(8); selectCompany = bCompany.Select(eCompany); if (selectCompany == null) { routes++; } eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = 1; eCorporation.Audit.UserRegister = "uni test"; bCorporation.Insert(eCorporation); eCompany.CodeCorporation = eCorporation.CodeCorporation; bCompany.Insert(eCompany); selectCompany = bCompany.Select(eCompany); if (selectCompany != null && selectCompany.LongName == eCompany.LongName && selectCompany.ShortName == eCompany.ShortName) { routes++; } ts.Dispose(); Assert.AreEqual(routes, 2); }
public void DeleteByUser() { bool result = false; List <ECompany> listECompanies = new List <ECompany>(); BUserCompany bUserCompany = new BUserCompany(); EUserCompany eUserCompany = new EUserCompany(); EUserCompany insertedOneUserCompany = new EUserCompany(); EUserCompany insertedTwoUserCompany = new EUserCompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); BUser bUser = new BUser(); EUser eUser = new EUser(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(15); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.Ruc = Aleatory.GetString(11); eCompany.LongName = Aleatory.GetString(15); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); eUser.CodeUser = Aleatory.GetString(8); eUser.Name = Aleatory.GetString(8); eUser.Password = Aleatory.GetString(8); eUser.State = Aleatory.GetShort(); eUser.Audit.UserRegister = Aleatory.GetString(8); bUser.Insert(eUser); eUserCompany.CodeUser = eUser.CodeUser; eUserCompany.CodeCompany = eCompany.CodeCompany; bUserCompany.Insert(eUserCompany); insertedOneUserCompany = bUserCompany.Select(eUserCompany); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.LongName = Aleatory.GetString(15); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); eUserCompany.CodeUser = eUser.CodeUser; eUserCompany.CodeCompany = eCompany.CodeCompany; bUserCompany.Insert(eUserCompany); insertedTwoUserCompany = bUserCompany.Select(eUserCompany); listECompanies = bUserCompany.SelectByUser(eUser); if (listECompanies.Count == 2 && listECompanies.Exists(x => x.CodeCompany == insertedOneUserCompany.CodeCompany) && listECompanies.Exists(x => x.CodeCompany == insertedTwoUserCompany.CodeCompany)) { bUserCompany.DeleteByUser(eUser); } listECompanies = bUserCompany.SelectByUser(eUser); if (listECompanies.Count == 0) { result = true; } Assert.IsTrue(result); }
public void Delete() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); ECorporation insertedCorporation = new ECorporation(); BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); ECompany insertedCompany = new ECompany(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); insertedCorporation = bCorporation.Select(eCorporation); if (insertedCorporation != null) { routes++; } insertedCorporation.Audit.UserRegister = eCorporation.Audit.UserRegister; bCorporation.Delete(insertedCorporation); if (bCorporation.Select(insertedCorporation) == null) { routes++; } eAudit = bAudit.Select(eCorporation.Audit). Where(x => x.UserRegister == eCorporation.Audit.UserRegister && x.Code == eCorporation.Audit.Code && x.TypeEvent == "Delete").FirstOrDefault(); if (eAudit != null) { routes++; } bCorporation.Insert(eCorporation); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.Ruc = Aleatory.GetString(11); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = eCorporation.Audit.UserRegister; bCompany.Insert(eCompany); insertedCompany = bCompany.Select(eCompany); if (insertedCompany != null) { try { eCorporation.Audit.UserRegister = Aleatory.GetString(9); bCorporation.Delete(eCorporation); } catch { } if (bCorporation.Message.Contains("La Corporación") && bCorporation.Message.Contains("tiene referencias en el Sistema, no se puede eliminar el registro.")) { routes++; } eAudit = bAudit.Select(eCorporation.Audit). Where(x => x.UserRegister == eCorporation.Audit.UserRegister && x.Code == eCorporation.Audit.Code && x.TypeEvent == "Delete").FirstOrDefault(); if (eAudit == null) { routes++; } } ts.Dispose(); Assert.AreEqual(routes, 5); }