Пример #1
0
        public void GetSelectionRegion_GetRowsIndex_SucessScenario()
        {
            // select two ranges:
            // * from row 1 to 10
            // * from row 21 to 30
            //
            // Assert that grid.Selection.GetSelectionRegion().GetRowsIndex();
            // returns correct row indexes

            Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);

            grid.Selection.SelectRange(new Range(1, 0, 10, 0), true);
            grid.Selection.SelectRange(new Range(21, 0, 30, 0), true);

            int[] indexes = grid.Selection.GetSelectionRegion().GetRowsIndex();
            Assert.AreEqual(20, indexes.Length);

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i + 1, indexes[i]);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(20 + i + 1, indexes[i + 10]);
            }
        }
Пример #2
0
        public void UnselectRegion()
        {
            // select two ranges:
            // * from row 1 to 10
            // * from row 21 to 30
            //
            // Assert that grid.Selection.GetSelectionRegion().GetRowsIndex();
            // returns correct row indexes

            Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);

            grid.Selection.SelectRange(new Range(1, 0, 3, 0), true);
            Assert.AreEqual(true, grid.Selection.IsSelectedRow(2));
            grid.Selection.SelectRange(new Range(2, 0, 2, 0), false);
            Assert.AreEqual(false, grid.Selection.IsSelectedRow(2));
        }
Пример #3
0
        public void GetSelectionRegion_ReturnsContiguousRanges()
        {
            // select two ranges:
            // * from row 1 to 100
            // * from row 501 to 600
            //
            // Assert that grid.Selection.GetSelectionRegion() returns
            // only 2 ranges, not 200

            Grid grid = new TestRowSelectionHelper().CreateGridWithRows(30);

            grid.Selection.SelectRange(new Range(1, 0, 2, 0), true);
            grid.Selection.SelectRange(new Range(21, 0, 22, 0), true);

            RangeRegion region = grid.Selection.GetSelectionRegion();

            Assert.AreEqual(2, region.Count);
            Assert.AreEqual(new Range(1, 0, 2, 0), region[0]);
            Assert.AreEqual(new Range(21, 0, 22, 0), region[1]);
        }
		public void GetSelectionRegion_GetRows_Index_Performance()
		{
			// select range:
			// * from row 1 to 2000
			// Print out how long in seconds that function takes to execute
			
			// The tests take seconds to execute
			// 6 seconds, 2008-12-11, AMD Athlon 64 X2 dual machine
			// 0 seconds, 2008-12-11, AMD Athlon 64 X2 dual machine
			
			Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);

			grid.Selection.SelectRange(new Range(0, 0, 1999, 1), true);
			
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				grid.Selection.GetSelectionRegion().GetRowsIndex();
				
				Console.WriteLine(string.Format(
					"Test executed in {0} seconds", counter.GetSeconds()));
			}
		}
Пример #5
0
		public void GetSelectionRegion_MergeRanges()
		{
			// select two ranges:
			// * from row 1 to 100
			// * from row 501 to 600
			//
			// Assert that grid.Selection.GetSelectionRegion() returns
			// only 2 ranges, not 200
			
			Grid grid = new TestRowSelectionHelper().CreateGridWithRows(30);
	
			grid.Selection.SelectRange(new Range(1, 0, 1, 0), true);
			grid.Selection.SelectRange(new Range(2, 0, 2, 0), true);
			
			grid.Selection.SelectRange(new Range(20, 0, 20, 0), true);
			grid.Selection.SelectRange(new Range(21, 0, 21, 0), true);
			
			RangeRegion region = grid.Selection.GetSelectionRegion();
			Assert.AreEqual(2, region.Count);
			Assert.AreEqual(new Range(1, 0, 2, 0), region[0]);
			Assert.AreEqual(new Range(20, 0, 21, 0), region[1]);
		}
Пример #6
0
		public void GetSelectionRegion_GetRowsIndex_SucessScenario()
		{
			// select two ranges:
			// * from row 1 to 10
			// * from row 21 to 30
			//
			// Assert that grid.Selection.GetSelectionRegion().GetRowsIndex();
			// returns correct row indexes
			
			Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);
	
			grid.Selection.SelectRange(new Range(1, 0, 10, 0), true);
			grid.Selection.SelectRange(new Range(21, 0, 30, 0), true);
			
			int[] indexes = grid.Selection.GetSelectionRegion().GetRowsIndex();
			Assert.AreEqual(20, indexes.Length);
			
			for (int i = 0; i < 10; i++)
			{
				Assert.AreEqual(i + 1, indexes[i]);
			}
			
			for (int i = 0; i < 10; i++)
			{
				Assert.AreEqual(20 + i + 1, indexes[i + 10]);
			}
		}
Пример #7
0
		public void UnselectRegion()
		{
			// select two ranges:
			// * from row 1 to 10
			// * from row 21 to 30
			//
			// Assert that grid.Selection.GetSelectionRegion().GetRowsIndex();
			// returns correct row indexes
			
			Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);
	
			grid.Selection.SelectRange(new Range(1, 0, 3, 0), true);
			Assert.AreEqual(true, grid.Selection.IsSelectedRow(2));
			grid.Selection.SelectRange(new Range(2, 0, 2, 0), false);
			Assert.AreEqual(false, grid.Selection.IsSelectedRow(2));
			
		}