public async Task TestApplications()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            using (var service = await SdkHelper.CreateService())
            {
                ApplicationCollection apps = service.Applications;
                await apps.GetAllAsync();

                foreach (Application app in apps)
                {
                    await CheckApplication(app);
                }

                for (int i = 0; i < apps.Count; i++)
                {
                    await CheckApplication(apps[i]);
                }
            }
        }
예제 #2
0
        public async Task Application()
        {
            using (var service = await SdkHelper.CreateService())
            {
                ApplicationCollection apps = service.Applications;
                await apps.GetAllAsync();

                foreach (Application app in apps)
                {
                    await CheckApplication(app);
                }

                for (int i = 0; i < apps.Count; i++)
                {
                    await CheckApplication(apps[i]);
                }

                if (await service.Applications.RemoveAsync("sdk-tests"))
                {
                    await service.Server.RestartAsync(2 * 60 * 1000);

                    await service.LogOnAsync();
                }

                ApplicationAttributes attributes = new ApplicationAttributes
                {
                    ApplicationAuthor = "me",
                    Description       = "this is a description",
                    Label             = "SDKTEST",
                    Visible           = false
                };

                var testApp = await service.Applications.CreateAsync("sdk-tests", "barebones", attributes);

                testApp = await service.Applications.GetAsync("sdk-tests");

                Assert.Equal("SDKTEST", testApp.Label);
                Assert.Equal("me", testApp.ApplicationAuthor);
                Assert.Equal("nobody", testApp.Author);
                Assert.False(testApp.Configured);
                Assert.False(testApp.Visible);

                Assert.DoesNotThrow(() =>
                {
                    bool p = testApp.CheckForUpdates;
                });

                attributes = new ApplicationAttributes
                {
                    ApplicationAuthor = "not me",
                    Description       = "new description",
                    Label             = "new label",
                    Visible           = false,
                    Version           = "1.5"
                };

                //// Update the application

                await testApp.UpdateAsync(attributes, true);

                await testApp.GetAsync();

                Assert.Equal("not me", testApp.ApplicationAuthor);
                Assert.Equal("nobody", testApp.Author);
                Assert.Equal("new description", testApp.Description);
                Assert.Equal("new label", testApp.Label);
                Assert.Equal("1.5", testApp.Version);
                Assert.False(testApp.Visible);

                ApplicationUpdateInfo updateInfo = await testApp.GetUpdateInfoAsync();

                Assert.NotNull(updateInfo.Eai.Acl);

                //// Package the application

                ApplicationArchiveInfo archiveInfo = await testApp.PackageAsync();

                Assert.Equal("Package", archiveInfo.Title);
                Assert.NotEqual(DateTime.MinValue, archiveInfo.Updated);

                Assert.DoesNotThrow(() =>
                {
                    string p = archiveInfo.ApplicationName;
                });
                Assert.True(archiveInfo.ApplicationName.Length > 0);

                Assert.DoesNotThrow(() =>
                {
                    Eai p = archiveInfo.Eai;
                });
                Assert.NotNull(archiveInfo.Eai);
                Assert.NotNull(archiveInfo.Eai.Acl);

                Assert.DoesNotThrow(() =>
                {
                    string p = archiveInfo.Path;
                });
                Assert.True(archiveInfo.Path.Length > 0);

                Assert.DoesNotThrow(() =>
                {
                    bool p = archiveInfo.Refresh;
                });

                Assert.DoesNotThrow(() =>
                {
                    Uri p = archiveInfo.Uri;
                });
                Assert.True(archiveInfo.Uri.AbsolutePath.Length > 0);

                Assert.True(await service.Applications.RemoveAsync("sdk-tests"));
                await service.Server.RestartAsync(2 * 60 * 1000);
            }
        }