Example #1
0
    /// <summary>
    /// This constructor is used to create Service & Anonymous profiles.
    /// It doesn't work with User profile type.
    /// </summary>
    /// <param name="type">Profile type: Service or Anonymous.</param>
    /// <exception cref="InvalidOperationException">Thrown when User profile
    /// type is specified.</exception>
    private AuthenticatedProfile(ProfileType type)
    {
        if (type == ProfileType.User)
        {
            throw new InvalidOperationException("Cannot create User profile without ProfileId.");
        }

        Type = type;

        if (type == ProfileType.Anonymous)
        {
            ProfileId = ProfileId.Anonymous();
        }

        if (type == ProfileType.Service)
        {
            ProfileId = ProfileId.ForService();
        }

        if (ProfileId == null)
        {
            throw new NotSupportedException($"Unsupported ProfileType: {type}");
        }
    }
Example #2
0
 public void Anonymous_ShouldCreateAnonymousId()
 {
     Assert.Equal(ProfileId.AnonymousUserId, ProfileId.Anonymous().Value);
 }