Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void Delete()
        {
            bool             result          = false;
            string           codeSequence    = Aleatory.GetString(8);
            int              correlativo     = Aleatory.GetShort();
            BSequence        bSequence       = new BSequence();
            ESequence        eSequence       = new ESequence(codeSequence, correlativo);
            ESequence        deletedSequence = null;
            ESequence        seletedSequence = null;
            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            bSequence.Insert(eSequence);
            seletedSequence = bSequence.Select(eSequence);
            if (seletedSequence != null)
            {
                bSequence.Delete(eSequence);
                deletedSequence = bSequence.Select(eSequence);
                if (deletedSequence == null)
                {
                    result = true;
                }
            }

            Assert.AreEqual(result, true);
        }
Esempio n. 4
0
        public void Select()
        {
            bool             result       = false;
            BUser            bUser        = new BUser();
            EUser            eUser        = new EUser();
            EUser            selectedUser = 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);

            selectedUser = bUser.Select(eUser);
            if (selectedUser == null)
            {
                bUser.Insert(eUser);
                selectedUser = bUser.Select(eUser);
            }

            if (selectedUser != null &&
                selectedUser.CodeUser == eUser.CodeUser &&
                selectedUser.Name == eUser.Name &&
                selectedUser.State == eUser.State)
            {
                result = true;
            }

            Assert.AreEqual(result, true);
        }
Esempio n. 5
0
        public void Select()
        {
            bool             result          = false;
            BAudit           bAudit          = new BAudit();
            List <EAudit>    listAudit       = new List <EAudit>();
            BClient          bClient         = new BClient();
            EClient          eClient         = new EClient();
            EClient          selectedEClient = 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);

            selectedEClient = bClient.Select(insertedEClient);

            if (selectedEClient != null &&
                selectedEClient.CodeClient == insertedEClient.CodeClient &&
                selectedEClient.SearchName == insertedEClient.SearchName &&
                selectedEClient.State == insertedEClient.State)
            {
                result = true;
            }

            ts.Dispose();

            Assert.IsTrue(result);
        }
Esempio n. 6
0
        public void Select()
        {
            short            routes           = 0;
            string           codeSequence     = Aleatory.GetString(8);
            int              correlativo      = Aleatory.GetShort();
            BSequence        bSequence        = new BSequence();
            ESequence        eSequence        = new ESequence(codeSequence, correlativo);
            ESequence        selectedSequence = null;
            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            selectedSequence = bSequence.Select(eSequence);

            if (selectedSequence == null)
            {
                routes++;
            }

            bSequence.Insert(eSequence);
            selectedSequence = bSequence.Select(eSequence);

            if (selectedSequence != null &&
                selectedSequence.CodeSequence == eSequence.CodeSequence &&
                selectedSequence.Correlative == eSequence.Correlative)
            {
                routes++;
            }

            ts.Dispose();

            Assert.AreEqual(routes, 2);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public void Login()
        {
            bool   result;
            short  routes = 0;
            BAudit bAudit = new BAudit();
            BUser  bUser  = new BUser();
            EUser  eUser  = new EUser();

            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);

            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            bUser.Delete(eUser);

            result = bUser.Login(eUser);
            if (result == false &&
                bUser.Message.Contains("usuario") &&
                bUser.Message.Contains("no existe"))
            {
                routes++;
            }

            eUser.State = 0;
            bUser.Insert(eUser);
            result = bUser.Login(eUser);
            if (result == false &&
                bUser.Message.Contains("El usuario") &&
                bUser.Message.Contains("no se encuentra 'Activo'."))
            {
                routes++;
            }

            eUser.State = 1;
            bUser.Update(eUser);
            result = bUser.Login(eUser);
            if (result == true && bUser.Message == "Ok")
            {
                routes++;
            }

            bUser.Delete(eUser);
            eUser.Password = "******";
            bUser.Insert(eUser);
            eUser.Password = "******";
            result         = bUser.Login(eUser);
            if (result == false && bUser.Message == "Password incorrecto.")
            {
                routes++;
            }

            ts.Dispose();

            Assert.AreEqual(routes, 4);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        public void Aleatorio_ConLongitudDefinida()
        {
            Configuration cg = new Configuration();

            cg.SetLength(8);
            Aleatory aleatory = new Aleatory();
            string   c        = aleatory.Generate(cg);

            Assert.False(string.IsNullOrEmpty(c), "No genera código");
        }
Esempio n. 13
0
        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();
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        public void Aleatorio_SinLongitudDefinida()
        {
            Configuration cg       = new Configuration();
            Aleatory      aleatory = new Aleatory();

            try
            {
                string c = aleatory.Generate(cg);
                Assert.False(!string.IsNullOrEmpty(c), "No debe generar código");
            }
            catch (Exception ex)
            {
                return;
            }
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        public void Select()
        {
            bool             result          = false;
            TransactionScope ts              = new TransactionScope();
            EProduct         eProduct        = new EProduct();
            EProduct         insertedProduct = new EProduct();
            BProduct         bProduct        = new BProduct();

            eProduct.DescriptionForSale  = Aleatory.GetString(60);
            eProduct.DescriptionForStore = Aleatory.GetString(60);
            eProduct.Audit.UserRegister  = Aleatory.GetString(8);
            insertedProduct = bProduct.Insert(eProduct);

            if (insertedProduct != null)
            {
                result = true;
            }

            Assert.IsTrue(result);
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        public void GetString()
        {
            bool          result = false;
            List <string> list   = new List <string>();
            List <string> dist   = new List <string>();
            string        value  = string.Empty;

            for (int i = 1; i <= 100; i++)
            {
                value = Aleatory.GetString(5);
                list.Add(value);
            }

            dist = list.Distinct().ToList();

            if (list.Count == dist.Count)
            {
                result = true;
            }

            Assert.IsTrue(result);
        }
Esempio n. 21
0
        public void GetShort()
        {
            bool         result = false;
            List <short> list   = new List <short>();
            List <short> dist   = new List <short>();
            short        value  = 0;

            for (int i = 1; i <= 10; i++)
            {
                value = Aleatory.GetShort();
                list.Add(value);
            }

            dist = list.Distinct().ToList();

            if (list.Count == dist.Count)
            {
                result = true;
            }

            Assert.IsTrue(result);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        public void Insert()
        {
            bool             result           = false;
            string           codeSequence     = Aleatory.GetString(8);
            int              correlativo      = Aleatory.GetShort();
            BSequence        bSequence        = new BSequence();
            ESequence        eSequence        = new ESequence(codeSequence, correlativo);
            ESequence        insertedSequence = null;
            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            bSequence.Insert(eSequence);
            insertedSequence = bSequence.Select(eSequence);

            if (insertedSequence != null &&
                insertedSequence.CodeSequence == eSequence.CodeSequence &&
                insertedSequence.Correlative == eSequence.Correlative)
            {
                result = true;
            }

            ts.Dispose();

            Assert.AreEqual(result, true);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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);
        }