public void Select() { short routes = 0; string codeCompany = Aleatory.GetString(2); string codeEntity = Aleatory.GetString(8); string code = Aleatory.GetString(8); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); EAudit selectedAudit = null; BAudit bAudit = new BAudit(); EAudit eAudit = new EAudit( CodeCompany: codeCompany, CodeEntity: codeEntity, Code: code ); eAudit.UserRegister = Aleatory.GetString(8); eAudit.TypeEvent = "Insert"; if (bAudit.Select(eAudit).Count == 0) { routes++; } bAudit.Insert(eAudit); selectedAudit = bAudit.Select(eAudit).Where(x => x.UserRegister == eAudit.UserRegister && x.TypeEvent == "Insert").FirstOrDefault(); if (selectedAudit != null) { routes++; } ts.Dispose(); Assert.AreEqual(routes, 2); }
public void Insert() { ECorporation eCorporation = new ECorporation(); BCorporation bCorporation = new BCorporation(); BAudit bAudit = new BAudit(); short routes = 0; eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { bCorporation.Insert(eCorporation); ECorporation insertedCorporation = bCorporation.Select(eCorporation); if (insertedCorporation != null && insertedCorporation.Name == eCorporation.Name && insertedCorporation.State == eCorporation.State) { routes++; } EAudit lastAudit = bAudit.Select(eCorporation.Audit).Where(x => x.UserRegister == eCorporation.Audit.UserRegister && x.TypeEvent == "Insert").FirstOrDefault(); if (lastAudit != null) { routes++; } } Assert.AreEqual(routes, 2); }
public void Insert() { bool result = false; string codeCompany = Aleatory.GetString(2); string codeEntity = Aleatory.GetString(8); string code = Aleatory.GetString(8); BAudit bAudit = new BAudit(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); EAudit eAudit = new EAudit( CodeCompany: codeCompany, CodeEntity: codeEntity, Code: code); eAudit.TypeEvent = "Insert"; eAudit.UserRegister = Aleatory.GetString(8); bAudit.Insert(eAudit); EAudit insertedAudit = bAudit.Select(eAudit).Where(x => x.UserRegister == eAudit.UserRegister && x.TypeEvent == eAudit.TypeEvent).FirstOrDefault(); if (insertedAudit != null) { result = true; } ts.Dispose(); Assert.IsTrue(result); }
public void Update() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BUser bUser = new BUser(); EUser eUser = new EUser(); EUser insertedUser = null; EUser updatedUser = null; TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eUser.CodeUser = Aleatory.GetString(8); eUser.Name = Aleatory.GetString(8); eUser.Password = Aleatory.GetString(8); eUser.Email = Aleatory.GetString(15); eUser.State = Aleatory.GetShort(); eUser.Audit.UserRegister = Aleatory.GetString(8); bUser.Insert(eUser); insertedUser = bUser.Select(eUser); if (insertedUser != null) { routes++; } insertedUser.Name = Aleatory.GetString(8); insertedUser.Email = Aleatory.GetString(15); insertedUser.State = Aleatory.GetShort(); insertedUser.Audit.UserRegister = Aleatory.GetString(8); bUser.Update(insertedUser); updatedUser = bUser.Select(insertedUser); if (updatedUser != null && updatedUser.Name != eUser.Name && updatedUser.Email != eUser.Email && updatedUser.State != eUser.State && updatedUser.CodeUser == eUser.CodeUser) { routes++; } eAudit = bAudit.Select(insertedUser.Audit). Where(x => x.UserRegister == insertedUser.Audit.UserRegister && x.Code == eUser.Audit.Code && x.TypeEvent == "Update").FirstOrDefault(); if (eAudit != null) { routes++; } ts.Dispose(); Assert.AreEqual(routes, 3); }
public void Insert() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BUser bUser = new BUser(); EUser eUser = new EUser(); EUser insertedUser = null; TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eUser.CodeUser = Aleatory.GetString(8); eUser.Name = Aleatory.GetString(8); eUser.Password = Aleatory.GetString(8); eUser.Email = Aleatory.GetString(15); eUser.State = Aleatory.GetShort(); eUser.Audit.UserRegister = Aleatory.GetString(8); if (bUser.Select(eUser) != null) { bUser.Delete(eUser); } if (bUser.Select(eUser) == null) { routes++; } bUser.Insert(eUser); insertedUser = bUser.Select(eUser); if (insertedUser != null) { routes++; } string hash = bUser.CalculateHash(eUser); if (insertedUser.Password == hash) { routes++; } eAudit = bAudit.Select(eUser.Audit). Where(x => x.UserRegister == eUser.Audit.UserRegister && x.Code == eUser.Audit.Code && x.TypeEvent == "Insert").FirstOrDefault(); if (eAudit != null) { routes++; } ts.Dispose(); Assert.AreEqual(routes, 4); }
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 Update() { bool result = false; BAudit bAudit = new BAudit(); List <EAudit> listAudit = new List <EAudit>(); BClient bClient = new BClient(); EClient eClient = new EClient(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eClient.CodeTypeDocumentIdentity = "0"; eClient.NumberIdentity = Aleatory.GetString(11); eClient.FirstName = Aleatory.GetString(8); eClient.SecondName = Aleatory.GetString(8); eClient.FatherLastName = Aleatory.GetString(8); eClient.MotherLastName = Aleatory.GetString(8); eClient.Audit.UserRegister = Aleatory.GetString(8); EClient insertedEClient = bClient.Insert(eClient); insertedEClient.FirstName = Aleatory.GetString(8); insertedEClient.SecondName = Aleatory.GetString(8); insertedEClient.FatherLastName = Aleatory.GetString(8); insertedEClient.MotherLastName = Aleatory.GetString(8); insertedEClient.Audit.UserRegister = Aleatory.GetString(8); EClient updatedEClient = bClient.Update(insertedEClient); listAudit = bAudit.Select(eClient.Audit); if (updatedEClient != null && updatedEClient.SearchName != eClient.SearchName && listAudit.Count > 0 && listAudit.Exists( x => x.UserRegister == insertedEClient.Audit.UserRegister && x.Code == updatedEClient.CodeClient.ToString() && x.TypeEvent == "Update")) { result = true; } ts.Dispose(); Assert.IsTrue(result); }
public void Select() { ECorporation eCorporation = new ECorporation(); BCorporation bCorporation = new BCorporation(); BAudit bAudit = new BAudit(); short routes = 0; eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = 1; eCorporation.Audit.UserRegister = Aleatory.GetString(8); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { if (bCorporation.Select(eCorporation) == null) { routes++; } bCorporation.Insert(eCorporation); ECorporation insertedCorporation = bCorporation.Select(eCorporation); if (insertedCorporation != null && insertedCorporation.Name == eCorporation.Name && insertedCorporation.State == eCorporation.State) { routes++; } EAudit lastAudit = bAudit.Select(eCorporation.Audit)[0]; if (lastAudit != null && lastAudit.UserRegister == eCorporation.Audit.UserRegister && lastAudit.TypeEvent.ToLower() == "insert") { routes++; } } Assert.AreEqual(routes, 3); }
public void Insert() { bool result = false; BAudit bAudit = new BAudit(); List <EAudit> listAudit = new List <EAudit>(); BClient bClient = new BClient(); EClient eClient = new EClient(); BSequence bSequence = new BSequence(); ESequence eSequence = null; TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eClient.CodeTypeDocumentIdentity = "0"; eClient.NumberIdentity = Aleatory.GetString(11); eClient.FirstName = Aleatory.GetString(8); eClient.SecondName = Aleatory.GetString(8); eClient.FatherLastName = Aleatory.GetString(8); eClient.MotherLastName = Aleatory.GetString(8); eClient.Audit.UserRegister = Aleatory.GetString(8); EClient insertedEClient = bClient.Insert(eClient); eSequence = new ESequence(eClient); eSequence = bSequence.Select(eSequence); listAudit = bAudit.Select(eClient.Audit); if (insertedEClient != null && listAudit.Exists(x => x.UserRegister == eClient.Audit.UserRegister && x.TypeEvent == "Insert" && x.Code == insertedEClient.CodeClient.ToString()) && eSequence.Correlative == insertedEClient.CodeClient + 1) { result = true; } ts.Dispose(); Assert.IsTrue(result); }
public void Update() { ECorporation eCorporation = new ECorporation(); BCorporation bCorporation = new BCorporation(); BAudit bAudit = new BAudit(); short routes = 0; eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { bCorporation.Insert(eCorporation); ECorporation originalCorporation = bCorporation.Select(eCorporation); if (originalCorporation != null && originalCorporation.Name == eCorporation.Name && originalCorporation.State == eCorporation.State) { routes++; } EAudit lastAudit = bAudit.Select(eCorporation.Audit).Where(x => x.UserRegister == eCorporation.Audit.UserRegister && x.TypeEvent == "Insert").FirstOrDefault(); if (lastAudit != null) { routes++; } eCorporation.Name = string.Format("{0} {1}", eCorporation.Name, "update"); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Update(eCorporation); ECorporation updatedCorporation = bCorporation.Select(eCorporation); if (updatedCorporation != null && updatedCorporation.Name == eCorporation.Name && updatedCorporation.State == eCorporation.State && updatedCorporation.Name != originalCorporation.Name && updatedCorporation.State != originalCorporation.State) { routes++; } lastAudit = bAudit.Select(updatedCorporation.Audit). Where(x => x.UserRegister == eCorporation.Audit.UserRegister && x.Code == eCorporation.Audit.Code && x.TypeEvent == "Update").FirstOrDefault(); if (lastAudit != null) { routes++; } } Assert.AreEqual(routes, 4); }
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); }