Beispiel #1
0
        public void SetUp()
        {
            var provider = Fake <ContactInfo, ContactInfoProvider>();

            contact = new ContactInfo
            {
                ContactID = CONTACT_ID,
            };
            var contactInPersona = new ContactInfo
            {
                ContactID        = CONTACT_WITH_PERSONA_ID,
                ContactPersonaID = PERSONA_ID
            };

            provider.WithData(contactInPersona, contact);

            Fake <ScoreInfo, ScoreInfoProvider>().WithData(
                new ScoreInfo
            {
                ScoreID          = SCORE_ID,
                ScoreName        = "TestScore",
                ScoreDisplayName = "Test Score",
                ScoreEnabled     = true,
                ScorePersonaID   = PERSONA_ID
            });

            Fake <PersonaInfo, PersonaInfoProvider>().WithData(
                new PersonaInfo
            {
                PersonaID              = PERSONA_ID,
                PersonaDisplayName     = "Test Persona",
                PersonaName            = PERSONA_NAME,
                PersonaEnabled         = true,
                PersonaPointsThreshold = 1
            },
                new PersonaInfo
            {
                PersonaID              = OTHER_PERSONA_ID,
                PersonaDisplayName     = "Other Persona",
                PersonaName            = OTHER_PERSONA_NAME,
                PersonaEnabled         = true,
                PersonaPointsThreshold = 1
            });

            var user = Substitute.For <CurrentUserInfo>();

            MembershipContext.AuthenticatedUser = user;

            service = Substitute.For <ICurrentContactProvider>();
            service.GetExistingContact(Arg.Any <IUserInfo>(), Arg.Any <bool>()).Returns(contactInPersona);
            Service.Use <ICurrentContactProvider>(service);

            checker = Substitute.For <IContactProcessingChecker>();
            checker.CanProcessContactInCurrentContext().Returns(true);
            Service.Use <IContactProcessingChecker>(checker);

            EnsureServiceContainer();
        }
Beispiel #2
0
        public void Evaluate_IsNotInPersona_ReturnsFalse()
        {
            service.GetExistingContact(Arg.Any <IUserInfo>(), Arg.Any <bool>()).Returns(contact);

            var condition = new IsInPersonaConditionType {
                PersonaName = PERSONA_NAME
            };

            Assert.That(condition.Evaluate(), Is.False);
        }
        /// <summary>
        /// Returns <see cref="ContactInfo"/> from persistent storage. If <see cref="ContactInfo"/> is not found, the service tries to obtain it based on
        /// <see cref="ContactMembershipInfo"/> with given <paramref name="userName"/>.
        /// </summary>
        /// <remarks>
        /// This method has no effect and returns <c>null</c> if the feature is disabled or unavailable in the license. Contact is not returned for crawler requests.
        /// </remarks>
        /// <param name="userName">User name of the <see cref="UserInfo"/> to get the <see cref="ContactInfo"/> for</param>
        /// <returns><see cref="ContactInfo"/> for the user from persistent storage. Returns <c>null</c> if the feature is unavailable or disabled.</returns>
        public async Task <ContactInfo> GetExistingContactAsync(string userName = null)
        {
            if (!mContactProcessingChecker.CanProcessContactInCurrentContext())
            {
                return(null);
            }

            var userInfo = await GetCurrentUserInfoAsync(userName);

            return(mCurrentContactProvider.GetExistingContact(userInfo, false));
        }
Beispiel #4
0
        /// <summary>
        /// Returns <see cref="ContactInfo"/> from persistent storage. If <see cref="ContactInfo"/> is not found, the service tries to obtain it based on
        /// <see cref="ContactMembershipInfo"/> with given <paramref name="userName"/>.
        /// </summary>
        /// <remarks>
        /// This method has no effect and returns <c>null</c> if the feature is disabled or unavailable in the license. Contact is not returned for crawler requests.
        /// </remarks>
        /// <param name="userName">User name of the <see cref="UserInfo"/> to get the <see cref="ContactInfo"/> for</param>
        /// <returns><see cref="ContactInfo"/> for the user from persistent storage. Returns <c>null</c> if the feature is unavailable or disabled.</returns>
        public async Task <ContactInfo> GetExistingContactAsync(string userName = null)
        {
            var currentSite         = (SiteInfo)mSiteService.CurrentSite;
            var requestDependencies = GetRequestDependencies();

            if (!CheckEnabled(currentSite, requestDependencies))
            {
                return(null);
            }

            var userInfo = await GetCurrentUserInfoAsync(userName);

            return(mCurrentContactProvider.GetExistingContact(userInfo, false));
        }
Beispiel #5
0
        public void SetUp()
        {
            var provider = Fake <ContactInfo, ContactInfoProvider>();

            contact = new ContactInfo
            {
                ContactID = CONTACT_ID,
            };
            contactInContactGroup = new ContactInfo
            {
                ContactID = CONTACT_IN_CONTACT_GROUP_ID,
            };
            provider.WithData(contactInContactGroup, contact);

            Fake <ContactGroupInfo, ContactGroupInfoProvider>().WithData(
                new ContactGroupInfo
            {
                ContactGroupID          = CONTACT_GROUP_ID,
                ContactGroupName        = CONTACT_GROUP_NAME,
                ContactGroupDisplayName = "Test Group"
            }
                );
            Fake <ContactGroupMemberInfo, ContactGroupMemberInfoProvider>().WithData(
                new ContactGroupMemberInfo
            {
                ContactGroupMemberID             = 1,
                ContactGroupMemberContactGroupID = CONTACT_GROUP_ID,
                ContactGroupMemberRelatedID      = CONTACT_IN_CONTACT_GROUP_ID,
                ContactGroupMemberType           = ContactGroupMemberTypeEnum.Contact
            }
                );

            var user = Substitute.For <CurrentUserInfo>();

            MembershipContext.AuthenticatedUser = user;

            currentContactProvider = Substitute.For <ICurrentContactProvider>();
            currentContactProvider.GetExistingContact(Arg.Any <IUserInfo>(), Arg.Any <bool>()).Returns(contactInContactGroup);
            Service.Use <ICurrentContactProvider>(currentContactProvider);

            checker = Substitute.For <IContactProcessingChecker>();
            checker.CanProcessContactInCurrentContext().Returns(true);
            Service.Use <IContactProcessingChecker>(checker);

            Service.Use <IContactInfoProvider>(ContactInfo.Provider);

            EnsureServiceContainer();
        }