public static string GetUserAlias(this ITeamFoundationIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            if (identity.Descriptor.Identifier.Contains("@"))
            {
                var identifier      = identity.Descriptor.Identifier;
                var identifierSplit = identifier.Split('\\');

                if (identifierSplit.Length == 2)
                {
                    return(identifierSplit[1].Split('@')[0]);
                }
            }
            else
            {
                var uniqueName      = identity.UniqueName;
                var uniqueNameSplit = uniqueName.Split('\\');
                if (uniqueNameSplit.Length == 2)
                {
                    return(uniqueNameSplit[1]);
                }
            }

            return(null);
        }
예제 #2
0
        partial void RemoveProperty_PreCondition(ITeamFoundationIdentity instance, ref String name)
        {
            name = "TestingProperty";
            var value = "TestingValue";

            instance.SetProperty(name, value);
        }
예제 #3
0
        /// <summary>
        ///     Gets the user account name from the specified <see cref="ITeamFoundationIdentity" /> instance.
        /// </summary>
        /// <param name="identity">An instance of <see cref="ITeamFoundationIdentity" />.</param>
        /// <returns>
        ///     The value of the <see cref="IdentityAttributeTags.AccountName" /> property; otherwise,
        ///     <see cref="IdentityFieldValue.AccountName" />.
        /// </returns>
        public static string GetUserAccountName(this ITeamFoundationIdentity identity)
        {
            if (identity == null)
            {
                return(null);
            }

            return(identity.GetAttribute(IdentityAttributeTags.AccountName, null) ?? new IdentityFieldValue(identity).AccountName);
        }
예제 #4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="IdentityFieldValue" /> class.
        /// </summary>
        /// <param name="identity">The identity.</param>
        /// <exception cref="ArgumentNullException">identity</exception>
        public IdentityFieldValue([NotNull] ITeamFoundationIdentity identity)
            : this(identity.DisplayName, identity.Descriptor?.Identifier, identity.TeamFoundationId.ToString())
        {
            Contract.Requires(identity != null);

            if (identity == null)
            {
                throw new ArgumentNullException(nameof(identity));
            }
        }
예제 #5
0
        public void GetAuthenticatedIdentity_UnitTest()
        {
            ITeamFoundationIdentity identity = default(ITeamFoundationIdentity);

            ExecuteMethod(
                () => { return((ITfsConnection)GetInstance()); },
                instance =>
            {
                identity = TeamFoundationIdentityImpl_UnitTests.GetInstance();
                GetAuthenticatedIdentity_PreCondition(instance, ref identity);
            },
                instance => { instance.GetAuthenticatedIdentity(out identity); },
                instance => { GetAuthenticatedIdentity_PostValidate(instance, identity); });
        }
 partial void IsContainer_SetCondition(ref ITeamFoundationIdentity instance, ref Boolean setValue);
 partial void UniqueName_SetCondition(ref ITeamFoundationIdentity instance, ref String setValue);
 partial void TryGetProperty_PostValidate(ITeamFoundationIdentity instance, String name, Object value);
 partial void SetAttribute_PreCondition(ITeamFoundationIdentity instance, ref String name, ref String value);
 partial void RemoveProperty_PreCondition(ITeamFoundationIdentity instance, ref String name);
예제 #11
0
 partial void SetProperty_PostValidate(ITeamFoundationIdentity instance, String name, Object value)
 {
     instance.RemoveProperty(IIdentityPropertyScope.Local, name);
 }
예제 #12
0
 partial void SetProperty_PreCondition(ITeamFoundationIdentity instance, ref String name, ref Object value)
 {
     name  = "TestingProperty";
     value = "TestingValue";
 }
예제 #13
0
 partial void GetProperty_PreCondition(ITeamFoundationIdentity instance, ref String name)
 {
     name = "Account";
 }
예제 #14
0
 /// <summary>
 ///     Gets the authenticated identity.
 /// </summary>
 /// <param name="identity">The identity.</param>
 /// <exception cref="ToBeImplementedException"></exception>
 void ITfsConnection.GetAuthenticatedIdentity(out ITeamFoundationIdentity identity)
 {
     throw new ToBeImplementedException();
 }
예제 #15
0
 /// <summary>
 ///     Gets the user account (logon) name from the specified <see cref="ITeamFoundationIdentity" /> instance.
 /// </summary>
 /// <param name="identity">An instance of <see cref="ITeamFoundationIdentity" />.</param>
 /// <returns>
 ///     <see cref="IdentityFieldValue.LogonName" />
 /// </returns>
 public static string GetUserAlias(this ITeamFoundationIdentity identity)
 {
     return(identity == null ? null : new IdentityFieldValue(identity).LogonName);
 }
 partial void Members_SetCondition(ref ITeamFoundationIdentity instance, ref IIdentityDescriptor[] setValue);
 partial void RemoveProperty_PostValidate(ITeamFoundationIdentity instance, String name);
 partial void AuthorizedIdentity_SetCondition(ref IIServerDataProvider instance, ref ITeamFoundationIdentity setValue);
 partial void SetAttribute_PostValidate(ITeamFoundationIdentity instance, String name, String value);
예제 #20
0
 partial void GetAuthenticatedIdentity_PostValidate(ITfsConnection instance, ITeamFoundationIdentity identity);
 partial void TeamFoundationId_SetCondition(ref ITeamFoundationIdentity instance, ref Guid setValue);
예제 #22
0
 partial void GetAuthenticatedIdentity_PreCondition(ITfsConnection instance, ref ITeamFoundationIdentity identity);
 partial void TryGetProperty_PreCondition(ITeamFoundationIdentity instance, ref String name, ref Object value);
 partial void GetProperties_PostValidate(ITeamFoundationIdentity instance);
 partial void UniqueUserId_SetCondition(ref ITeamFoundationIdentity instance, ref Int32 setValue);
 partial void GetProperties_PreCondition(ITeamFoundationIdentity instance);
 public override void When()
 {
     ActualIdentity = IdentityService.GetIdentityForAlias(Alias, MockIdentityDescriptor.TenantId, MockIdentityDescriptor.Domain, "otherdomain");
 }
예제 #28
0
 public override void When()
 {
     _result = Instance.ReadIdentity(IdentitySearchFactor.AccountName, _input, MembershipQuery.Expanded);
 }