Пример #1
0
        public void UpdateContactFacets_ShouldUpdateTracker(ITracker tracker, Contact contact, Sitecore.XConnect.Contact xdbContact, IXdbContextFactory xdbContextFactory, IXdbContext xdbContext, IContactManagerService contactManager, IContactFacetUpdater facetUpdater, string source, string identifier)
        {
            // Arrange
            contact.Identifiers.Returns(new List <ContactIdentifier>
            {
                new ContactIdentifier(source, identifier, ContactIdentificationLevel.Known)
            }.AsReadOnly());
            tracker.Contact.Returns(contact);
            xdbContext.GetAsync <Sitecore.XConnect.Contact>(Arg.Any <IdentifiedContactReference>(), Arg.Any <ContactExpandOptions>()).Returns(Task.FromResult(xdbContact));
            xdbContextFactory.CreateContext().Returns(xdbContext);
            var userProfile = Substitute.For <Sitecore.Security.UserProfile>();

            facetUpdater.SetFacets(userProfile, xdbContact, xdbContext).Returns(true);
            var facetsService = new UpdateContactFacetsService(xdbContextFactory, contactManager, new List <IContactFacetUpdater> {
                facetUpdater
            });

            // Act
            using (new TrackerSwitcher(tracker))
            {
                facetsService.UpdateContactFacets(userProfile);
            }

            // Assert
            contactManager.Received(1).SaveContact();
            contactManager.Received(1).ReloadContact();
        }