public void SetFacets_NoProfilePhone_ShouldReturnFalse(Contact xdbContact, IXdbContext xdbContext)
        {
            // Arrange
            var userProfile  = Substitute.For <Sitecore.Security.UserProfile>();
            var facetUpdater = new PhoneFacetUpdater();

            // Act
            var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext);

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }
        public void SetFacets_NoChanges_ShouldReturnFalse(Contact xdbContact, IXdbContext xdbContext, string phone)
        {
            // Arrange
            var userProfile = Substitute.For <Sitecore.Security.UserProfile>();

            userProfile[Accounts.Constants.UserProfile.Fields.PhoneNumber] = phone;
            Sitecore.XConnect.Serialization.DeserializationHelpers.SetFacet(xdbContact, PhoneNumberList.DefaultFacetKey, new PhoneNumberList(new PhoneNumber(null, phone), null));
            var facetUpdater = new PhoneFacetUpdater();

            // Act
            var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext);

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }
Beispiel #3
0
        public void SetFacets_NoChanges_ShouldReturnFalse(Contact xdbContact, IXdbContext xdbContext, string email)
        {
            // Arrange
            var userProfile = Substitute.For <Sitecore.Security.UserProfile>();

            userProfile.Email.Returns(email);
            Sitecore.XConnect.Serialization.DeserializationHelpers.SetFacet(xdbContact, EmailAddressList.DefaultFacetKey, new EmailAddressList(new EmailAddress(email, false), null));
            var facetUpdater = new EmailFacetUpdater();

            // Act
            var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext);

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }
        public void SetFacets_SameAvatar_ShouldReturnFalse(IWebClient webClient, Contact xdbContact, IXdbContext xdbContext, string url, string mimeType, byte[] picture)
        {
            // Arrange
            var userProfile = Substitute.For <Sitecore.Security.UserProfile>();

            userProfile[Accounts.Constants.UserProfile.Fields.PictureUrl]      = url;
            userProfile[Accounts.Constants.UserProfile.Fields.PictureMimeType] = mimeType;
            Sitecore.XConnect.Serialization.DeserializationHelpers.SetFacet(xdbContact, Avatar.DefaultFacetKey, new Avatar(mimeType, picture));
            webClient.DownloadData(url).Returns(picture);
            var facetUpdater = new AvatarFacetUpdater(webClient);

            // Act
            var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext);

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }
        private void SetFacets_SameValue_ShouldReturnFalse(Contact xdbContact, IXdbContext xdbContext, string profileKey, string value, Action <PersonalInformation> setValue)
        {
            // Arrange
            var userProfile = Substitute.For <Sitecore.Security.UserProfile>();

            userProfile[profileKey] = value;
            var personalInformation = new PersonalInformation();

            setValue(personalInformation);
            Sitecore.XConnect.Serialization.DeserializationHelpers.SetFacet(xdbContact, PersonalInformation.DefaultFacetKey, personalInformation);
            var facetUpdater = new PersonalInformationFacetUpdater();

            // Act
            var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext);

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }