Beispiel #1
0
        private void AddAndCheckRandomAppWithVersion(WebModelNode web, Version version)
        {
            var def = new AppDefinition();

            def.ProductId = DefaultContainers.Apps.ProductId;
            def.Version   = version.ToString();

            def.Content = File.ReadAllBytes(string.Format(DefaultContainers.Apps.GenericVersionableAppFilePath, version));

            web.AddApp(def, app =>
            {
                app.OnProvisioned <object, AppDefinition>(context =>
                {
                    Trace.WriteLine(context.ObjectDefinition.ToString());
                    Trace.WriteLine(context.Object.ToString());

                    var expectedAppVersion = new Version(context.ObjectDefinition.Version);

                    var obj     = context.Object;
                    var objType = context.Object.GetType();

                    if (objType.ToString().Contains("Microsoft.SharePoint.Client.AppInstance"))
                    {
                        // with CSOM there is no API to know current app installed version
                        // checking if app is Installed after every single update
                        var appStatus = obj.GetPropertyValue("Status").ToString();

                        Assert.IsTrue(appStatus == "Installed",
                                      string.Format("App should be installed after every update"));
                    }
                    else if (objType.ToString().Contains("Microsoft.SharePoint.Administration.SPAppInstance"))
                    {
                        var appObjet = obj.GetPropertyValue("App");

                        var versionString = appObjet.GetPropertyValue("VersionString") as string;
                        var spAppVersion  = new Version(versionString);

                        // either equal (update) or SharePoint version greater than local (second update)
                        // the test is run several times, so only once we have =, and then we have <
                        Assert.IsTrue(expectedAppVersion <= spAppVersion,
                                      string.Format("Expecting app version:[{0}] SharePoint app version:[{1}]", expectedAppVersion, spAppVersion));
                    }
                    else
                    {
                        throw new SPMeta2NotImplementedException(string.Format("ID property extraction is not implemented for type: [{0}]", objType));
                    }
                });
            });
        }
Beispiel #2
0
        private void AddAndCheckRandomAppWithVersion(WebModelNode web, Version version)
        {
            var def = new AppDefinition();

            def.ProductId = DefaultContainers.Apps.ProductId;
            def.Version = version.ToString();

            def.Content = File.ReadAllBytes(string.Format(DefaultContainers.Apps.GenericVersionableAppFilePath, version));

            web.AddApp(def, app =>
            {
                app.OnProvisioned<object, AppDefinition>(context =>
                {
                    Trace.WriteLine(context.ObjectDefinition.ToString());
                    Trace.WriteLine(context.Object.ToString());

                    var expectedAppVersion = new Version(context.ObjectDefinition.Version);

                    var obj = context.Object;
                    var objType = context.Object.GetType();

                    if (objType.ToString().Contains("Microsoft.SharePoint.Client.AppInstance"))
                    {
                        // with CSOM there is no API to know current app installed version
                        // checking if app is Installed after every single update
                        var appStatus = obj.GetPropertyValue("Status").ToString();

                        Assert.IsTrue(appStatus == "Installed",
                            string.Format("App should be installed after every update"));
                    }
                    else if (objType.ToString().Contains("Microsoft.SharePoint.Administration.SPAppInstance"))
                    {
                        var appObjet = obj.GetPropertyValue("App");

                        var versionString = appObjet.GetPropertyValue("VersionString") as string;
                        var spAppVersion = new Version(versionString);

                        // either equal (update) or SharePoint version greater than local (second update)
                        // the test is run several times, so only once we have =, and then we have <
                        Assert.IsTrue(expectedAppVersion <= spAppVersion,
                            string.Format("Expecting app version:[{0}] SharePoint app version:[{1}]", expectedAppVersion, spAppVersion));
                    }
                    else
                    {
                        throw new SPMeta2NotImplementedException(string.Format("ID property extraction is not implemented for type: [{0}]", objType));
                    }
                });
            });
        }