Example #1
0
        public void Application()
        {
            string  dummyString;
            bool    dummyBool;
            int     dummyInt;
            Service service = Connect();

            ApplicationCollection apps = service.GetApplicationsAsync().Result;

            foreach (Application app in apps)
            {
                try
                {
                    ApplicationSetupInfo applicationSetup = app.GetSetupInfoAsync().Result;
                    //string setupXml = applicationSetup.SetupXml;
                }
                catch (Exception)
                {
                    // silent exception, if setup doesn't exist, exception occurs
                }

                ApplicationArchiveInfo applicationArchive = app.PackageAsync().Result;
                dummyString = app.Author;
                dummyBool   = app.CheckForUpdates;
                dummyString = app.Description;
                dummyString = app.Label;
                dummyBool   = app.Refresh;
                dummyString = app.Version;
                dummyBool   = app.Configured;
                if (this.VersionCompare(service, "5.0") < 0)
                {
                    //dummyBool = app.IsManageable;
                }
                dummyBool = app.Visible;
                dummyBool = app.StateChangeRequiresRestart;
                ApplicationUpdateInfo applicationUpdate = app.GetUpdateInfoAsync().Result;
                //dummyString = applicationUpdate.Checksum;
                //dummyString = applicationUpdate.ChecksumType;
                //dummyString = applicationUpdate.Homepage;
                //dummyInt = applicationUpdate.UpdateSize;
                //dummyString = applicationUpdate.UpdateName;
                //dummyString = applicationUpdate.AppUrl;
                //dummyString = applicationUpdate.Version;
                //dummyBool = applicationUpdate.IsImplicitIdRequired;
            }

            if (apps.Any(a => a.Name == "sdk-tests"))
            {
                service = this.CleanApp("sdk-tests", service);
            }

            apps = service.GetApplicationsAsync().Result;
            Assert.False(apps.Any(a => a.Name == "sdk-tests"), assertRoot + "#1");

            ApplicationAttributes createArgs = new ApplicationAttributes();

            createArgs.ApplicationAuthor = "me";
            if (this.VersionCompare(service, "4.2.4") >= 0)
            {
                createArgs.Configured = false;
            }
            createArgs.Description = "this is a description";
            createArgs.Label       = "SDKTEST";
            if (this.VersionCompare(service, "5.0") < 0)
            {
                //createArgs.manageable", false);
            }
            //createArgs.template", "barebones");
            createArgs.Visible = false;
            service.CreateApplicationAsync("sdk-tests", "barebones", createArgs).Wait();
            apps.GetAsync().Wait();
            Assert.True(apps.Any(a => a.Name == "sdk-tests"), assertRoot + "#2");

            Application app2 = service.GetApplicationAsync("sdk-tests").Result;

            dummyBool = app2.CheckForUpdates;
            Assert.Equal("SDKTEST", app2.Label);
            Assert.Equal("me", app2.ApplicationAuthor);
            Assert.False(app2.Configured, assertRoot + "#5");
            if (this.VersionCompare(service, "5.0") < 0)
            {
                //Assert.False(app2.Manageable, assertRoot + "#6");
            }
            Assert.False(app2.Visible, assertRoot + "#7");

            // update the app
            ApplicationAttributes attr = new ApplicationAttributes();

            attr.ApplicationAuthor = "not me";
            attr.Description       = "new description";
            attr.Label             = "new label";
            attr.Visible           = false;
            if (this.VersionCompare(service, "5.0") < 0)
            {
                //app2.IsManageable = false;
            }
            //attr.Version = "5.0.0";
            app2.UpdateAsync(attr, true).Wait();
            app2.GetAsync().Wait();

            // check to see if args took.
            Assert.Equal("not me", app2.ApplicationAuthor);
            Assert.Equal("new description", app2.Description);
            Assert.Equal("new label", app2.Label);
            Assert.False(app2.Visible, assertRoot + "#11");
            //Assert.Equal("5.0.0", app2.Version);

            // archive (package) the application
            ApplicationArchiveInfo appArchive = app2.PackageAsync().Result;

            Assert.True(appArchive.ApplicationName.Length > 0, assertRoot + "#13");
            Assert.True(appArchive.Path.Length > 0, assertRoot + "#14");
            Assert.True(appArchive.Uri.AbsolutePath.Length > 0, assertRoot + "#15");

            ApplicationUpdateInfo appUpdate = app2.GetUpdateInfoAsync().Result;

            //ApplicationUpdate appUpdate = app2.AppUpdate();
            //Assert.True(appUpdate.ContainsKey("eai:acl"), assertRoot + "#16");

            service = this.CleanApp("sdk-tests", service);
            apps    = service.GetApplicationsAsync().Result;
            Assert.False(apps.Any(a => a.Name == "sdk-tests"), assertRoot + "#17");
        }
        async Task CheckApplication(Application app)
        {
            ApplicationSetupInfo setupInfo = null;

            try
            {
                setupInfo = await app.GetSetupInfoAsync();

                //// TODO: Install an app which hits this code before this test runs

                Assert.NotNull(setupInfo.Eai);
                Assert.DoesNotThrow(() => { bool p = setupInfo.Refresh; });
            }
            catch (InternalServerErrorException e)
            {
                Assert.Contains("Internal Server Error", e.Message);
            }

            ApplicationArchiveInfo archiveInfo = await app.PackageAsync();

            Assert.DoesNotThrow(() =>
            {
                string p = app.Author;
                Assert.NotNull(p);
            });

            Assert.DoesNotThrow(() => { string p = app.ApplicationAuthor; });
            Assert.DoesNotThrow(() => { bool p = app.CheckForUpdates; });
            Assert.DoesNotThrow(() => { string p = app.Description; });
            Assert.DoesNotThrow(() => { string p = app.Label; });
            Assert.DoesNotThrow(() => { bool p = app.Refresh; });
            Assert.DoesNotThrow(() => { string p = app.Version; });
            Assert.DoesNotThrow(() => { bool p = app.Configured; });
            Assert.DoesNotThrow(() => { bool p = app.StateChangeRequiresRestart; });
            Assert.DoesNotThrow(() => { bool p = app.Visible; });

            ApplicationUpdateInfo updateInfo = await app.GetUpdateInfoAsync();

            Assert.NotNull(updateInfo.Eai);

            if (updateInfo.Update != null)
            {
                var update = updateInfo.Update;

                Assert.DoesNotThrow(() =>
                {
                    string p = updateInfo.Update.ApplicationName;
                });
                Assert.DoesNotThrow(() =>
                {
                    Uri p = updateInfo.Update.ApplicationUri;
                });
                Assert.DoesNotThrow(() =>
                {
                    string p = updateInfo.Update.ApplicationName;
                });
                Assert.DoesNotThrow(() =>
                {
                    string p = updateInfo.Update.ChecksumType;
                });
                Assert.DoesNotThrow(() =>
                {
                    string p = updateInfo.Update.Homepage;
                });
                Assert.DoesNotThrow(() =>
                {
                    bool p = updateInfo.Update.ImplicitIdRequired;
                });
                Assert.DoesNotThrow(() =>
                {
                    long p = updateInfo.Update.Size;
                });
                Assert.DoesNotThrow(() =>
                {
                    string p = updateInfo.Update.Version;
                });
            }

            Assert.DoesNotThrow(() => { DateTime p = updateInfo.Updated; });
        }