public MappingLookup GetAuthorBy(RevisionInfo revision)
        {
            if (!AuthorIsSpecified(revision))
            {
                _logger().Warn(string.Format("No author in revision. Revision ID: {0}", revision.Id));
                return DefaultUser;
            }

            var tpUser = GetTpUserFromMapping(revision);
            var userDtos = StorageRepository().Get<UserDTO>().Where(x => x.DeleteDate == null && x.IsActive == true).ToList();

            if (tpUser != null)
            {
                if (userDtos.FirstOrDefault(x => x.ID.GetValueOrDefault() == tpUser.Id) != null)
                {
                    return tpUser;
                }

                _logger().Warn(string.Format("TP user not found. TargetProcess User ID: {0}; Name: {1}", tpUser.Id, tpUser.Name));
            }

            var user = GuessUser(revision, userDtos);

            if (user != null)
            {
                return user.ConvertToUserLookup();
            }

            _logger().Warn(string.Format("Revision author doesn't match any TP User name. There is no valid mapping for Git user {0}", revision.Author));
            return DefaultUser;
        }
        private static string GetKey(RevisionInfo revision)
        {
            if (revision.TimeCreated.HasValue)
            {
                return string.Format("{0}#{1}", revision.TimeCreated.Value.Ticks, revision.Comment);
            }

            return revision.Id.Value;
        }
		private static string GetKey(RevisionInfo revision)
		{
			if (revision.TimeCreated.HasValue)
			{
				var key = string.Format("{0}#{1}", revision.TimeCreated.Value.Ticks, revision.Comment);
				return key.Length > 255 ? key.Substring(0, 255) : key;
			}

			return revision.Id.Value;
		}
		public void ShouldGetKeyForCommitWithLongComment()
		{
			var revisionInfo = new RevisionInfo
				                   {
					                   Author = "User1",
					                   Email = "*****@*****.**",
					                   Id = "48588d3bef746129aa66e5fa915da2962a1a4014",
					                   TimeCreated = CurrentDate.Value.AddMonths(-1),
					                   Comment =
						                   "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
				                   };
			var key = GitRevisionStorageRepository.GetKey(revisionInfo);
			key.Length.Should(Be.EqualTo(255));
		}
		public static string GetKey(RevisionInfo revision)
		{
			var result = revision.Id.Value;
			if (revision.TimeCreated.HasValue)
			{
				result = string.Format("{0}#{1}", revision.TimeCreated.Value.Ticks, revision.Comment);
				if (result.Length > 255)
				{
					result = result.Substring(0, 255);
				}
			}

			return result;
		}
        public override bool SaveRevisionInfo(RevisionInfo revision, out string key)
        {
            var revisionKey = GetKey(revision);
            var info = Repository.Get<bool>(revisionKey);
            var revisionIsNew = !info.FirstOrDefault();

            if (revisionIsNew)
            {
                info.ReplaceWith(true);
            }

            key = revisionKey;

            return revisionIsNew;
        }
		protected override UserDTO GuessUser(RevisionInfo revision, IEnumerable<UserDTO> userDtos)
		{
			UserDTO result = null;

			if (AuthorEmailIsSpecified(revision))
			{
				result = userDtos.FirstOrDefault(x => revision.Email.Equals(x.Email, StringComparison.OrdinalIgnoreCase));
			}

			if (result == null && AuthorNameIsSpecified(revision))
			{
				result = userDtos.FirstOrDefault(x => revision.Author.Equals(x.FirstName + " " + x.LastName, StringComparison.OrdinalIgnoreCase)) ??
				         userDtos.FirstOrDefault(x => revision.Author.Equals(x.Login, StringComparison.OrdinalIgnoreCase));
			}

			return result;
		}
		protected override MappingLookup GetTpUserFromMapping(RevisionInfo revision)
		{
			var userMapping = StorageRepository().GetProfile<GitPluginProfile>().UserMapping;
			MappingLookup lookup = null;

			if (AuthorEmailIsSpecified(revision))
			{
				lookup = userMapping[revision.Email];
			}

			if (lookup == null && AuthorNameIsSpecified(revision))
			{
				lookup = userMapping[revision.Author];
			}

			return lookup;
		}
		protected override MappingLookup GetTpUserFromMapping(RevisionInfo revision)
		{
			var userMapping = StorageRepository().GetProfile<TfsPluginProfile>().UserMapping;
			MappingLookup lookup = null;

			if (AuthorNameIsSpecified(revision))
			{
				lookup = userMapping[revision.Author];

				if (lookup != null)
					return lookup;

				var login = GetLogin(revision.Author);

				if (login != null)
					lookup = userMapping[login];
			}

			return lookup;
		}
		protected override UserDTO GuessUser(RevisionInfo revision, IEnumerable<UserDTO> userDtos)
		{
			UserDTO result = null;

			if (AuthorNameIsSpecified(revision))
			{
				result = userDtos.FirstOrDefault(x => revision.Author.Equals(x.ActiveDirectoryName, StringComparison.OrdinalIgnoreCase));

				if (result == null)
				{
					var splittedLogin = revision.Author.Split('\\');

					var login = splittedLogin.Length > 1 ? splittedLogin[1] : splittedLogin[0];
					result = userDtos.FirstOrDefault(x => login.Equals(x.Login, StringComparison.OrdinalIgnoreCase));

					if (result != null)
						return result;

					result = userDtos.FirstOrDefault(x => login.Equals(x.FirstName + " " + x.LastName, StringComparison.OrdinalIgnoreCase));
				}
			}

			return result;
		}
		protected override bool AuthorIsSpecified(RevisionInfo revision)
		{
			return AuthorEmailIsSpecified(revision) || AuthorNameIsSpecified(revision);
		}
 protected abstract UserDTO GuessUser(RevisionInfo revision, IEnumerable<UserDTO> userDtos);
 protected abstract MappingLookup GetTpUserFromMapping(RevisionInfo revision);
 protected abstract bool AuthorIsSpecified(RevisionInfo revision);
		protected override UserDTO GuessUser(RevisionInfo revision, IEnumerable<UserDTO> userDtos)
		{
			return userDtos.FirstOrDefault(x => x.Login.ToLower() == revision.Author.ToLower());
		}
		public abstract bool SaveRevisionInfo(RevisionInfo revision, out string key);
 public void ShouldSupport()
 {
     ObjectFactory.Configure(x => x.For<IActivityLogger>().Use<LogMock>());
     ObjectFactory.Configure(x => x.For<IActionFactory>().Use<ActionFactory>());
     var comment = string.Format("added headerRenderer to WindowShade control{0} added fix to allow CanvasButton to work within a Repeater", Environment.NewLine);
     var info = new RevisionInfo {Comment = comment};
     new CommentParser().ParseAssignToEntityAction(info).Should(Be.Empty);
 }
		public IEnumerable<AssignRevisionToEntityAction> ParseAssignToEntityAction(RevisionInfo revision)
		{
			return ParseAssignToEntityAction(revision.Comment);
		}
		private static bool AuthorEmailIsSpecified(RevisionInfo revision)
		{
			return !string.IsNullOrEmpty(revision.Email);
		}
		protected override bool AuthorIsSpecified(RevisionInfo revision)
		{
			return !string.IsNullOrEmpty(revision.Author);
		}
 public bool IsAuthorMapped(RevisionInfo revision)
 {
     return !GetAuthorBy(revision).Equals(DefaultUser);
 }
		public override bool SaveRevisionInfo(RevisionInfo revision, out string key)
		{
			key = revision.Id.Value;

			return true;
		}
		protected override MappingLookup GetTpUserFromMapping(RevisionInfo revision)
		{
			return ObjectFactory.GetInstance<ISourceControlConnectionSettingsSource>().UserMapping[revision.Author];
		}