public void record_failed_attempt(string ip)
        {
            log_ip_fail ip_attempt = find_attempt_by_ip(ip);

            if (ip_attempt == null)
            {
                ip_attempt = new log_ip_fail(ip);
                _attempts.Add(ip_attempt);
            }
            else
            {
                ip_attempt.Record_Failed_Attempt();
            }
        }
        public void is_ip_lockedTest_users_should_not_lock_out_after_three_attempts_when_time_between_attempts_is_greater_then_needed()
        {
            Service_Manager_Accessor target = new Service_Manager_Accessor();
            string ip = "some address";

            log_ip_fail ip_attempt = new log_ip_fail(ip);
            ip_attempt.Record_Failed_Attempt();
            ip_attempt.Last_Attempt = new DateTime(1990, 3, 3);
            target._attempts.Add(ip_attempt);

            bool expected = false; // account should not be locked
            bool actual;
            actual = target.is_ip_locked(ip);
            Assert.AreEqual(expected, actual);
        }
 public bool is_ip_locked(string ip)
 {
     log_ip_fail ip_attempt = find_attempt_by_ip(ip);
     if (ip_attempt == null  // this ip has never failed an attempt so let it through
         || (ip_attempt.Fail_Count <= _allowed_attempts // allow ip through since it has not been locked by to many fails
         && ip_attempt.Ticks_Since_Last_Failed_Attempt() > _Ticks_between_attempts)) // check to see if lockout time still applies
     {
         return false;   // user is not locked
     }
     else if (_Ticks_until_user_can_unlock < ip_attempt.Ticks_Since_Last_Failed_Attempt())
     {// user's account is locked, but they have reached the time to unlock so reset users data
         ip_attempt = new log_ip_fail(ip);
         return false;
     }
     else
     {
         return true; // user is locked so he cannot access system
     }
 }