コード例 #1
0
        public void SetFacets_NoProfileUrl_ShouldReturnFalse(IWebClient webClient, Contact xdbContact, IXdbContext xdbContext)
        {
            // Arrange
            var userProfile  = Substitute.For <Sitecore.Security.UserProfile>();
            var facetUpdater = new AvatarFacetUpdater(webClient);

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

            // Assert
            changed.Should().BeFalse();
            xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>());
        }
コード例 #2
0
        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>());
        }
コード例 #3
0
        public void SetFacets_NoAvatar_ShouldSetFacet(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;
            webClient.DownloadData(url).Returns(picture);
            var facetUpdater = new AvatarFacetUpdater(webClient);

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

            // Assert
            changed.Should().BeTrue();
            xdbContext.Received(1).RegisterOperation(Arg.Is <SetFacetOperation>(x =>
                                                                                x.FacetReference.FacetKey == Avatar.DefaultFacetKey &&
                                                                                ((Avatar)x.Facet).Picture == picture &&
                                                                                ((Avatar)x.Facet).MimeType == mimeType));
        }