コード例 #1
0
        public void CheckProperlySet_OfSocialShareButton_FromControllerToModel()
        {
            var socialShareOptions = new List<SocialShareGroup>
                {
                    new SocialShareGroup(new List<SocialShareOption>
                        {
                            new SocialShareOption("Facebook", true),
                            new SocialShareOption("Twitter", true),
                            new SocialShareOption("GooglePlusOne", true),
                            new SocialShareOption("LinkedIn", true),
                            new SocialShareOption("SocialShareMode", false)
                        }),
                };

            // Arrange
            using (var controller = new DummySocialShareController(socialShareOptions))
            {
                // Act
                controller.Index();

                // Assert
                Assert.IsTrue(controller.Model.SocialButtons.Count == 4);

                foreach (SocialShareOption option in socialShareOptions.SelectMany(s => s.Groups))
                {
                    var button = controller.Model.SocialButtons.FirstOrDefault(b => b.ButtonName == option.Key);

                    if (!option.IsChecked)
                    {
                        Assert.IsNull(button);
                    }
                    else
                    {
                        Assert.IsNotNull(button);
                    }
                }
            }
        }
コード例 #2
0
        public void CheckProperlySet_OfSocialShareButton_PassedFromClient()
        {
            string selectedSocialButtons = "[{\"__type\":\"Telerik.Sitefinity.Frontend.SocialShare.Mvc.Models.SocialShareGroupMap, Telerik.Sitefinity.Frontend.SocialShare\",\"Groups\":[{\"Key\":\"Facebook\",\"Label\":\"Facebook\",\"IsChecked\":true,\"$$hashKey\":\"object:15\"},{\"Key\":\"Twitter\",\"Label\":\"Twitter\",\"IsChecked\":false,\"$$hashKey\":\"object:16\"},{\"Key\":\"GooglePlusOne\",\"Label\":\"Google +\",\"IsChecked\":true,\"$$hashKey\":\"object:17\"},{\"Key\":\"StumbleUpon\",\"Label\":\"Stumble Upon\",\"IsChecked\":true,\"$$hashKey\":\"object:18\"},{\"Key\":\"GoogleBookmarks\",\"Label\":\"Google bookmarks\",\"IsChecked\":true,\"$$hashKey\":\"object:19\"}],\"$$hashKey\":\"object:9\"}}]";

            var socialShareOptions = new List<SocialShareGroup>
                {
                    new SocialShareGroup(new List<SocialShareOption>
                        {
                            new SocialShareOption("Facebook", true),
                            new SocialShareOption("GooglePlusOne", true),
                            new SocialShareOption("StumbleUpon", true),
                            new SocialShareOption("GoogleBookmarks", true)
                        }),
                };

            // Arrange
            using (var controller = new DummySocialShareController())
            {
                controller.SerializedSocialShareOptionsList = selectedSocialButtons;

                // Act
                controller.Index();

                // Assert
                Assert.IsTrue(controller.Model.SocialButtons.Count == 4);

                foreach (SocialShareOption option in socialShareOptions.SelectMany(s => s.Groups))
                {
                    var button = controller.Model.SocialButtons.FirstOrDefault(b => b.ButtonName == option.Key);

                    Assert.IsNotNull(button);
                }
            }
        }
コード例 #3
0
        public void CreateSocialShare_CallTheIndexAction_EnsuresTheDefaultViewIsReturned()
        {
            // Arrange
            using (var controller = new DummySocialShareController())
            {
                // Act
                var view = controller.Index() as ViewResult;

                // Assert
                Assert.AreEqual("SocialShare", view.ViewName, "The view name is not correct.");
            }
        }