public async Task TestGetVersion() { ApplicationUpdate applicationUpdate = new ApplicationUpdate(TimeSpan.FromSeconds(30)); Version version = new Version("1.0.0.0"); ApplicationUpdateInfo info = await applicationUpdate.GetUpdateApplicationInfo(version); if (info != null) { Assert.IsTrue(info.Version > version); Assert.IsTrue(info.DownloadUrl.EndsWith(".zip")); info = await applicationUpdate.GetUpdateApplicationInfo(info.Version); Assert.IsNull(info); } }
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; }); }
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"); }
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); } }