public void Test_CreateUIGrid_ShouldReturnNewUIDef()
 {
     //---------------Set up test pack-------------------
     var gridCreator = new UIGridCreator(GetFactory());
     IClassDef classDef = typeof(FakeBo).MapClass();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);
     //---------------Test Result -----------------------
     Assert.IsNotNull(returnedUIGrid);
 }
        public void Test_Construct_ShouldConstruct()
        {
            //---------------Set up test pack-------------------
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var gridCreator = new UIGridCreator(GetFactory());
            //---------------Test Result -----------------------
            Assert.IsNotNull(gridCreator);
        }
        public void Test_CreateUIGrid_ShouldReturnNewUIDef()
        {
            //---------------Set up test pack-------------------
            var       gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid);
        }
        public void Test_Construct_ShouldConstruct()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var gridCreator = new UIGridCreator(GetFactory());

            //---------------Test Result -----------------------
            Assert.IsNotNull(gridCreator);
        }
        public void Test_CreateUIGrid_ShouldCreateFilterDefForGrid()
        {
            //---------------Set up test pack-------------------
            var gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef = typeof(FakeBo).MapClass();
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid.FilterDef);
        }
        public void Test_CreateUIGrid_ShouldCreateFilterDefForGrid()
        {
            //---------------Set up test pack-------------------
            var       gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid.FilterDef);
        }
        public void Test_CreateUIGrid_WhenClassDefHasOnePropAndOnePKProp_ShouldCreateFilterDefWithOneFilterPropertyDef()
        {
            //---------------Set up test pack-------------------
            var gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef = typeof(FakeBo).MapClass();
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, returnedUIGrid.FilterDef.FilterPropertyDefs.Count);
            Assert.AreEqual("Fake Bo Name", returnedUIGrid.FilterDef.FilterPropertyDefs[0].Label);
            Assert.AreEqual("FakeBoName", returnedUIGrid.FilterDef.FilterPropertyDefs[0].PropertyName);
        }
        public void Test_CreateUIGrid_WhenClassDefHasOnePropAndOnePKProp_ShouldCreateFilterDefWithOneFilterPropertyDef()
        {
            //---------------Set up test pack-------------------
            var       gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, returnedUIGrid.FilterDef.FilterPropertyDefs.Count);
            Assert.AreEqual("Fake Bo Name", returnedUIGrid.FilterDef.FilterPropertyDefs[0].Label);
            Assert.AreEqual("FakeBoName", returnedUIGrid.FilterDef.FilterPropertyDefs[0].PropertyName);
        }
        public void Test_CreateGridInfo_TwoProperty_ShouldHaveAppropriateColumnInfo()
        {
            //---------------Set up test pack-------------------
            IClassDef     classDef    = typeof(FakeBoW2Props).MapClass();
            UIGridCreator gridCreator = new UIGridCreator(GetFactory());

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(bool), classDef.PropDefcol["FakeBoName2"].PropertyType);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid);
            Assert.AreEqual(2, returnedUIGrid.Count);
            AssertGridColumnTypeIsTextBox(returnedUIGrid[0]);
            AssertGridColumnTypeIsCheckBox(returnedUIGrid[1]);
        }
        public void Test_CreateUIGrid_WhenNotHasViewAndHasStringProp_ShouldCreateGridColumn()
        {
            //---------------Set up test pack-------------------
            var gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef = typeof(FakeBo).MapClass();
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);
            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid);
            Assert.AreEqual(1, returnedUIGrid.Count, "Should create Column");

            var returnedUIGridColumn = returnedUIGrid[0];
            Assert.AreEqual("Fake Bo Name", returnedUIGridColumn.Heading);
            Assert.AreEqual("FakeBoName", returnedUIGridColumn.PropertyName);
            Assert.AreEqual(PropAlignment.left, returnedUIGridColumn.Alignment, "Alignment should be left by default");
            Assert.AreEqual(100, returnedUIGridColumn.Width, "Width should be 100 by default");
            Assert.IsTrue(returnedUIGridColumn.Editable, "Grid Column Should be editable by default");
        }
        public void Test_CreateUIGrid_With2Props_ShouldCreate2GridColumns()
        {
            //---------------Set up test pack-------------------
            var       gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBoW2Props).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            Assert.AreEqual(3, classDef.PropDefcol.Count, "2 Props and IDProp");
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);
            //---------------Test Result -----------------------
            IUIGridColumn uiFormField1 = returnedUIGrid[0];

            Assert.AreEqual("Fake Bo Name", uiFormField1.Heading);
            Assert.AreEqual("FakeBoName", uiFormField1.PropertyName);

            IUIGridColumn uiFormField2 = returnedUIGrid[1];

            Assert.AreEqual("Fake Bo Name 2", uiFormField2.Heading);
            Assert.AreEqual("FakeBoName2", uiFormField2.PropertyName);
        }
        public void Test_CreateUIGrid_WhenNotHasViewAndHasStringProp_ShouldCreateGridColumn()
        {
            //---------------Set up test pack-------------------
            var       gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIGrid);
            Assert.AreEqual(1, returnedUIGrid.Count, "Should create Column");

            var returnedUIGridColumn = returnedUIGrid[0];

            Assert.AreEqual("Fake Bo Name", returnedUIGridColumn.Heading);
            Assert.AreEqual("FakeBoName", returnedUIGridColumn.PropertyName);
            Assert.AreEqual(PropAlignment.left, returnedUIGridColumn.Alignment, "Alignment should be left by default");
            Assert.AreEqual(100, returnedUIGridColumn.Width, "Width should be 100 by default");
            Assert.IsTrue(returnedUIGridColumn.Editable, "Grid Column Should be editable by default");
        }
        public void Test_CreateUIGrid_With2Props_ShouldCreate2GridColumns()
        {
            //---------------Set up test pack-------------------
            var gridCreator = new UIGridCreator(GetFactory());
            IClassDef classDef = typeof(FakeBoW2Props).MapClass();
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            Assert.AreEqual(3, classDef.PropDefcol.Count, "2 Props and IDProp");
            //---------------Execute Test ----------------------
            IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);
            //---------------Test Result -----------------------
            IUIGridColumn uiFormField1 = returnedUIGrid[0];
            Assert.AreEqual("Fake Bo Name", uiFormField1.Heading);
            Assert.AreEqual("FakeBoName", uiFormField1.PropertyName);

            IUIGridColumn uiFormField2 = returnedUIGrid[1];
            Assert.AreEqual("Fake Bo Name 2", uiFormField2.Heading);
            Assert.AreEqual("FakeBoName2", uiFormField2.PropertyName);
        }
 public void Test_CreateGridInfo_TwoProperty_ShouldHaveAppropriateColumnInfo()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = typeof(FakeBoW2Props).MapClass();
     UIGridCreator gridCreator = new UIGridCreator(GetFactory());
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(bool), classDef.PropDefcol["FakeBoName2"].PropertyType);
     //---------------Execute Test ----------------------
     IUIGrid returnedUIGrid = gridCreator.CreateUIGrid(classDef);
     //---------------Test Result -----------------------
     Assert.IsNotNull(returnedUIGrid);
     Assert.AreEqual(2, returnedUIGrid.Count);
     AssertGridColumnTypeIsTextBox(returnedUIGrid[0]);
     AssertGridColumnTypeIsCheckBox(returnedUIGrid[1]);
 }