context: //
  // DataGridViewTextBoxCellTest.cs - Unit tests for
  // System.Windows.Forms.DataGridViewTextBoxCell
  //
  // Author:
  //	Gert Driesen  <drieseng@users.sourceforge.net>
  //
  // Copyright (C) 2007 Gert Driesen
  //
  // Permission is hereby granted, free of charge, to any person obtaining
  // a copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to
  // permit persons to whom the Software is furnished to do so, subject to
  // the following conditions:
  // 
  // The above copyright notice and this permission notice shall be
  // included in all copies or substantial portions of the Software.
  // 
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  //
  
  #if NET_2_0
  
  using System;
  using System.Windows.Forms;
  
  using NUnit.Framework;
  using System.Drawing;
  using System.Threading;
  using System.ComponentModel;
  
  namespace MonoTests.System.Windows.Forms
  {
  	[TestFixture]
  	public class DataGridViewTextBoxCellTest : TestHelper
  	{
  		[Test]
  		public void Value ()
  		{
  			DataGridViewTextBoxCell tbc = new DataGridViewTextBoxCell ();
  			Assert.IsNull (tbc.Value, "#1");
  			tbc.Value = string.Empty;
  			Assert.AreEqual (string.Empty, tbc.Value, "#2");
  			tbc.Value = 5;
  			Assert.AreEqual (5, tbc.Value, "#3");
  			tbc.Value = null;
  			Assert.IsNull (tbc.Value, "#4");
  		}
  
  		[Test]
  		public void ColumnIndex ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (-1, c.ColumnIndex, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (0, dgv.Rows[0].Cells[0].ColumnIndex, "A2");
  		}
  
  		/* font measurement dependent
  		[Test]
  		public void ContentBounds ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (Rectangle.Empty, c.ContentBounds, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (new Rectangle (0, 11, 0, 0), dgv.Rows[0].Cells[0].ContentBounds, "A2");
  		}
  		*/
  
  		[Test]
  		public void ContextMenuStrip ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.ContextMenuStrip, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			ContextMenuStrip cms1 = new ContextMenuStrip ();
  			cms1.Items.Add ("hey");
  
  			ContextMenuStrip cms2 = new ContextMenuStrip ();
  			cms2.Items.Add ("yo");
  
  			dgv.Rows[0].ContextMenuStrip = cms1;
  			Assert.AreEqual (null, dgv.Rows[0].Cells[0].ContextMenuStrip, "A2");
  
  			dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
  			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].ContextMenuStrip, "A3");
  		}
  
  		[Test]
  		public void DataGridView ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.DataGridView, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreSame (dgv, dgv.Rows[0].Cells[0].DataGridView, "A2");
  		}
  
  		[Test]
  		public void DefaultNewRowValue ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.DefaultNewRowValue, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (null, dgv.Rows[0].Cells[0].DefaultNewRowValue, "A2");
  		}
  
  		[Test]
  		public void Displayed ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.Displayed, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Displayed, "A2");
  		}
  
  		[Test]
  		public void EditedFormattedValue ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.EditedFormattedValue, "A1");
  		}
  
  		[Test]
  		public void FormattedValueType ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (typeof (string), c.FormattedValueType, "A1");
  		}
  
  		[Test]
  		public void Frozen ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.Frozen, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Frozen, "A2");
  
  			dgv.Columns[0].Frozen = true;
  			dgv.Rows[0].Frozen = true;
  			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Frozen, "A3");
  		}
  
  		[Test]
  		public void HasStyle ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.HasStyle, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].HasStyle, "A2");
  
  			dgv.Rows[0].Cells[0].Style.BackColor = Color.Orange;
  			Assert.AreEqual (true, dgv.Rows[0].Cells[0].HasStyle, "A3");
  		}
  
  		[Test]
  		public void InheritedState ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (DataGridViewElementStates.ResizableSet, c.InheritedState, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A2");
  
  			dgv.Rows[0].Selected = true;
  			Assert.AreEqual (DataGridViewElementStates.Selected | DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A3");
  
  			dgv.Rows[0].Selected = false;
  			dgv.Columns[0].Selected = true;
  			Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A4");
  		}
  
  		[Test]
  		public void InheritedStyle ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (SystemColors.Window, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A1");
  
  			dgv.DefaultCellStyle.BackColor = Color.Firebrick;
  			Assert.AreEqual (Color.Firebrick, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A2");
  
  			dgv.Columns[0].DefaultCellStyle.BackColor = Color.FloralWhite;
  			Assert.AreEqual (Color.FloralWhite, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A3");
  
  			dgv.RowsDefaultCellStyle.BackColor = Color.DeepPink;
  			Assert.AreEqual (Color.DeepPink, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A4");
  
  			dgv.Rows[0].DefaultCellStyle.BackColor = Color.DeepSkyBlue;
  			Assert.AreEqual (Color.DeepSkyBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A5");
  
  			dgv.Rows[0].Cells[0].Style.BackColor = Color.DodgerBlue;
  			Assert.AreEqual (Color.DodgerBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A6");
  		}
  
  		[Test]
  		public void IsInEditMode ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.IsInEditMode, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].IsInEditMode, "A2");
  		}
  
  		[Test]
  		public void OwningColumn ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.OwningColumn, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreSame (dgv.Columns[0], dgv.Rows[0].Cells[0].OwningColumn, "A2");
  		}
  
  		[Test]
  		public void OwningRow ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (null, c.OwningRow, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreSame (dgv.Rows[0], dgv.Rows[0].Cells[0].OwningRow, "A2");
  		}
  
  		/* Font measurement dependent
  		[Test]
  		public void PreferredSize ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (new Size (-1, -1), c.PreferredSize, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (new Size (21, 20), dgv.Rows[0].Cells[0].PreferredSize, "A2");
  
  			dgv.Rows[0].Cells[0].Value = "bob";
  			Assert.AreEqual (new Size (26, 20), dgv.Rows[0].Cells[0].PreferredSize, "A3");
  
  			dgv.Rows[0].Cells[0].Value = "roasted quail";
  			Assert.AreEqual (new Size (68, 20), dgv.Rows[0].Cells[0].PreferredSize, "A3");
  		}
  		 * */
  
  		[Test]
  		public void ReadOnly ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.ReadOnly, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].ReadOnly, "A2");
  
  			dgv.Rows[0].ReadOnly = true;
  			Assert.AreEqual (true, dgv.Rows[0].Cells[0].ReadOnly, "A3");
  
  			dgv.Rows[0].Cells[0].ReadOnly = false;
  			Assert.AreEqual (false, dgv.Rows[0].Cells[0].ReadOnly, "A4");
  		}
  
  		[Test]
  		public void Resizable ()
  		{
  			DataGridViewCell c = new BaseCell ();
  			Assert.AreEqual (false, c.Resizable, "A1");
  
  			DataGridView dgv = new DataGridView ();
  			dgv.Columns.Add ("hi", "there");
  
  			DataGridViewRow row = new DataGridViewRow ();
  			row.Cells.Add (c);
  			dgv.Rows.Add (row);
  
  			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A2");
  
  
gt: 			dgv.Rows[0].Resizable = DataGridViewTriState.False;