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"]);
        }
Exemple #2
0
        public MappingProviderForCollection(IList <TModel> list)
        {
            this.list   = list;
            this.maxRow = list.Count;

            innerMapper = new MappingProviderForProperty(this.CreateNewInstance(), StringComparer.OrdinalIgnoreCase);

            this.Initialize();
        }
        public void ShouldBe_Fire_Exception_Why_Not_Exists_Property_Possible_Mapping_Name_Test()
        {
            var watcher = Stopwatch.StartNew();

            var source = new Temp_SourceClass()
            {
                UserName = "******"
            };

            var target = new Temp_TargetClass();

            var sourceMapping = new MappingProviderForProperty(source);
            var targetMapping = new ParamPropertyMappingProvider(target);

            sourceMapping.AssignTo(targetMapping);
        }
Exemple #4
0
        public void MappingProperty()
        {
            var person = new MockPerson()
            {
                Name = "NCsoft 1", Age = 11
            };

            var mapping = new MappingProviderForProperty(person);

            mapping.Setter("Name", "Junil, Um");
            mapping.Setter("Age", 255);
            var obj1 = mapping.Getter("Name");

            Console.WriteLine(obj1);
            Console.WriteLine(person.Name);

            Assert.AreEqual("Junil, Um", mapping.Getter("Name"));
            Assert.AreEqual(255, mapping.Getter("Age"));
        }
Exemple #5
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);
        }