// ReSharper disable PossibleMultipleEnumeration public async Task RunAsync(IRestContext context) { ISystemApi systemApi = context.Factory.CreateSystemApi(); IEnumerable <ScriptResponse> scripts = await systemApi.GetScriptsAsync(true); Console.WriteLine("GetScriptsAsync(): {0}", scripts.Select(x => x.script_id).ToStringList()); if (scripts.Any(x => x.script_id == ScriptId)) { await DeleteDummyScript(systemApi); } const string scriptText = @"return Number(event.n1) + Number(event.n2);"; ScriptResponse response = await systemApi.WriteScriptAsync(ScriptId, scriptText); Console.WriteLine("WriteScriptAsync(): id={0}", response.script_id); Dictionary <string, object> p = new Dictionary <string, object> { { "n1", 3 }, { "n2", 5 } }; string output = await systemApi.RunScriptAsync(ScriptId, p); Console.WriteLine("RunScriptAsync(): {0}", context.ContentSerializer.Serialize(output)); await DeleteDummyScript(systemApi); }
private static async Task DeleteRole(RoleResponse role, ISystemApi systemApi) { Debug.Assert(role.id.HasValue, "Role ID must be set"); await systemApi.DeleteRolesAsync(role.id.Value); Console.WriteLine("DeleteRolesAsync():: id={0}", role.id); }
// ReSharper disable PossibleMultipleEnumeration public async Task RunAsync(IRestContext context) { ISystemApi systemApi = context.Factory.CreateSystemApi(); // Read SqlQuery query = new SqlQuery { fields = "*", related = "services,roles", }; IEnumerable <AppResponse> apps = await systemApi.GetAppsAsync(query); Console.WriteLine("Apps: {0}", apps.Select(x => x.api_name).ToStringList()); // Cloning AppResponse todoApp = apps.Single(x => x.api_name == "todoangular"); AppRequest todoAppRequest = todoApp.Convert <AppResponse, AppRequest>(); todoAppRequest.name = todoApp.name + "clone"; todoAppRequest.api_name = todoApp.api_name + "clone"; // Creating a clone apps = await systemApi.CreateAppsAsync(new SqlQuery(), todoAppRequest); AppResponse todoAppClone = apps.Single(x => x.api_name == "todoangularclone"); Console.WriteLine("Created a clone app={0}", todoAppClone.api_name); // Deleting the clone Debug.Assert(todoAppClone.id.HasValue); await systemApi.DeleteAppsAsync(true, todoAppClone.id.Value); Console.WriteLine("Created clone has been deleted"); }
// ReSharper disable PossibleMultipleEnumeration public async Task RunAsync(IRestContext context) { ISystemApi systemApi = context.Factory.CreateSystemApi(); IEnumerable <DeviceResponse> devices = await systemApi.GetDevicesAsync(new SqlQuery()); await DeleteAnyDevices(devices, systemApi); IUserApi userApi = context.Factory.CreateUserApi(); DeviceRequest device = new DeviceRequest { uuid = "1", model = "model", platform = "windows", version = "1.0" }; bool ok = await userApi.SetDeviceAsync(device); Console.WriteLine("SetDeviceAsync(): success={0}", ok); SqlQuery query = new SqlQuery { filter = "platform=\"windows\"", fields = "*" }; devices = await systemApi.GetDevicesAsync(query); Console.WriteLine("GetDevicesAsync(): {0}", context.ContentSerializer.Serialize(devices.Single())); await DeleteAnyDevices(devices, systemApi); }
private static async Task DeleteUser(UserResponse user, ISystemApi systemApi) { Debug.Assert(user.id.HasValue, "User ID must be set"); await systemApi.DeleteUsersAsync(user.id.Value); Console.WriteLine("DeleteUsersAsync():: id={0}", user.id); }
public void ShouldDeleteAppsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act & Assert systemApi.DeleteAppsAsync(true, 1, 2, 3); }
public void ShouldUpdateUserAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); UserRequest user = CreateUser(); // Act & Assert systemApi.UpdateUsersAsync(new SqlQuery(), user).Wait(); }
public void ShouldUpdateRoleAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); RoleRequest role = CreateRole(); // Act & Assert systemApi.UpdateRolesAsync(new SqlQuery(), role).Wait(); }
public void ShouldUpdateServiceAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); ServiceRequest service = CreateService(); // Act & Assert systemApi.UpdateServicesAsync(new SqlQuery(), service).Wait(); }
public void ShouldUpdateAppAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); AppRequest app = CreateApp(); // Act & Assert systemApi.UpdateAppsAsync(new SqlQuery(), app).Wait(); }
public void ShouldUpdateLookupAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); LookupRequest lookup = CreateLookup(); // Act & Assert systemApi.UpdateLookupsAsync(new SqlQuery(), lookup).Wait(); }
private static async Task DeleteAnyDevices(IEnumerable<DeviceResponse> devices, ISystemApi systemApi) { if (devices.Any()) { int[] ids = devices.Select(x => x.id ?? 0).ToArray(); await systemApi.DeleteDevicesAsync(ids); Console.WriteLine("DeleteDevicesAsync()"); } }
public void ShouldDeleteLookupsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act & Assert systemApi.DeleteLookupsAsync(new SqlQuery(), 1, 2, 3); Should.Throw <ArgumentException>(() => systemApi.DeleteLookupsAsync(new SqlQuery())); }
public void ShouldGetConfigAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act ConfigResponse config = systemApi.GetConfigAsync().Result; // Assert config.EditableProfileFields.ShouldBe("name"); }
public void ShouldGetEnvironmentAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act EnvironmentResponse environment = systemApi.GetEnvironmentAsync().Result; // Assert environment.Platform.VersionCurrent.ShouldBe("2.0"); }
public async Task RunAsync(IRestContext context) { ISystemApi systemApi = context.Factory.CreateSystemApi(); bool success = await systemApi.LogoutAdminAsync(); Console.WriteLine("Logged out, success={0}", success); //IUserApi userApi = context.Factory.CreateUserApi(); //bool success = await userApi.LogoutAsync(); //Console.WriteLine("Logged out, success={0}", success); }
public void ShouldGetEnvironmentAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act EnvironmentResponse environment = systemApi.GetEnvironmentAsync().Result; // Assert environment.server.server_os.ShouldBe("linux"); }
public void ShouldLogoutAdminAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act bool logout = systemApi.LogoutAdminAsync().Result; // Assert logout.ShouldBe(true); }
public void ShouldDownloadApplicationSdkAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act byte[] data = systemApi.DownloadApplicationSdkAsync(1).Result; // Assert data.Length.ShouldBeGreaterThan(0); }
public void ShouldGetAppGroupAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <AppGroupResponse> appGroups = systemApi.GetAppGroupsAsync(new SqlQuery()).Result.ToList(); // Assert appGroups.Count.ShouldBe(1); appGroups.First().name.ShouldBe("NewGroup"); }
public void ShouldGetServicesAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <ServiceResponse> services = systemApi.GetServicesAsync(new SqlQuery()).Result.ToList(); // Assert services.Count.ShouldBe(4); services.First().name.ShouldBe("Database"); }
public void ShouldGetRolesAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <RoleResponse> roles = systemApi.GetRolesAsync(new SqlQuery()).Result.ToList(); // Assert roles.Count.ShouldBe(1); roles.First().name.ShouldBe("TestRole"); }
public void ShouldGetUsersAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <UserResponse> users = systemApi.GetUsersAsync(new SqlQuery()).Result.ToList(); // Assert users.Count.ShouldBe(2); users.First().display_name.ShouldBe("Andrei Smirnov"); }
public void ShouldGetAppsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <AppResponse> apps = systemApi.GetAppsAsync(new SqlQuery()).Result.ToList(); // Assert apps.Count.ShouldBe(5); apps.First().api_name.ShouldBe("todojquery"); }
public void ShouldGetConstantAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act Dictionary <string, string> constant = systemApi.GetConstantAsync("content_types").Result; // Assert constant.Count.ShouldBe(14); constant.Keys.ShouldContain("HTML"); }
public void ShouldGetConstantsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <string> types = systemApi.GetConstantsAsync().Result.ToList(); // Assert types.Count.ShouldBe(19); types.ShouldContain("content_types"); }
public void ShouldGetEventScriptsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <string> events = systemApi.GetEventsAsync().Result.ToList(); // Assert events.Count.ShouldBe(5); events.First().ShouldBe("system.get.pre_process"); }
public void ShouldGetScriptTypes() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <ScriptTypeResponse> scriptTypes = systemApi.GetScriptTypesAsync(new SqlQuery()).Result.ToList(); // Assert scriptTypes.Count.ShouldBe(1); scriptTypes.Select(x => x.Name).First().ShouldBe("v8js"); }
public void ShouldCreateAppAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); AppRequest app = CreateApp(); // Act AppResponse created = systemApi.CreateAppsAsync(new SqlQuery(), app).Result.First(); // Assert created.name.ShouldBe("Todo List jQuery"); }
public void ShouldGetCorsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <CorsResponse> results = systemApi.GetCorsAsync(new SqlQuery()).Result.ToList(); // Assert results.Count.ShouldBe(2); results.First().Origin.ShouldBe("http://domain.foo"); }
public void ShouldGetLookupsAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); // Act List <LookupResponse> lookups = systemApi.GetLookupsAsync(new SqlQuery()).Result.ToList(); // Assert lookups.Count.ShouldBe(1); lookups.First().Value.ShouldBe("text"); }
private static async Task DeleteUser(UserResponse user, ISystemApi systemApi) { Debug.Assert(user.id.HasValue, "User ID must be set"); await systemApi.DeleteUsersAsync(user.id.Value); Console.WriteLine("DeleteUsersAsync():: id={0}", user.id); }
private static async Task DeleteDummyScript(ISystemApi systemApi) { await systemApi.DeleteScriptAsync(ScriptId); Console.WriteLine("DeleteScriptAsync({0})", ScriptId); }
private static async Task DeleteRole(RoleResponse role, ISystemApi systemApi) { Debug.Assert(role.id.HasValue, "Role ID must be set"); await systemApi.DeleteRolesAsync(role.id.Value); Console.WriteLine("DeleteRolesAsync():: id={0}", role.id); }