TryGetCurrentUser() public method

public TryGetCurrentUser ( ) : User
return User
        public  void TestInitialize()
        {
            if (Membership.CurrentUser == null)
            {
                UserRepository repository = new UserRepository();
                User user = new User();
                user = repository.TryGetCurrentUser();
                if (user == null)
                {
                    user = new User();
                    user.Name = LoginViewModelTest.LOGIN;
                    user.Password = LoginViewModelTest.PASSWORD;
                    Server server = new Server();
                    server.Address = LoginViewModelTest.SERVER_PATH;
                    user.ID = 0;
                    user.Server = server;
                    user.IsCurrent = true;
                    repository.AddNewUser(user);
                }

                Membership.CheckUserData(user.Name, user.Password, user.Server.Address, this.OnUserAuthenticated);
            }
        }
 static Membership()
 {
     using (var userRepository = new UserRepository())
         CurrentUser = userRepository.TryGetCurrentUser();
 }