Esempio n. 1
0
        public void Test_SetSelectedBOToNull_ShouldRaiseSelectedEvent()
        {
            //---------------Set up test pack-------------------
            var gridView = new DataGridView();

            gridView.Columns.Add("FakeStringProp", "FakeStringProp");
            var dataGridViewAdapter = new WinFormsGridBaseAdapter(gridView);
            var gridBaseManager     = new GridBaseManagerBindingList(dataGridViewAdapter);

            var boCol = GetBusinessObjectCollectionWith3Items();

            gridBaseManager.SetBusinessObjectCollection(boCol);
            PlaceGridOnForm(gridView);
            gridView.Rows[0].Selected = true;
            IBusinessObject selectedBO         = boCol[0];
            bool            selectedEventFired = false;

            gridBaseManager.BusinessObjectSelected += (sender, args) =>
            {
                selectedEventFired = true;
                selectedBO         = args.BusinessObject;
            };
            //---------------Assert Precondition----------------
            Assert.AreSame(boCol[0], selectedBO);
            Assert.IsFalse(selectedEventFired);
            //---------------Execute Test ----------------------
            gridBaseManager.SelectedBusinessObject = null;
            //---------------Test Result -----------------------
            Assert.IsTrue(selectedEventFired);
            Assert.IsNull(selectedBO);
        }
Esempio n. 2
0
        public void Test_SetSelectedBOToNull_ShouldSet()
        {
            //---------------Set up test pack-------------------
            var gridView = new DataGridView();

            gridView.Columns.Add("FakeStringProp", "FakeStringProp");
            var dataGridViewAdapter = new WinFormsGridBaseAdapter(gridView);
            var gridBaseManager     = new GridBaseManagerBindingList(dataGridViewAdapter);

            var boCol = GetBusinessObjectCollectionWith3Items();

            gridBaseManager.SetBusinessObjectCollection(boCol);
            PlaceGridOnForm(gridView);
            gridView.Rows[0].Selected = true;
            //---------------Assert Precondition----------------
            Assert.AreSame(boCol[0], gridBaseManager.SelectedBusinessObject);
            //---------------Execute Test ----------------------
            gridBaseManager.SelectedBusinessObject = null;
            //---------------Test Result -----------------------
            Assert.IsNull(gridBaseManager.SelectedBusinessObject);
            Assert.IsFalse(gridView.Rows[0].Selected);
        }