Esempio n. 1
0
        public void MapFromEntityTest()
        {
            var mapper   = TypeMapper.Instance <User> .Mapper;
            var table    = CreateTable();
            var id       = GA.CreateMockValue <long>();
            var username = GA.CreateMockValue <string>();
            var status   = GA.CreateMockValue <UserStatus>();

            table.Rows.Add(id, username, status);
            var row = table.Rows[0];
            var u   = mapper.From(row).To(new User());

            Assert.Equal(id, u.Id);
            Assert.Equal(username, u.Username);
            Assert.Equal(status, u.Status);

            u.Id       = 5;
            u.Username = "******";
            u.Status   = UserStatus.Actived;

            mapper.From(u).To(row);
            Assert.Equal(row["Id"], u.Id);
            Assert.Equal(row["Username"], u.Username);
            Assert.Equal(row["Status"], (int)u.Status);
        }
Esempio n. 2
0
        public void MapFromDataRowTest()
        {
            var mapper   = TypeMapper.Instance <User> .Mapper;
            var table    = CreateTable();
            var id       = GA.CreateMockValue <long>();
            var username = GA.CreateMockValue <string>();
            var status   = GA.CreateMockValue <UserStatus>();

            table.Rows.Add(id, username, status);

            var u = mapper.From(table.Rows[0]).To(new User());

            Assert.Equal(id, u.Id);
            Assert.Equal(username, u.Username);
            Assert.Equal(status, u.Status);
        }