コード例 #1
0
 /// <summary>
 /// Convert User to User public profile
 /// </summary>
 /// <param name="user">User</param>
 /// <returns>User Public Profile</returns>
 public static UserPublicProfile Convert(this Abc.Services.Data.UserPublicProfile user)
 {
     return(new UserPublicProfile()
     {
         CreatedOn = user.CreatedOn,
         UserName = user.UserName,
         Gravatar = user.Gravatar,
         AbcHandle = user.Handle,
         PreferedProfile = user.PreferedProfile,
         Points = user.Points,
         Word = user.Word,
     });
 }
コード例 #2
0
        public void ConvertPublicProfile()
        {
            var user = new Abc.Services.Data.UserPublicProfile()
            {
                CreatedOn       = DateTime.UtcNow,
                UserName        = StringHelper.ValidString(),
                Gravatar        = StringHelper.ValidString(),
                Handle          = StringHelper.ValidString(),
                PreferedProfile = true,
            };

            var profile = user.Convert();

            Assert.IsNotNull(profile);
            Assert.AreEqual <DateTime>(user.CreatedOn, profile.CreatedOn);
            Assert.AreEqual <string>(user.UserName, profile.UserName);
            Assert.AreEqual <string>(user.Handle, profile.AbcHandle);
            Assert.AreEqual <string>(user.Gravatar, profile.Gravatar);
            Assert.IsTrue(profile.PreferedProfile);
        }