public void QueryFormLogicTest_SetDataGridColumns01()
        {
            DataGridView grid = new DataGridView();

            QueryFormLogic cls = new QueryFormLogic();
            cls.SetDataGridColumns(_attributes, grid);

            Assert.AreEqual(3, grid.ColumnCount);
            Assert.AreEqual("attr1", grid.Columns[0].DataPropertyName);
            Assert.AreEqual("attr1", grid.Columns[0].Name);
            Assert.AreEqual("Disp1", grid.Columns[0].HeaderText);
            Assert.AreEqual("attr3", grid.Columns[1].DataPropertyName);
            Assert.AreEqual("attr3", grid.Columns[1].Name);
            Assert.AreEqual("Disp3", grid.Columns[1].HeaderText);
            Assert.AreEqual("attr4", grid.Columns[2].DataPropertyName);
            Assert.AreEqual("attr4", grid.Columns[2].Name);
            Assert.AreEqual("Disp4", grid.Columns[2].HeaderText);
        }
        public void QueryFormLogicTest_SetDataGridValues01()
        {
            List<Entity> entities = new List<Entity>()
            {
                new Entity()
                {
                    Id = new Guid("10000000-0000-0000-0000-000000000001"),
                    Attributes = new AttributeCollection()
                    {
                        {"attr1", "strVal1"},
                        {"attr2", new Money(1000)},
                        {"attr3", new OptionSetValue(1)},
                        {"attr4", new EntityReference("Ref1", new Guid("20000000-0000-0000-0000-000000000001"))}
                    }
                },
                new Entity()
                {
                    Id = new Guid("10000000-0000-0000-0000-000000000002"),
                    Attributes = new AttributeCollection()
                    {
                        {"attr1", "strVal2"},
                        {"attr2", new Money(2000)},
                        {"attr3", new OptionSetValue(2)},
                        {"attr4", new EntityReference("Ref2", new Guid("20000000-0000-0000-0000-000000000002"))}
                    }
                }
            };
            EntityCollection records = new EntityCollection(entities);

            DataGridView grid = new DataGridView();
            grid.AllowUserToAddRows = false;

            _attributes[1].DisplayName = new Microsoft.Xrm.Sdk.Label(new LocalizedLabel("Disp2", LANG_CODE), null);

            QueryFormLogic cls = new QueryFormLogic();
            cls.SetDataGridColumns(_attributes, grid);
            cls.SetOptionSetData(_attributes);
            cls.SetDataGridValues(records, grid);

            Assert.AreEqual(2, grid.RowCount);

            Assert.AreEqual("strVal1", grid.Rows[0].Cells[0].Value);
            Assert.AreEqual(1000, grid.Rows[0].Cells[1].Value);
            Assert.AreEqual("list1", grid.Rows[0].Cells[2].Value);
            Assert.AreEqual(new Guid("20000000-0000-0000-0000-000000000001"), grid.Rows[0].Cells[3].Value);

            Assert.AreEqual("strVal2", grid.Rows[1].Cells[0].Value);
            Assert.AreEqual(2000, grid.Rows[1].Cells[1].Value);
            Assert.AreEqual("list2", grid.Rows[1].Cells[2].Value);
            Assert.AreEqual(new Guid("20000000-0000-0000-0000-000000000002"), grid.Rows[1].Cells[3].Value);
        }