private static IWinFormsGridBaseAdapter GetGridBaseAdapter(DataGridView gridView) { IWinFormsGridBaseAdapter gridBaseAdapter = new WinFormsGridBaseAdapter(gridView); gridView.Columns.Add("ff", "fdfd"); return(gridBaseAdapter); }
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); }
public void Test_Constuct_ShouldSetWrappedControl() { //---------------Set up test pack------------------- var expectedWrappedControl = GenerateStub <DataGridView>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IWinFormsGridBaseAdapter gridBaseAdapter = new WinFormsGridBaseAdapter(expectedWrappedControl); //---------------Test Result ----------------------- Assert.AreSame(expectedWrappedControl, gridBaseAdapter.WrappedControl); }
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); }