public void Test_CellTemplateIsCalendarCell()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            DataGridViewDateTimeColumn dtColumn = new DataGridViewDateTimeColumn();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CalendarCell), dtColumn.CellTemplate);
        }
Beispiel #2
0
    public MainForm()
    {
        InitializeComponent();
        DataGridView dataGridView1 = new DataGridView();

        this.Controls.Add(dataGridView1);
        dataGridView1.Columns.Clear();
        DataGridViewDateTimeColumn col = new DataGridViewDateTimeColumn();

        dataGridView1.Columns.Add(col);
    }
        public void Test_SetCellTemplate()
        {
            //---------------Set up test pack-------------------
            DataGridViewDateTimeColumn dtColumn = new DataGridViewDateTimeColumn();
            CalendarCell calendarCell           = new CalendarCell();

            //---------------Assert Precondition----------------
            Assert.AreNotSame(calendarCell, dtColumn.CellTemplate);
            //---------------Execute Test ----------------------
            dtColumn.CellTemplate = calendarCell;

            //---------------Test Result -----------------------
            Assert.AreSame(calendarCell, dtColumn.CellTemplate);
        }
        public void Test_SetCellTemplate_MustBeCalendarCell()
        {
            //---------------Set up test pack-------------------
            DataGridViewDateTimeColumn dtColumn = new DataGridViewDateTimeColumn();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool errorThrown = false;

            try
            {
                dtColumn.CellTemplate = new System.Windows.Forms.DataGridViewCheckBoxCell();
            }
            catch (InvalidCastException) { errorThrown = true; }
            //---------------Test Result -----------------------
            Assert.IsTrue(errorThrown, "Cell Template must be type of CalendarCell");
        }