public void SelectionChanged_UnselectIndex_ArgumentIsAsExpected(int row, int column)
        {
            var model = new TableSingleSelectionModel();
            var args = new List<SelectionChangedEventArgs>();
            var expectedArgument = new SelectionChangedEventArgs(row, column, false);
            model.SelectionChanged += (obj, arg) => args.Add(arg);

            model.UnselectIndex(row, column);

            AssertContainsEvent(expectedArgument, args);
        }
Пример #2
0
        public void SelectionChanged_SelectionModelRaisesEventBeforeSetup_IsRaised()
        {
            var selectionModelStub = new Mock<ITableSelectionModel>();
            var table = CreateTable(10, 20, selectionModelStub);
            bool eventWasRaised = false;
            SelectionChangedEventArgs eventArgs = new SelectionChangedEventArgs(5, 4, true);
            table.SelectionChanged += (obj, args) => eventWasRaised = true;

            selectionModelStub.Raise(o => o.SelectionChanged += null, selectionModelStub.Object, eventArgs);

            Assert.True(eventWasRaised);
        }
Пример #3
0
        public void SelectionChanged_SelectionModelRaisesEventBeforeSetup_RightEventArgs()
        {
            var selectionModelStub = new Mock<ITableSelectionModel>();
            var table = CreateTable(10, 20, selectionModelStub);
            SelectionChangedEventArgs eventArgs = new SelectionChangedEventArgs(5, 4, true);
            SelectionChangedEventArgs returnedArgs = null;
            table.SelectionChanged += (obj, args) => returnedArgs = args;

            selectionModelStub.Raise(o => o.SelectionChanged += null, selectionModelStub.Object, eventArgs);

            Assert.NotNull(returnedArgs);
            Assert.AreEqual(eventArgs.Row, returnedArgs.Row);
            Assert.AreEqual(eventArgs.Column, returnedArgs.Column);
            Assert.AreEqual(eventArgs.IsSelected, returnedArgs.IsSelected);
        }
 private void AssertContainsEvent(SelectionChangedEventArgs expectedEvent, List<SelectionChangedEventArgs> args)
 {
     var result = args.Any(v => v.Column == expectedEvent.Column && v.Row == expectedEvent.Row && v.IsSelected == expectedEvent.IsSelected);
     Assert.IsTrue(result);
 }
Пример #5
0
        public void DrawCalledTwice_SelectionChangedRaised_RenderedComponentHasRightSelection()
        {
            var modelStub = new Mock<ITableModel<Object>>();
            var tableRendererMock = new TableRendererMock<Object>();
            var selectionModelStub = new Mock<ITableSelectionModel>();
            SetDimension(modelStub, 10, 20);
            var table = CreateTable(modelStub, tableRendererMock, selectionModelStub);
            int row = 4;
            int column = 5;
            var eventArgs = new SelectionChangedEventArgs(row, column, true);

            table.Setup();
            table.Draw(new SpriteBatchMock());

            selectionModelStub.Setup(o => o.IsSelected(row, column)).Returns(true);
            selectionModelStub.Raise(o => o.SelectionChanged += null, selectionModelStub.Object, eventArgs);
            table.Draw(new SpriteBatchMock());

            var changedComponent = tableRendererMock.components[row, column];
            Assert.True(changedComponent.IsSelected);
        }