Exemple #1
0
        public void Mapping_Property_Assign_To_DataRow()
        {
            // Source
            var source = new MockPerson()
            {
                Name = "NCsoft 1", Age = 11
            };

            // Target
            var target = new DataTable();

            target.Columns.Add("Name", typeof(string));
            target.Columns.Add("Age", typeof(int));

            var mapping1 = new MappingProviderForProperty(source);
            var mapping2 = new MappingProviderForDataRow(target);

            mapping1.AssignTo(mapping2);

            var row = target.Rows[0];

            TestContext.WriteLine("Name:{0}, Age:{1}", row["Name"], row["Age"]);

            Assert.AreEqual("NCsoft 1", row["Name"]);
            Assert.AreEqual(11, row["Age"]);
        }
        public MappingProviderForDataTable(DataTable dt)
        {
            this.dt          = dt;
            this.maxRow      = dt.Rows.Count;
            this.innerMapper = new MappingProviderForDataRow(this.dt);

            this.Initialize();
        }
Exemple #3
0
        public void MappingDataRow()
        {
            var dt = new DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Age", typeof(int));
            dt.Rows.Add("NCsoft 1", 11);

            var mapping = new MappingProviderForDataRow(dt.Rows[0]);

            TestContext.WriteLine(mapping.Getter("Name").ToString());
            Assert.AreEqual("NCsoft 1", mapping.Getter("Name"));
            Assert.AreEqual(11, mapping.Getter("Age"));

            mapping.Setter("Name", "Junil, Um");
            TestContext.WriteLine(mapping.Getter("Name").ToString());
            Assert.AreEqual("Junil, Um", mapping.Getter("Name"));
        }
Exemple #4
0
        public void Mapping_DataRow_Assign_To_Property()
        {
            var source = new DataTable();

            source.Columns.Add("Name", typeof(string));
            source.Columns.Add("Age", typeof(int));
            source.Rows.Add("NCsoft 1", 11);

            var target = new MockPerson();

            var mapping1 = new MappingProviderForDataRow(source.Rows[0]);
            var mapping2 = new MappingProviderForProperty(target);

            mapping1.AssignTo(mapping2);

            TestContext.WriteLine("Name:{0}, Age:{1}", target.Name, target.Age);

            Assert.AreEqual("NCsoft 1", target.Name);
            Assert.AreEqual(11, target.Age);
        }