public async Task Assign(int userId) { await _apiClient.SendAsync(new AssignIncident(DTO.Id, userId, userId)); async Task <bool> Func() { var query = new GetIncident(DTO.Id); var result = await _apiClient.QueryAsync(query); if (result.AssignedToId != userId) { return(false); } DTO = result; return(true); } if (!await ActionExtensions.Retry(Func)) { throw new TestFailedException($"Incident {DTO.Id} was not assigned to {userId}."); } }
public static async Task <int> Reset(this ServerApiClient client, int applicationId, string environmentName) { var envs = new GetEnvironments(); var result = await client.QueryAsync(envs); var id = result.Items.FirstOrDefault(x => x.Name == environmentName)?.Id; // haven't reported for that environment yet if (id == null) { return(id ?? 0); } var cmd = new ResetEnvironment(applicationId, id.Value); await client.SendAsync(cmd); return(id ?? 0); }
public static async Task <int> EnsureApplication(this ServerApiClient client, string name) { var query = new GetApplicationList(); var result = await client.QueryAsync(query); var app = result.FirstOrDefault(x => x.Name == name); if (app != null) { return(app.Id); } var cmd = new CreateApplication(name, TypeOfApplication.DesktopApplication) { ApplicationKey = Guid.NewGuid().ToString("N"), UserId = 1 }; await client.SendAsync(cmd); var query2 = new GetApplicationIdByKey(cmd.ApplicationKey); var retriesLeft = 3; while (retriesLeft-- > 0) { var app2 = await client.QueryAsync(query2); if (app2 != null) { return(app2.Id); } await Task.Delay(500); } throw new TestFailedException("Could not create application."); }
public async Task Reset() { var query = new GetWhitelistEntries(); var result = await _apiClient.QueryAsync(query); foreach (var item in result.Entries) { var cmd = new RemoveEntry { Id = item.Id }; await _apiClient.SendAsync(cmd); } }