예제 #1
0
 private void SetUpShims()
 {
     shimsContext = ShimsContext.Create();
     guid         = Guid.NewGuid();
     spWeb        = new ShimSPWeb()
     {
         IDGet   = () => guid,
         SiteGet = () => new ShimSPSite()
         {
             IDGet             = () => guid,
             WebApplicationGet = () => new ShimSPWebApplication(),
             RootWebGet        = () => new ShimSPWeb()
         },
         PropertiesGet = () =>
         {
             var propertyBag = new ShimSPPropertyBag();
             var sd          = new ShimStringDictionary(propertyBag);
             sd.ItemGetString = (key) =>
             {
                 return("EPMLive_MyWork_Grid_GlobalViews");
             };
             return(propertyBag);
         }
     }.Instance;
     ShimSqlConnection.AllInstances.Open  = _ => { };
     ShimSqlConnection.AllInstances.Close = _ => { };
     ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = _ => { };
     ShimSPPersistedObject.AllInstances.IdGet = _ => guid;
     ShimCoreFunctions.getReportingConnectionStringGuidGuid = (_, _1) => ConnectionString;
     ShimCoreFunctions.getConfigSettingSPWebString          = (_, _1) => string.Empty;
     threadManager   = new ThreadManager(new DBConnectionManager(spWeb, false));
     activityManager = new ActivityManager(new DBConnectionManager(spWeb, false));
     streamManager   = new StreamManager(new DBConnectionManager(spWeb, false));
 }
        public void PageLoad_RequestNull_FillDataField()
        {
            // Arrange
            ShimSPContext.CurrentGet = () => new ShimSPContext()
            {
                SiteGet = () => new ShimSPSite()
                {
                    RootWebGet = () => new ShimSPWeb()
                    {
                        PropertiesGet = () =>
                        {
                            var propertyBag      = new ShimSPPropertyBag();
                            var stringDictionary = new ShimStringDictionary(propertyBag)
                            {
                                ItemGetString = key => PropertySiteTemplateIds
                            };
                            return(propertyBag);
                        },
                        SiteGet = () => new ShimSPSite()
                        {
                            CatchAccessDeniedExceptionSetBoolean = catchAccess => { }
                        }
                    }
                }
            };

            // Act
            _privateObject.Invoke(PageLoadMethodName, this, EventArgs.Empty);

            // Assert
            var actualData = (string)_privateObject.GetField(DataFieldName);

            actualData.ShouldBe("Request is not available in this context");
        }
예제 #3
0
        public void AddBasicSecurityGroupsTest()
        {
            using (new SPEmulators.SPEmulationContext(SPEmulators.IsolationLevel.Fake))
            {
                var user = new ShimSPUser()
                {
                    IDGet = () =>
                    {
                        return(1073741823);
                    }
                };

                var listitem = new ShimSPListItem()
                {
                    ItemGetGuid = (guid) =>
                    {
                        return(Guid.NewGuid());
                    },
                    IDGet = () =>
                    {
                        return(1);
                    },
                    TitleGet = () =>
                    {
                        return("Adam Bar");
                    },
                    SystemUpdate = () => { }
                    ,
                    FieldsGet = () =>
                    {
                        return(new ShimSPFieldCollection()
                        {
                            GetFieldByInternalNameString = (s) =>
                            {
                                return new ShimSPField()
                                {
                                    IdGet = () => { return Guid.NewGuid(); }
                                };
                            },
                            ItemGetGuid = (guid) =>
                            {
                                return new ShimSPField()
                                {
                                    IdGet = () => { return Guid.NewGuid(); }
                                };
                            }
                        });
                    },
                    ItemSetGuidObject = (a, b) => { },
                    Update            = () => { }
                };

                ShimSPList list = new ShimSPList()
                {
                    ItemsGet = () =>
                    {
                        return(new ShimSPListItemCollection()
                        {
                            GetItemByIdInt32 = (id) =>
                            {
                                return listitem;
                            }
                        });
                    }
                };

                ShimCoreFunctions.AddGroupSPWebStringStringSPMemberSPUserString = (a, b, c, d, e, f) => { return("final"); };

                ShimSPWeb fakespweb = fakespweb = new ShimSPWeb()
                {
                    IDGet = () =>
                    {
                        return(Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03"));
                    },
                    CurrentUserGet = () =>
                    {
                        return(user);
                    },
                    SiteGroupsGet = () =>
                    {
                        return(new ShimSPGroupCollection()
                        {
                            ItemGetString = (id) =>
                            {
                                return new ShimSPGroup()
                                {
                                    NameGet = () => { return Guid.NewGuid().ToString(); }
                                };
                            }
                        });
                    },
                    AllowUnsafeUpdatesSetBoolean = (b) => { },
                    SiteGet = () =>
                    {
                        return(new ShimSPSite()
                        {
                            UrlGet = () =>
                            {
                                return "";
                            },
                            OpenWebGuid = (gg) =>
                            {
                                return new ShimSPWeb()
                                {
                                    IDGet = () =>
                                    {
                                        return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                    },
                                    PropertiesGet = () =>
                                    {
                                        var propertyBag = new ShimSPPropertyBag();
                                        var sd = new ShimStringDictionary(propertyBag);
                                        sd.ItemGetString = (key) =>
                                        {
                                            return "EPMLive_MyWork_Grid_GlobalViews";
                                        };
                                        return propertyBag;
                                    },
                                    SiteGet = () =>
                                    {
                                        return new ShimSPSite()
                                        {
                                            IDGet = () =>
                                            {
                                                return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                            }
                                        };
                                    },
                                    Dispose = () => { },
                                    AllowUnsafeUpdatesSetBoolean = (b) => { }
                                };
                            },
                            RootWebGet = () =>
                            {
                                return new ShimSPWeb()
                                {
                                    ListsGet = () =>
                                    {
                                        return new ShimSPListCollection()
                                        {
                                            ItemGetString = (s) =>
                                            {
                                                return list;
                                            }
                                        };
                                    },
                                    IDGet = () =>
                                    {
                                        return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                    }
                                };
                            }
                        });
                    },
                    ParentWebGet = () =>
                    {
                        return(null);
                    },
                    PropertiesGet = () =>
                    {
                        var propertyBag = new ShimSPPropertyBag();
                        var sd          = new ShimStringDictionary(propertyBag);
                        sd.ItemGetString = (key) =>
                        {
                            return("EPMLiveLockConfig");
                        };
                        return(propertyBag);
                    }
                    ,
                    Update = () => { }
                };
                fakespweb.Dispose = () => { };

                var objSecurityUpdates = new SecurityUpdate();
                var dict = objSecurityUpdates.AddBasicSecurityGroups(fakespweb, "title", user, listitem);

                Assert.IsTrue(dict.Count == 3);
            }
        }
        private ShimSPWeb ArrangeForExecute()
        {
            var list = new List <SPUser>
            {
                new ShimSPUser
                {
                    IDGet    = () => 11,
                    NameGet  = () => "Name",
                    EmailGet = () => "Email"
                }
            };
            var shimSPUserCollection = new ShimSPUserCollection
            {
                GetByIDInt32 = intValue => list[0]
            };

            new ShimSPBaseCollection(shimSPUserCollection)
            {
                GetEnumerator = () => list.GetEnumerator()
            };
            return(new ShimSPWeb
            {
                AllUsersGet = () => shimSPUserCollection,
                ListsGet = () =>
                {
                    var listSpList = new List <SPList>
                    {
                        new ShimSPList
                        {
                            GetItemsSPQuery = spQuery =>
                            {
                                var listSPField = new List <SPField>
                                {
                                    new ShimSPField
                                    {
                                        InternalNameGet = () => "InternalName",
                                        SchemaXmlGet = () => " Percentage=\"TRUE\""
                                    }
                                };
                                var listListItem = new List <SPListItem>
                                {
                                    new ShimSPListItem
                                    {
                                        FieldsGet = () =>
                                        {
                                            var shimSPFieldCollection = new ShimSPFieldCollection
                                            {
                                                GetFieldByInternalNameString = stringValue => listSPField[0]
                                            };
                                            new ShimSPBaseCollection(shimSPUserCollection)
                                            {
                                                GetEnumerator = () => listSPField.GetEnumerator()
                                            };
                                            return shimSPFieldCollection;
                                        },
                                        ItemGetGuid = guidValue => "2018-05-12"
                                    }
                                };
                                var shimSPListItemCollection = new ShimSPListItemCollection
                                {
                                    CountGet = () => listListItem.Count,
                                    GetEnumerator = () => listListItem.GetEnumerator()
                                };
                                return shimSPListItemCollection;
                            }
                        }
                    };
                    var shim = new ShimSPListCollection
                    {
                        ItemGetString = stringValue => listSpList[0]
                    };
                    new ShimSPBaseCollection(shim)
                    {
                        GetEnumerator = () => listSpList.GetEnumerator()
                    };
                    return shim;
                },
                LocaleGet = () => new CultureInfo("en-US"),
                PropertiesGet = () =>
                {
                    var shim = new ShimSPPropertyBag();
                    var stringDictionary = new StringDictionary
                    {
                        ["EPMLiveNotificationLists"] = "notification|notificationC`notification|notificationC`notification|notificationC`notification|notificationC",
                        ["EPMLiveNotificationEmail"] = "EPMLiveNotificationEmail",
                        ["EPMLiveNotificationEmailSubject"] = "EPMLiveNotificationEmailSubject",
                        ["EPMLiveNotificationNote"] = "EPMLiveNotificationNote",
                        ["EPMLiveLogDetailedErrors"] = "EPMLiveLogDetailedErrors",
                        ["EPMLiveNotificationOptedOutUsers"] = "10"
                    };
                    new ShimStringDictionary(shim)
                    {
                        ContainsKeyString = key => stringDictionary.ContainsKey(key),
                        ItemGetString = key => stringDictionary.ContainsKey(key)
                            ? stringDictionary[key]
                            : null,
                        ItemSetStringString = (key, stringValue) =>
                        {
                            if (stringDictionary.ContainsKey(key))
                            {
                                stringDictionary[key] = stringValue;
                            }
                            else
                            {
                                stringDictionary.Add(key, stringValue);
                            }
                        }
                    };
                    return shim;
                },
                SiteUsersGet = () => shimSPUserCollection,
                UrlGet = () => SpWebUrl,
                WebsGet = () =>
                {
                    var shim = new ShimSPWebCollection();
                    new ShimSPBaseCollection(shim)
                    {
                        GetEnumerator = () => new List <SPWeb>().GetEnumerator()
                    };
                    return shim;
                }
            });
        }
        public void AddSynchedTemplatesColumn_WithChild_ReturnsTrueFieldNodeXml()
        {
            // Arrange
            var webChild = new ShimSPWeb()
            {
                IDGet   = () => DummyGuidWeb2,
                WebsGet = () => new ShimSPWebCollection().Bind(
                    new List <SPWeb>().AsEnumerable()),
                PropertiesGet = () =>
                {
                    var propertyBag      = new ShimSPPropertyBag();
                    var stringDictionary = new ShimStringDictionary(propertyBag)
                    {
                        ItemGetString     = key => PropertyTemplateId,
                        ContainsKeyString = keyParam => true
                    };
                    return(propertyBag);
                },
                SiteGet = () => new ShimSPSite()
                {
                    RootWebGet = () => new ShimSPWeb()
                    {
                        PropertiesGet = () =>
                        {
                            var propertyBag      = new ShimSPPropertyBag();
                            var stringDictionary = new ShimStringDictionary(propertyBag)
                            {
                                ItemGetString = key => DummyGuidWeb2.ToString()
                            };
                            return(propertyBag);
                        }
                    }
                }
            };

            var web = new ShimSPWeb()
            {
                IDGet   = () => DummyGuidWeb,
                WebsGet = () => new ShimSPWebCollection().Bind(
                    new List <SPWeb>
                {
                    webChild
                }.AsEnumerable()),
                PropertiesGet = () =>
                {
                    var propertyBag      = new ShimSPPropertyBag();
                    var stringDictionary = new ShimStringDictionary(propertyBag)
                    {
                        ItemGetString     = key => DummyGuidSite.ToString(),
                        ContainsKeyString = keyParam => false
                    };
                    return(propertyBag);
                },
                SiteGet = () => new ShimSPSite()
                {
                    RootWebGet = () => new ShimSPWeb()
                    {
                        PropertiesGet = () =>
                        {
                            var propertyBag      = new ShimSPPropertyBag();
                            var stringDictionary = new ShimStringDictionary(propertyBag)
                            {
                                ItemGetString     = key => DummyGuidSite.ToString(),
                                ContainsKeyString = keyParam => true
                            };
                            return(propertyBag);
                        }
                    }
                }
            };

            ShimSPSecurableObject.AllInstances.DoesUserHavePermissionsSPBasePermissions = (sender, permissionMask) => true;

            var doc = new XmlDocument();

            doc.LoadXml(XmlFull);
            var mainNode = doc.ChildNodes[0];

            _privateObject.SetField(DocFieldName, doc);

            var expectedXml = new List <string>()
            {
                "<rows>",
                "<head>",
                "<column type=\"tree\" width=\"298\">Sites</column></head>",
                "<row open=\"1\" locked=\"1\" id=\"------\">",
                $"<row open=\"1\" locked=\"1\" id=\"{PropertyTemplateId}\">",
                "<cell image=\"ICODCT.GIF\"> &lt;/a&gt;</cell></row>",
                "<cell image=\"STSICON.GIF\"> &lt;/a&gt;</cell></row></rows>"
            };

            // Act
            var actualResult = (bool)_privateObject.Invoke(AddSynchedTemplatesColumnMethodName, web.Instance, mainNode);

            // Assert
            var actualXml = mainNode.OuterXml;

            this.ShouldSatisfyAllConditions(
                () => actualResult.ShouldBeTrue(),
                () => expectedXml.ForEach(c => actualXml.ShouldContain(c)));
        }
        public void PageLoad_TTypeTmp1tColOnly_FillDataField()
        {
            // Arrange
            ShimSPContext.CurrentGet = () => new ShimSPContext()
            {
                SiteGet = () => new ShimSPSite()
                {
                    RootWebGet = () => new ShimSPWeb()
                    {
                        PropertiesGet = () =>
                        {
                            var propertyBag      = new ShimSPPropertyBag();
                            var stringDictionary = new ShimStringDictionary(propertyBag)
                            {
                                ItemGetString = key => PropertySiteTemplateIds
                            };
                            return(propertyBag);
                        },
                        SiteGet = () => new ShimSPSite()
                        {
                            CatchAccessDeniedExceptionSetBoolean = catchAccess => { }
                        }
                    }
                }
            };

            ShimPage.AllInstances.RequestGet = sender => new ShimHttpRequest()
            {
                ItemGetString = itemName =>
                {
                    switch (itemName)
                    {
                    case "maxlistsyncdate":
                        return("maxlistsyncdate");

                    case "ttype":
                        return("tmpltcolonly");

                    default:
                        break;
                    }

                    return(null);
                }
            };
            ShimPage.AllInstances.ResponseGet = sender => new ShimHttpResponse()
            {
                CacheGet = () => new ShimHttpCachePolicy()
                {
                    SetCacheabilityHttpCacheability = cacheAbility => { }
                },
                ExpiresSetInt32      = expires => { },
                ContentTypeSetString = contentType => { }
            };

            // Act
            _privateObject.Invoke(PageLoadMethodName, this, EventArgs.Empty);

            // Assert
            var actualData = (string)_privateObject.GetField(DataFieldName);

            actualData.ShouldBe("<rows><head><column type=\"tree\" width=\"598\">Sites</column></head></rows>");
        }
        public void AddWebs_WithoutChild_ReturnsTrueFieldNodeXml()
        {
            // Arrange
            var web = new ShimSPWeb()
            {
                IDGet   = () => DummyGuidWeb,
                SiteGet = () => new ShimSPSite()
                {
                    IDGet      = () => DummyGuidSite,
                    RootWebGet = () => new ShimSPWeb()
                    {
                        PropertiesGet = () =>
                        {
                            var propertyBag      = new ShimSPPropertyBag();
                            var stringDictionary = new ShimStringDictionary(propertyBag)
                            {
                                ItemGetString = key => DummyGuidWeb.ToString()
                            };
                            return(propertyBag);
                        },
                        GetFileString = url => new ShimSPFile()
                        {
                            ExistsGet           = () => true,
                            TimeLastModifiedGet = () => DummyDateTime
                        },
                        SiteGet = () => new ShimSPSite()
                        {
                            UrlGet = () => DummyUrl
                        }
                    }
                },
                WebsGet = () => new ShimSPWebCollection().Bind(
                    new List <SPWeb>().AsEnumerable()),
                PropertiesGet = () =>
                {
                    var propertyBag      = new ShimSPPropertyBag();
                    var stringDictionary = new ShimStringDictionary(propertyBag)
                    {
                        ItemGetString     = key => PropertyTemplateId,
                        ContainsKeyString = keyParam => true
                    };
                    return(propertyBag);
                },
                ServerRelativeUrlGet = () => DummyRelativeUrl
            };

            ShimSPSecurableObject.AllInstances.DoesUserHavePermissionsSPBasePermissions = (sender, permissionMask) => true;
            ShimSPContext.CurrentGet = () => new ShimSPContext()
            {
                WebGet = () => new ShimSPWeb()
                {
                    UrlGet = () => DummyUrlWeb
                }
            };

            var doc = new XmlDocument();

            doc.LoadXml(XmlRowNodeOnly);
            var mainNode = doc.ChildNodes[0];

            _privateObject.SetField(DocFieldName, doc);
            _privateObject.SetField("sMaxListSyncDate", "2017,1,1");

            var expectedXml = new List <string>()
            {
                "<rows>",
                "<row open=\"1\" locked=\"1\" id=\"/\">",
                "<cell image=\"ICODCT.GIF\"> &lt;/a&gt;</cell>",
                "<cell> &lt;a href='' target='_blank'&gt;Edit&lt;/a&gt;</cell>",
                "<cell> &lt;a href='#' onclick=\"showSaveTemplateForm('');return false\"&gt;Save&lt;/a&gt;</cell>",
                "<cell> &lt;a href='#' onclick=\"showRenameTemplateForm('','');return false\"&gt;Rename&lt;/a&gt;</cell>",
                "<cell> &lt;a href='#' onclick=\"delTemplate('/');return false\"&gt;Remove&lt;/a&gt;</cell>",
                "<cell align=\"center\" title=\"Based on the date/time of the last Enterprise List Synchronization, this template is up to date.\">&lt;img src=\"/_layouts/images/green.gif\" alt=\"\" title=\"Based on the date/time of the last Enterprise List Synchronization, this template is up to date.\" &gt;</cell>",
                "<cell align=\"center\">1/1/2018 12:00:00 AM</cell></row></rows>"
            };

            // Act
            var actualResult = (bool)_privateObject.Invoke(AddWebsMethodName, web.Instance, mainNode);

            // Assert
            var actualXml = mainNode.OuterXml;

            this.ShouldSatisfyAllConditions(
                () => actualResult.ShouldBeTrue(),
                () => expectedXml.ForEach(c => actualXml.ShouldContain(c)));
        }
예제 #8
0
        private string ProcessNewSaveRequest(bool hasPermission)
        {
            PrivateType objToTestPrivateMethod = new PrivateType(typeof(EPMLiveCore.API.MyWork));

            using (new SPEmulators.SPEmulationContext(SPEmulators.IsolationLevel.Fake))
            {
                ShimSPWeb fakespweb = fakespweb = new ShimSPWeb()
                {
                    IDGet = () =>
                    {
                        return(Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03"));
                    },
                    CurrentUserGet = () =>
                    {
                        return(new ShimSPUser()
                        {
                            IDGet = () =>
                            {
                                return 1073741823;
                            }
                        });
                    },
                    SiteGet = () =>
                    {
                        return(new ShimSPSite()
                        {
                            UrlGet = () =>
                            {
                                return "";
                            },
                            OpenWebGuid = (gg) =>
                            {
                                return new ShimSPWeb()
                                {
                                    IDGet = () =>
                                    {
                                        return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                    },
                                    PropertiesGet = () =>
                                    {
                                        var propertyBag = new ShimSPPropertyBag();
                                        var sd = new ShimStringDictionary(propertyBag);
                                        sd.ItemGetString = (key) =>
                                        {
                                            return "EPMLive_MyWork_Grid_GlobalViews";
                                        };
                                        return propertyBag;
                                    },
                                    SiteGet = () =>
                                    {
                                        return new ShimSPSite()
                                        {
                                            IDGet = () =>
                                            {
                                                return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                            }
                                        };
                                    },
                                    Dispose = () => { },
                                    AllowUnsafeUpdatesSetBoolean = (b) => { }
                                };
                            },
                            RootWebGet = () =>
                            {
                                return new ShimSPWeb()
                                {
                                    IDGet = () =>
                                    {
                                        return Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03");
                                    }
                                };
                            }
                        });
                    },
                    ParentWebGet = () =>
                    {
                        return(null);
                    },
                    PropertiesGet = () =>
                    {
                        var propertyBag = new ShimSPPropertyBag();
                        var sd          = new ShimStringDictionary(propertyBag);
                        sd.ItemGetString = (key) =>
                        {
                            return("EPMLiveLockConfig");
                        };
                        return(propertyBag);
                    }
                };
                fakespweb.Dispose = () => { };

                ShimSPSite.ConstructorString = (instance, url) =>
                {
                    ShimSPSite moledInstance = new ShimSPSite(instance);
                    moledInstance.Dispose           = () => { };
                    ShimSPSite.AllInstances.OpenWeb = (ins) =>
                    {
                        return(fakespweb);
                    };
                };

                ShimSPSite.ConstructorGuid = (instance, url) =>
                {
                    ShimSPSite moledInstance = new ShimSPSite(instance)
                    {
                        IDGet = () =>
                        {
                            return(Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86D03"));
                        },
                        WebApplicationGet = () =>
                        {
                            var webApp          = new ShimSPWebApplication();
                            var persistedObject = new ShimSPPersistedObject(webApp);
                            persistedObject.IdGet = () =>
                            {
                                return(Guid.Parse("D4A8A5A3-5C26-45D0-876C-AC2B4FB86DAA"));
                            };
                            return(webApp);
                        }
                    };
                    moledInstance.Dispose           = () => { };
                    ShimSPSite.AllInstances.OpenWeb = (ins) =>
                    {
                        return(fakespweb);
                    };
                };

                ShimCoreFunctions.iGetConfigSettingSPWebStringBooleanBoolean = (p1, p2, p3, p4) =>
                {
                    return("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfMyWorkGridView xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <MyWorkGridView>\r\n    <Cols>Flag:30,Work0000Type:131,Project:116,DueDate:100,WorkingOn:85</Cols>\r\n    <Default>false</Default>\r\n    <Filters>0|WorkingOn:1:11</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>7e9399ec83ae91854b600b808918b3c4</Id>\r\n    <LeftCols>Complete:20,CommentCount:36,Priority:25,Title:222</LeftCols>\r\n    <Name>Working On It</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols />\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>false</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols>Work0000Type:89,StartDate:97,DueDate:131,Status:38,PercentComplete:113,Flag:41,Project:83,WorkingOn:86</Cols>\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|Due</Grouping>\r\n    <Id>0007b12319302de33f227d1e08e089be</Id>\r\n    <LeftCols>Complete:20,CommentCount:36,Priority:25,Title:213</LeftCols>\r\n    <Name>My Work by Due</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols />\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>false</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols>Work0000Type:119,Due:98,StartDate:83,DueDate:112,Work:33,Status:56,PercentComplete:113,Flag:44,WorkingOn:86</Cols>\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|Project</Grouping>\r\n    <Id>2ba87d5cf4822160e548843193ad30db</Id>\r\n    <LeftCols>Complete:20,CommentCount:36,Priority:25,Title:140</LeftCols>\r\n    <Name>My Work by Project</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols />\r\n    <Sorting>DueDate,Due</Sorting>\r\n    <HasPermission>false</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols>DueDate:58,WorkingOn:100</Cols>\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>0111d91d9fc6c72b3fe349a55e89048a</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:601</LeftCols>\r\n    <Name>Work Summary</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols />\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>false</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>57bcc4f29adfe3c1f09d7e29e7128bdb</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:570</LeftCols>\r\n    <Name>gg3</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>dv</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:570</LeftCols>\r\n    <Name>Default View</Name>\r\n    <Personal>false</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>true</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>ec6ef230f1828039ee794566b9c58adc</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:570</LeftCols>\r\n    <Name>p1</Name>\r\n    <Personal>true</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n</ArrayOfMyWorkGridView>");
                };

                ShimSPContext.CurrentGet = () =>
                {
                    return(new ShimSPContext()
                    {
                        WebGet = () =>
                        {
                            return fakespweb;
                        }
                    });
                };


                ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = (w) =>
                {
                    w();
                };

                ShimCoreFunctions.getConnectionStringGuid = (guid) =>
                {
                    return("Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;");
                };

                var openedConnections = 0;
                var closedConnections = 0;

                ShimSqlConnection.ConstructorString = (instance, connString) =>
                {
                    var connection = new ShimSqlConnection(instance);
                    connection.Open  = () => { openedConnections++; };
                    connection.Close = () => { closedConnections++; };
                };


                ShimSqlCommand.ConstructorStringSqlConnection = (instance, cmdText, sqlConnection) =>
                {
                    ShimSqlCommand sqlCommand = new ShimSqlCommand(instance);
                    sqlCommand.ParametersGet = () =>
                    {
                        var realSqlCommand = new SqlCommand();
                        return(realSqlCommand.Parameters);
                    };

                    sqlCommand.ExecuteScalar = () =>
                    {
                        return("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfMyWorkGridView xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>7d7f7e971ca8152804ad89b891fba0b4</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:554</LeftCols>\r\n    <Name>gg2</Name>\r\n    <Personal>true</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>false</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>57bcc4f29adfe3c1f09d7e29e7128bdb</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:554</LeftCols>\r\n    <Name>gg3</Name>\r\n    <Personal>true</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n  <MyWorkGridView>\r\n    <Cols />\r\n    <Default>true</Default>\r\n    <Filters>0|</Filters>\r\n    <Grouping>0|</Grouping>\r\n    <Id>ec6ef230f1828039ee794566b9c58adc</Id>\r\n    <LeftCols>Complete:25,CommentCount:36,Priority:25,Title:570</LeftCols>\r\n    <Name>p1</Name>\r\n    <Personal>true</Personal>\r\n    <RightCols>Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87</RightCols>\r\n    <Sorting>DueDate</Sorting>\r\n    <HasPermission>true</HasPermission>\r\n  </MyWorkGridView>\r\n</ArrayOfMyWorkGridView>");
                    };

                    sqlCommand.ExecuteNonQuery = () =>
                    {
                        return(1);
                    };
                };

                var data = "<MyWork><View ID=\"73c18c59a39b18382081ec00bb456d43\" Name=\"gg\" Default=\"true\" Personal=\"false\" HasPermission=\"" + hasPermission.ToString() + "\" LeftCols=\"Complete:25,CommentCount:36,Priority:25,Title:570\" Cols=\"\" RightCols=\"Flag:30,Work0000Type:125,Project:90,DueDate:100,WorkingOn:87\" Filters=\"0|\" Grouping=\"0|\" Sorting=\"DueDate\"/></MyWork>";

                string result = "";
                result = objToTestPrivateMethod.InvokeStatic("SaveMyWorkGridView", data) as string;

                Assert.AreEqual(openedConnections, closedConnections);

                return(result);
            }
        }