Esempio n. 1
0
        public void Test_SelectedBusinessObjects_WhenTwoRowsSelected_ShouldReturnItem()
        {
            //---------------Set up test pack-------------------
            var          grid     = GetControlFactory().CreateDataGridView();
            const string propName = "FakeBos";
            var          mapper   = CreateMultipleRelationshipDataGridViewMapper(grid, propName);

            var expectedBO  = new FakeBoWithMultipleRelationship();
            var selectedBo  = expectedBO.FakeBos.CreateBusinessObject();
            var selectedBO2 = expectedBO.FakeBos.CreateBusinessObject();

            AddToForm(grid);
            mapper.BusinessObject = expectedBO;
            grid.Rows[0].Selected = true;
            grid.Rows[1].Selected = true;
            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedBO.FakeBos.Count + 1, grid.Rows.Count, "Include add row");
            Assert.AreEqual(2, grid.SelectedRows.Count);
            //---------------Execute Test ----------------------
            var selectedBusinessObjects = mapper.SelectedBusinessObjects;

            //---------------Test Result -----------------------
            Assert.AreEqual(2, selectedBusinessObjects.Count);
            selectedBusinessObjects.ShouldContain(selectedBo);
            selectedBusinessObjects.ShouldContain(selectedBO2);
        }
        public void Test_BusinessObject()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateDataGridView();

            const string propName = "FakeBos";
            var mapper = CreateMultipleRelationshipDataGridViewMapper(grid, propName);
            var expectedBO = new FakeBoWithMultipleRelationship();
            var fakeBos = expectedBO.FakeBos;
            //---------------Assert PreConditions---------------        
            Assert.IsNull(mapper.BusinessObject);

            //---------------Execute Test ----------------------
            mapper.BusinessObject = expectedBO;
            //---------------Test Result -----------------------
            Assert.AreSame(expectedBO, mapper.BusinessObject);
            Assert.IsInstanceOf<BindingListView<FakeBo>>(grid.DataSource);
            Assert.AreSame(fakeBos, GetBOColFromGrid(grid));
        }
Esempio n. 3
0
        public void Test_BusinessObject()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateReadOnlyGrid();

            const string propName   = "FakeBos";
            var          mapper     = CreateMultipleRelationshipReadOnlyGridMapper(grid, propName);
            var          expectedBO = new FakeBoWithMultipleRelationship();
            var          fakeBos    = expectedBO.FakeBos;

            //---------------Assert PreConditions---------------
            Assert.IsNull(mapper.BusinessObject);

            //---------------Execute Test ----------------------
            mapper.BusinessObject = expectedBO;
            //---------------Test Result -----------------------
            Assert.AreSame(expectedBO, mapper.BusinessObject);
            Assert.IsInstanceOf <BindingListView <FakeBo> >(grid.DataSource);
            Assert.AreSame(fakeBos, GetBOColFromGrid(grid));
        }
Esempio n. 4
0
        public void Test_SetBO_ShouldPopulateGridWithRelatedItems()
        {
            //---------------Set up test pack-------------------
            var          grid     = GetControlFactory().CreateReadOnlyGrid();
            const string propName = "FakeBos";
            var          mapper   = CreateMultipleRelationshipReadOnlyGridMapper(grid, propName);

            var expectedBO = new FakeBoWithMultipleRelationship();

            expectedBO.FakeBos.CreateBusinessObject();
            expectedBO.FakeBos.CreateBusinessObject();
            AddToForm(grid);
            //---------------Assert PreConditions---------------
            Assert.AreEqual(2, expectedBO.FakeBos.Count);
            Assert.AreEqual(0, grid.Rows.Count);
            //---------------Execute Test ----------------------
            mapper.BusinessObject = expectedBO;
            //---------------Test Result -----------------------
            Assert.AreSame(expectedBO.FakeBos, GetBOColFromGrid(grid));
            Assert.AreEqual(expectedBO.FakeBos.Count, grid.Rows.Count);
        }
Esempio n. 5
0
        public void Test_BusinessObject_WhenWasNotNull_WhenNull_ShouldClearDataSource()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateDataGridView();

            const string propName   = "FakeBos";
            var          mapper     = CreateMultipleRelationshipDataGridViewMapper(grid, propName);
            var          expectedBO = new FakeBoWithMultipleRelationship();

            mapper.BusinessObject = expectedBO;
            var fakeBos = expectedBO.FakeBos;

            //---------------Assert PreConditions---------------
            Assert.AreSame(expectedBO, mapper.BusinessObject);
            Assert.AreSame(fakeBos, GetBOColFromGrid(grid));
            //---------------Execute Test ----------------------
            mapper.BusinessObject = null;
            //---------------Test Result -----------------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.IsNull(grid.DataSource);
        }
        public void Test_SelectedBusinessObjects_WhenTwoRowsSelected_ShouldReturnItem()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateDataGridView();
            const string propName = "FakeBos";
            var mapper = CreateMultipleRelationshipDataGridViewMapper(grid, propName);

            var expectedBO = new FakeBoWithMultipleRelationship();
            var selectedBo = expectedBO.FakeBos.CreateBusinessObject();
            var selectedBO2 = expectedBO.FakeBos.CreateBusinessObject();
            AddToForm(grid);
            mapper.BusinessObject = expectedBO;
            grid.Rows[0].Selected = true;
            grid.Rows[1].Selected = true;
            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedBO.FakeBos.Count + 1, grid.Rows.Count, "Include add row");
            Assert.AreEqual(2, grid.SelectedRows.Count);
            //---------------Execute Test ----------------------
            var selectedBusinessObjects = mapper.SelectedBusinessObjects;
            //---------------Test Result -----------------------
            Assert.AreEqual(2, selectedBusinessObjects.Count);
            selectedBusinessObjects.ShouldContain(selectedBo);
            selectedBusinessObjects.ShouldContain(selectedBO2);
        }
        public void Test_SetBO_ShouldPopulateGridWithRelatedItems()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateDataGridView();
            const string propName = "FakeBos";
            var mapper = CreateMultipleRelationshipDataGridViewMapper(grid, propName);

            var expectedBO = new FakeBoWithMultipleRelationship();
            expectedBO.FakeBos.CreateBusinessObject();
            expectedBO.FakeBos.CreateBusinessObject();
            AddToForm(grid);
            //---------------Assert PreConditions---------------            
            Assert.AreEqual(2, expectedBO.FakeBos.Count);
            Assert.AreEqual(0, grid.Rows.Count);
            //---------------Execute Test ----------------------
            mapper.BusinessObject = expectedBO;
            //---------------Test Result -----------------------
            Assert.AreSame(expectedBO.FakeBos, GetBOColFromGrid(grid));
            Assert.AreEqual(expectedBO.FakeBos.Count + 1, grid.Rows.Count, "BOs plus add row");
        }
        public void Test_BusinessObject_WhenWasNotNull_WhenNull_ShouldClearDataSource()
        {
            //---------------Set up test pack-------------------
            var grid = GetControlFactory().CreateReadOnlyGrid();

            const string propName = "FakeBos";
            var mapper = CreateMultipleRelationshipReadOnlyGridMapper(grid, propName);
            var expectedBO = new FakeBoWithMultipleRelationship();
            mapper.BusinessObject = expectedBO;
            var fakeBos = expectedBO.FakeBos;
            //---------------Assert PreConditions---------------        
            Assert.AreSame(expectedBO, mapper.BusinessObject);
            Assert.AreSame(fakeBos, GetBOColFromGrid(grid));
            //---------------Execute Test ----------------------
            mapper.BusinessObject = null;
            //---------------Test Result -----------------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.IsNull(grid.DataSource);
        }