public void FeatureReceiverAddsWebPartTest()
        {
            using (var context = new SPEmulationContext(Settings.Default.IsolationLevel, Settings.Default.Url))
            {
                if (context.IsolationLevel == IsolationLevel.Fake)
                {
                    var webPartManager = new ShimSPLimitedWebPartManager();
                    new ShimSPWeb(context.Web)
                    {
                        GetLimitedWebPartManagerStringPersonalizationScope = (s, c) =>
                        {
                            return webPartManager;
                        },
                    };

                    webPartManager.WebPartsGet = () =>
                    {
                        var webPartCollection = new ShimSPLimitedWebPartCollection();
                        webPartCollection.ItemGetInt32 = (i) => { return new SalesOrderWebPart(); };

                        return webPartCollection.Instance;
                    };
                }

                var feature = context.Web.Features.FirstOrDefault(f => f.DefinitionId == featureId);
                if (feature == null)
                    context.Web.Features.Add(featureId);

                AssertIfWebpartOnPage(context, true);

                context.Web.Features.Remove(featureId);
            }
        }
        public void FeatureReceiverAddsWebPartTest()
        {
            using (var context = new SPEmulationContext(Settings.Default.IsolationLevel, Settings.Default.Url))
            {
                if (context.IsolationLevel == IsolationLevel.Fake)
                {
                    var webPartManager = new ShimSPLimitedWebPartManager();
                    new ShimSPWeb(context.Web)
                    {
                        GetLimitedWebPartManagerStringPersonalizationScope = (s, c) =>
                        {
                            return(webPartManager);
                        },
                    };

                    webPartManager.WebPartsGet = () =>
                    {
                        var webPartCollection = new ShimSPLimitedWebPartCollection();
                        webPartCollection.ItemGetInt32 = (i) => { return(new SalesOrderWebPart()); };

                        return(webPartCollection.Instance);
                    };
                }

                var feature = context.Web.Features.FirstOrDefault(f => f.DefinitionId == featureId);
                if (feature == null)
                {
                    context.Web.Features.Add(featureId);
                }

                AssertIfWebpartOnPage(context, true);

                context.Web.Features.Remove(featureId);
            }
        }