public void DefaultCommandTimeOutNotWorking()
        {
            string connectionString = String.Format(
                "metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=MySql.Data.MySqlClient; provider connection string=\"{0};Use Default Command Timeout For EF=true; Default Command Timeout=5;\"", GetConnectionString(true));

            //EntityConnection connection = new EntityConnection(connectionString);

            using (testEntities context = new testEntities(connectionString))
            {
                Author a = new Author();
                a.Id   = 66; // special value to indicate the routine should take 30 seconds
                a.Name = "Test name";
                a.Age  = 44;
                context.AddToAuthors(a);
                try
                {
                    context.SaveChanges();
                    Assert.Fail("This should have timed out");
                }
                catch (Exception ex)
                {
                    Exception innerException = ex.InnerException;
                    Assert.AreEqual("Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.", innerException.Message);
                }
            }
        }
예제 #2
0
        public void Insert()
        {
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Authors", st.conn);
            DataTable        dt = new DataTable();

            da.Fill(dt);
            int count = dt.Rows.Count;

            using (testEntities context = new testEntities())
            {
                Author a = new Author();
                a.Id   = 23;
                a.Name = "Test name";
                a.Age  = 44;
                context.AddToAuthors(a);
                context.SaveChanges();
            }

            dt.Clear();
            da.Fill(dt);
            Assert.Equal(count + 1, dt.Rows.Count);
            Assert.Equal(23, dt.Rows[count]["id"]);
        }
예제 #3
0
        public void CommandTimeout()
        {
            string connectionString = String.Format(
                "metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=MySql.Data.MySqlClient; provider connection string=\"{0};default command timeout=5\"", st.GetConnectionString(true));
            EntityConnection connection = new EntityConnection(connectionString);

            using (testEntities context = new testEntities(connection))
            {
                Author a = new Author();
                a.Id   = 66; // special value to indicate the routine should take 30 seconds
                a.Name = "Test name";
                a.Age  = 44;
                context.AddToAuthors(a);
                try
                {
                    context.SaveChanges();
                    //Assert.Fail("This should have timed out");
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }
            }
        }