public void ToBindingListViewTest()
        {
            TestToBindingListView(MetaDataHelper.GetPropertiesToDisplay(typeof(AddressTypeEntity)));
            TestToBindingListView(((IEntity)MetaSingletons.MetaData.AddressType.First()).CustomPropertiesOfType);
            var addressTypeEntityCollection = MetaSingletons.MetaData.AddressType.ToEntityCollection();
            var list = TestToBindingListView(addressTypeEntityCollection.DefaultView);

            Assert.AreEqual(addressTypeEntityCollection.DefaultView, list);

            Assert.AreEqual(addressTypeEntityCollection.DefaultView, TestToBindingListView(addressTypeEntityCollection));
            CollectionAssert.AreEqual(addressTypeEntityCollection, TestToBindingListView(addressTypeEntityCollection.AsQueryable()));
            CollectionAssert.AreEqual(addressTypeEntityCollection, TestToBindingListView(addressTypeEntityCollection.Cast <CommonEntityBase>()));

            TestToBindingListView(MetaSingletons.MetaData.AddressType);

            var dataTable = TestData.GetAddressTypeDataTable();

            Assert.AreEqual(dataTable.DefaultView, TestListSourceToBindingListView(dataTable));

            var enumerable = Enumerable.Range(1, 100);
            var actual     = TestToBindingListView(enumerable);

            CollectionAssert.AreEqual(enumerable.ToList(), actual);

            Assert.IsNull("A string".ToBindingListView());

            Assert.IsNull((new[] { "s1", "s2", "s3" }).ToBindingListView());

            TestToBindingListView(SerializableClass.GenerateList().ToBindingListView());
        }
 public void EditInDataGridViewTest()
 {
     TestShowInGrid(NonSerializableClass.GenerateList());
     TestShowInGrid(SerializableClass.GenerateList());
     TestShowInGrid(SerializableClass.GenerateListWithBoth());
     TestShowInGrid(SerializableBaseClass.GenerateList());
     TestShowInGrid(SerializableBaseClass2.GenerateListWithBothSerializableClasses());
     TestEditInDataGridView(null);
     TestShowInGrid(Enumerable.Range(1, 100));
 }
        public void DifferentItemTypesTest()
        {
            var listofNonSerializableClasses = SerializableClass.GenerateListWithBothSerializableClasses();
            var bindingSource = new BindingSource();

            Assert.IsTrue(bindingSource.BindEnumerable((IEnumerable)listofNonSerializableClasses, false));
            Assert.AreEqual(listofNonSerializableClasses, bindingSource.List);

            TestBindEnumerable(listofNonSerializableClasses);
            TestBindEnumerable(SerializableClass.GenerateListWithBoth());
        }
        public void DataTableSurrogateSerializeDeserializeTest()
        {
            TestDataTableSurrogateSerializeDeserialize(GeneralHelper.CopyToDataTable(NonSerializableClass.GenerateList()));
            TestDataTableSurrogateSerializeDeserialize(GeneralHelper.CopyToDataTable(SerializableClass.GenerateList()));
            var dt = new DataSet();
            var addressTypeEntityCollection = MetaSingletons.MetaData.AddressType.ToEntityCollection();

            addressTypeEntityCollection.CreateHierarchicalProjection(dt);
            TestDataTableSurrogateSerializeDeserialize(dt.Tables[0]);
            TestDataTableSurrogateSerializeDeserialize(GeneralHelper.CopyToDataTable(MetaDataHelper.GetPropertiesToDisplay(typeof(AddressTypeEntity))));
            //TestDataTableSurrogateSerializeDeserialize(GeneralHelper.CopyToDataTable(MetaSingletons.MetaData.AddressType));
        }
        public void BindEnumerableTest()
        {
            var addressTypeEntityCollection = MetaSingletons.MetaData.AddressType.ToEntityCollection();

            Assert.AreEqual(addressTypeEntityCollection.DefaultView, TestBindEnumerable(addressTypeEntityCollection));
            Assert.AreEqual(addressTypeEntityCollection.DefaultView, TestBindEnumerable(addressTypeEntityCollection.DefaultView));

            TestBindEnumerable(MetaSingletons.MetaData.AddressType);

            TestBindEnumerable(TestData.GetAddressTypeDataTable().DefaultView);

            TestBindEnumerable((IEnumerable)SerializableClass.GenerateList());
            TestBindEnumerable(SerializableClass.GenerateList());
        }
        public static string GetTestxmlString()
        {
            var x = new XmlSerializer(typeof(List <SerializableClass>));
            var s = new MemoryStream();

            x.Serialize(s, SerializableClass.GenerateList());

            //	var serializableClassDataTable = GeneralHelper.CopyToDataTable(SerializableClass.GenerateList());
            //var sw = new StringWriter();
            //var xmltw = new XmlTextWriter(sw);
            //
            //		serializableClassDataTable.WriteXml( s, XmlWriteMode.IgnoreSchema);

            DataSet ds = GetAddressTypeDataSet();

            return(ds.GetXml());
        }
        public void GetEnumerableItemTypeTest()
        {
            Assert.AreEqual(typeof(int), MetaDataHelper.GetEnumerableItemType(new List <int>()));
            Assert.AreEqual(typeof(int), MetaDataHelper.GetEnumerableItemType((new List <int> {
                1, 2, 3, 4
            }).Where(i => i > 2)));
            Assert.AreEqual(typeof(AddressTypeEntity), MetaDataHelper.GetEnumerableItemType(new AddressTypeCollection()));
            Assert.AreEqual(typeof(AddressTypeEntity), MetaDataHelper.GetEnumerableItemType(MetaSingletons.MetaData.AddressType));
            Assert.AreEqual(typeof(int), MetaDataHelper.GetEnumerableItemType(new ArrayList {
                1, 2, 3
            }));
            Assert.AreEqual(typeof(object), MetaDataHelper.GetEnumerableItemType(new ArrayList()));

            Assert.AreEqual(typeof(string), MetaDataHelper.GetEnumerableItemType(new string[0]));
            var emptySerializableClasses = new SerializableClass[0];

            Assert.AreEqual(typeof(SerializableClass), MetaDataHelper.GetEnumerableItemType(emptySerializableClasses));
            Assert.AreEqual(typeof(SerializableClass), MetaDataHelper.GetEnumerableItemType(emptySerializableClasses.Take(30)));
        }