コード例 #1
0
ファイル: MappingTests.cs プロジェクト: Qasemt/NServiceKit
        public void Does_map_only_properties_with_specified_Attribute()
        {
            var user = new User {
                FirstName = "Demis",
                LastName = "Bellot",
                Car = new Car { Name = "BMW X6", Age = 3 }
            };

            var to = new User();
            to.PopulateFromPropertiesWithAttribute(user, typeof(DataMemberAttribute));

            Assert.That(to.LastName, Is.EqualTo(user.LastName));
            Assert.That(to.FirstName, Is.Null);
            Assert.That(to.Car, Is.Null);
        }
コード例 #2
0
ファイル: MappingTests.cs プロジェクト: Qasemt/NServiceKit
        public void Does_translate()
        {
            var user = new User() {
                FirstName = "Demis",
                LastName = "Bellot",
                Car = new Car() { Name = "BMW X6", Age = 3 }
            };

            var userDto = user.TranslateTo<UserDto>();

            Assert.That(userDto.FirstName, Is.EqualTo(user.FirstName));
            Assert.That(userDto.LastName, Is.EqualTo(user.LastName));
            Assert.That(userDto.Car, Is.EqualTo("{Name:BMW X6,Age:3}"));
        }
コード例 #3
0
ファイル: MappingTests.cs プロジェクト: Qasemt/NServiceKit
        public void Does_translate_to_inherited_propeties()
        {
            var user = new User {
                FirstName = "Demis",
                LastName = "Bellot",
                Car = new Car { Name = "BMW X6", Age = 3 }
            };

            var to = user.TranslateTo<SubUserFields>();
            Assert.That(to.FirstName, Is.EqualTo(user.FirstName));
            Assert.That(to.LastName, Is.EqualTo(user.LastName));
            Assert.That(to.Car.Name, Is.EqualTo(user.Car.Name));
            Assert.That(to.Car.Age, Is.EqualTo(user.Car.Age));
        }
コード例 #4
0
ファイル: MappingTests.cs プロジェクト: Qasemt/NServiceKit
        public void Does_populate()
        {
            var user = new User() {
                FirstName = "Demis",
                LastName = "Bellot",
                Car = new Car() { Name = "BMW X6", Age = 3 }
            };

            var userDto = new UserDto().PopulateWith(user);

            Assert.That(userDto.FirstName, Is.EqualTo(user.FirstName));
            Assert.That(userDto.LastName, Is.EqualTo(user.LastName));
            Assert.That(userDto.Car, Is.EqualTo("{Name:BMW X6,Age:3}"));
        }