public void BusinessObjectToViewModel_Name()
 {
     var userBo = new UserBo();
     userBo.Name = "abcde";
     UserModel userModel = Mapper.Map<UserBo, UserModel>(userBo);
     Assert.That(userModel.Name, Is.EqualTo(userBo.Name));
 }
 public void BusinessObjectToViewModel_Id()
 {
     var userBo = new UserBo();
     userBo.Id = ObjectId.GenerateNewId();
     UserModel userModel = Mapper.Map<UserBo, UserModel>(userBo);
     Assert.That(userModel.Id.Value, Is.EqualTo(userBo.Id.ToString()));
 }
 public void BusinessObjectToViewModel_Empty_Id()
 {
     var userBo = new UserBo();
     userBo.Id = new ObjectId();
     UserModel userModel = Mapper.Map<UserBo, UserModel>(userBo);
     Assert.That(userModel.Id.Value, Is.EqualTo(string.Empty));
 }
 public void BusinessObjectToViewModel_Email()
 {
     var userBo = new UserBo();
     userBo.Email = "*****@*****.**";
     UserModel userModel = Mapper.Map<UserBo, UserModel>(userBo);
     Assert.That(userModel.Email, Is.EqualTo(userBo.Email));
 }
 public void BusinessObjectToViewModel_Password()
 {
     var userBo = new UserBo();
     userBo.PasswordHash = "abcdef";
     userBo.PasswordSalt = "1234";
     UserModel userModel = Mapper.Map<UserBo, UserModel>(userBo);
     Assert.That(userModel.Password, Is.Null);
 }
        public void MicropostsFollowedByUser()
        {
            var micropostsA = new List<MicropostBo>();
            micropostsA.Add(new MicropostBo { Content = "AaaaaaA"});
            micropostsA.Add(new MicropostBo { Content = "aAAAAAa"});
            var userA = new UserBo {Email = "*****@*****.**", Id = new ObjectId(1,1,1,1), Name = "userA"};
            userA.Microposts.AddRange(micropostsA);

            var micropostsB = new List<MicropostBo>();
            micropostsB.Add(new MicropostBo { Content = "BbbbbbB"});
            var userB = new UserBo { Email = "*****@*****.**", Id = new ObjectId(2, 2, 2, 2), Name = "userB" };
            userB.Microposts.AddRange(micropostsB);
            userB.Following.Add(userA.Id);

            Expect.Call(_repository.FindById<UserBo>(new BoRef())).IgnoreArguments().Return(userA).Repeat.Any();
            _mocks.ReplayAll();

            IMicropostBS micropostBS = new MicropostBS(_repository);
            MicropostsForUserModel result = micropostBS.GetMicropostsForUser(Mapper.Map<UserBo, UserModel>(userB));
            Assert.That(result.Microposts.Count(), Is.EqualTo(3));
        }
 private UserBo CreateUserBo(string name, string email, string hash, string salt)
 {
     var user = new UserBo();
     user.Id = ObjectId.GenerateNewId();
     user.Name = name;
     user.Email = email;
     user.PasswordHash = hash;
     user.PasswordSalt = salt;
     return user;
 }