public void Integration_LogControlContext_CreateControlCatOperator_NoIndex_Exception()
        {

            // Create new customer
            // context object LogControlContext matches the same name used for Logqso DB
            using (IDataContextAsync context = new ContestqsoContext())
            using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
            {
                bool caught = false;
                IRepositoryAsync<CatOperator> CatOperatorRepository = new Repository<CatOperator>(context, unitOfWork);
                var CatOperator = new CatOperator
                {
                    CatOperatorEnum = (int)CatOperatorEnum.SINGLE_OP,
                    CatOprName = CatOprName,
                    ObjectState = ObjectState.Added,
                };

                try
                {
                    CatOperatorRepository.Insert(CatOperator);
                    unitOfWork.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException)
                {

                }
                catch (System.Data.Entity.Core.UpdateException)
                {
                    //caught = true;
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException)
                {
                    caught = true;
                }

                Assert.IsTrue(caught);
            }
        }
        public void Integration_LogControlContext_CreateControlCatOperator_ValidIndex_Exception_Duplicate_Key()
        {

            // Create new customer
            // context object LogControlContext matches the same name used for Logqso DB
            using (IDataContextAsync context = new ContestqsoContext())
            using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
            {
                bool caught = false;
                IRepositoryAsync<CatOperator> CatOperatorRepository = new Repository<CatOperator>(context, unitOfWork);
                var CatOperator = new CatOperator
                {
                    CatOperatorEnum = (int)CatOperatorEnum.SINGLE_OP,
                    CatOprName = CatOprName,
                    Index = 2,
                    ObjectState = ObjectState.Added,
                };

                try
                {
                    CatOperatorRepository.Insert(CatOperator);
                    unitOfWork.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException)
                {

                }
                catch (System.Data.Entity.Core.UpdateException)
                {
                    //caught = true;
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException)
                {
                    caught = true;
                }

                Assert.IsTrue(caught);

            }


            ////  Query for newly created CatOperator by ID from a new context, to ensure it's not pulling from cache
            //using (IDataContextAsync context = new LogControlContext())
            //using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
            //{
            //    IRepositoryAsync<CatOperator> CatOperatorRepository = new Repository<CatOperator>(context, unitOfWork);
            //    var Query = CatOperatorRepository.Query(c => c.CatOprName == CatOprName);
            //    var list = Query.Select(c=>c.CatOprName);
            //    //Query.Select().

            //    //var CatOperator1 = (CatOperatorRepository.Query(c => c.CatOprName == CatOprName);
            //    //if (CatOperator1 != null)
            //    //{
            //    //    var CatOperator2 = CatOperatorRepository.Find(CatOperator1);
            //    //    Assert.AreEqual(CatOperator2.CatOprName, CatOprName);
            //    //}
            //    //Assert.AreEqual(CatOperator1.CatOprName, CatOprName); 
            //}

        }