Beispiel #1
0
        public async Task GetCurrentContactAsync_CorrectEnvironment_GetsAndSetsContact(string userName, string expectedCallingUserName)
        {
            // Arrange
            var expectedContact = new ContactInfo
            {
                ContactLastName = "TestContact"
            };

            mCurrectContactProvider.GetCurrentContact(Arg.Any <IUserInfo>(), false).Returns(expectedContact);

            // Act
            var result = await mContactTrackingService.GetCurrentContactAsync(userName);

            // Assert
            CMSAssert.All(
                () => Assert.That(result, Is.SameAs(expectedContact), "Result contact should be the same as the expected one"),
                () => mCurrectContactProvider.Received(1).GetCurrentContact(Arg.Any <IUserInfo>(), Arg.Any <bool>()),
                () => mCurrectContactProvider.Received(1).SetCurrentContact(Arg.Any <ContactInfo>())
                );
        }
Beispiel #2
0
        public void Evaluate_NoContactGroupSelected_ReturnsCorrectResult(int contactId, Constraint result)
        {
            var currentContact = ContactInfo.Provider.Get(contactId);

            currentContactProvider.GetCurrentContact(Arg.Any <IUserInfo>(), Arg.Any <bool>())
            .Returns(currentContact);

            var evaluatorEmpty = new IsInContactGroupConditionType
            {
                SelectedContactGroups = new List <string>()
            };

            var evaluatorNull = new IsInContactGroupConditionType
            {
                SelectedContactGroups = null
            };

            Assert.Multiple(() =>
            {
                Assert.That(() => evaluatorEmpty.Evaluate(), result);
                Assert.That(() => evaluatorNull.Evaluate(), result);
            });
        }
        /// <summary>
        /// Get a contact for a user and decide whether to merge matching activities.
        /// </summary>
        /// <param name="userName">User name of the user to get a contact for</param>
        /// <param name="forceMatching">Merge matched activities to contact</param>
        /// <returns><see cref="ContactInfo"/> returned for the user.</returns>
        private async Task <ContactInfo> GetContactAsync(string userName, bool forceMatching)
        {
            if (!mContactProcessingChecker.CanProcessContactInCurrentContext())
            {
                return(null);
            }

            var userInfo = await GetCurrentUserInfoAsync(userName);

            var currentContact = mCurrentContactProvider.GetCurrentContact(userInfo, forceMatching);

            mCurrentContactProvider.SetCurrentContact(currentContact);

            return(currentContact);
        }
Beispiel #4
0
        private void SetCustomerRelationAndUpdateContact(CustomerInfo customerInfo)
        {
            if (mCurrentContactProvider == null)
            {
                return;
            }

            var currentContact = mCurrentContactProvider.GetCurrentContact(MembershipContext.AuthenticatedUser, false);

            mCurrentContactProvider.SetCurrentContact(currentContact);

            Service.Entry <IContactRelationAssigner>().Assign(MemberTypeEnum.EcommerceCustomer, customerInfo, currentContact, true);
            ContactInfoProvider.UpdateContactFromExternalData(
                customerInfo,
                DataClassInfoProvider.GetDataClassInfo(CustomerInfo.TYPEINFO.ObjectClassName).ClassContactOverwriteEnabled,
                currentContact.ContactID);
        }
Beispiel #5
0
        /// <summary>
        /// Get a contact for a user and decide whether to merge matching activities.
        /// </summary>
        /// <param name="userName">User name of the user to get a contact for</param>
        /// <param name="forceMatching">Merge matched activities to contact</param>
        /// <returns><see cref="ContactInfo"/> returned for the user.</returns>
        private async Task <ContactInfo> GetContactAsync(string userName, bool forceMatching)
        {
            var currentSite         = (SiteInfo)mSiteService.CurrentSite;
            var requestDependencies = GetRequestDependencies();

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

            var userInfo = await GetCurrentUserInfoAsync(userName);

            var currentContact = mCurrentContactProvider.GetCurrentContact(userInfo, forceMatching);

            mCurrentContactProvider.SetCurrentContact(currentContact);

            return(currentContact);
        }