Пример #1
0
        public void UserNameRequired()
        {
            var model = new User();

             var required = AttributeHelper.GetRequiredAttribute( () => model.UserName );

             Assert.IsNotNull( required );
        }
Пример #2
0
 private void AssertUsersEqual( User expected, User actual )
 {
     Assert.AreEqual( expected.Id, actual.Id );
      Assert.AreEqual( expected.FirstName, actual.FirstName );
      Assert.AreEqual( expected.LastName, actual.LastName );
      Assert.AreEqual( expected.UserName, actual.UserName );
 }
Пример #3
0
        private void SetupCurrentUser()
        {
            _userIdentity = new Mock<IIdentity>();
             _principal = new Mock<IPrincipal>();
             _principal.SetupGet( x => x.Identity ).Returns( _userIdentity.Object );

             _user = WorkItems.ModelData.First( x => x.AssignedToUser != null ).AssignedToUser;
             _userIdentity
            .SetupGet( x => x.Name )
            .Returns( _user.UserName );
        }
        private void SetupCurrentUser()
        {
            _userIdentity = new Mock<IIdentity>();
             _principal = new Mock<IPrincipal>();
             _principal.SetupGet( x => x.Identity ).Returns( _userIdentity.Object );

             // In other places where we use a random user, we use the first active one.
             // Use the next active user.
             var firstActiveUser = Users.ModelData.First( x => x.StatusCd == 'A' );
             _user = Users.ModelData.First( x => x.StatusCd == 'A' && x.Id != firstActiveUser.Id );
             _userIdentity
            .SetupGet( x => x.Name )
            .Returns( _user.UserName );
        }
Пример #5
0
 private EditUserViewModel CreateNewEditViewModel( User model )
 {
     return new EditUserViewModel()
      {
     Id = model.Id,
     UserName = model.UserName,
     FirstName = model.FirstName,
     MiddleName = model.MiddleName,
     LastName = model.LastName,
     IsActive = (model.StatusCd == 'A')
      };
 }
Пример #6
0
        private void SetupCurrentUser()
        {
            _userIdentity = new Mock<IIdentity>();
             _principal = new Mock<IPrincipal>();
             _principal.SetupGet( x => x.Identity ).Returns( _userIdentity.Object );

             var userInfo = WorkItemHistories.ModelData
            .GroupBy( x => x.LastModifiedUser.Id )
            .Select( g => new { Id = g.Key, EntryCount = g.Count() } )
            .OrderBy( x => x.EntryCount )
            .Last();

             _user = Users.ModelData.Single( x => x.Id == userInfo.Id );
             _userIdentity
            .SetupGet( x => x.Name )
            .Returns( _user.UserName );
        }