public async Task Execute(IAssemblaClient client) { var newSpace = new Space { Name = "Test Space" }; var createdSpace = await client.Spaces.CreateAsync(newSpace); createdSpace.ShouldNotBeNull(); createdSpace.Name.ShouldBe(newSpace.Name); createdSpace.Id.ShouldNotBeNull(); const string newName = "New Name"; await client.Spaces.UpdateAsync(new Space { Name = newName, WikiName = createdSpace.WikiName }); var updatedSpace = await client.Spaces.GetAsync(createdSpace.WikiName); updatedSpace.Name.ShouldBe(newName); updatedSpace.Id.ShouldBe(createdSpace.Id); var listAll = await client.Spaces.GetAllAsync(); listAll.Count(c => c.Id == updatedSpace.Id).ShouldBe(1); await client.Spaces.DeleteAsync(updatedSpace.Id); }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var customField = await client.Tickets.CustomFields.CreateAsync(test.Space.WikiName, new CustomField { Title = "Test Field", DefaultValue = "DefaultValue", IsRequired = true }); var ticketWithDefaultValue = await client.Tickets.CreateAsync(test.Space.WikiName, new Ticket { Summary = "Ticket with Default Value" }); ticketWithDefaultValue.CustomFields[customField.Title].ShouldBe(customField.DefaultValue); const string specialValue = "A Special Value"; var ticketWithSpecifiedValue = await client.Tickets.CreateAsync(test.Space.WikiName, new Ticket { Summary = "Ticket with Default Value", CustomFields = new Dictionary <string, string> { [customField.Title] = specialValue } }); ticketWithSpecifiedValue.CustomFields[customField.Title].ShouldBe(specialValue); var allCustomFields = await client.Tickets.CustomFields.GetAllAsync(test.Space.WikiName); allCustomFields.ShouldContain(c => c.Id == customField.Id); const string newDefaultValue = "New Default Value"; await client.Tickets.CustomFields.UpdateAsync(test.Space.WikiName, new CustomField { Id = customField.Id, DefaultValue = newDefaultValue }); var updatedCustomField = await client.Tickets.CustomFields.GetAsync(test.Space.WikiName, customField.Id); updatedCustomField.DefaultValue.ShouldBe(newDefaultValue); await client.Tickets.CustomFields.DeleteAsync(test.Space.WikiName, customField.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace()) { var tool = await client.Spaces.Tools.AddAsync(test.Space.WikiName, ToolType.SourceGit); tool.ShouldNotBeNull(); tool.Id.ShouldNotBeNull(); tool.ToolType.ShouldBe(ToolType.SourceGit); var listAll = await client.Spaces.Tools.GetAllInSpaceAsync(test.Space.WikiName); listAll.Count().ShouldBe(1); listAll.Single().Id.ShouldBe(tool.Id); var listRepo = await client.Spaces.Tools.GetAllRepoInSpaceAsync(test.Space.WikiName); listRepo.Count().ShouldBe(1); listRepo.Single().Id.ShouldBe(tool.Id); await client.Spaces.Tools.UpdateAsync(test.Space.WikiName, new Tool { Id = tool.Id, WatcherPermissions = Permissions.All }); var updatedTool = await client.Spaces.Tools.GetAsync(test.Space.WikiName, tool.Id); updatedTool.WatcherPermissions.ShouldBe(Permissions.All); await client.Spaces.Tools.DeleteAsync(test.Space.WikiName, tool.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var tag = new Tag { Name = "New Tag" }; var createdTag = await client.Tags.CreateAsync(test.Space.Id, tag); createdTag.ShouldNotBeNull(); createdTag.Name.ShouldBe(tag.Name); const string newName = "New Name"; await client.Tags.UpdateAsync(test.Space.WikiName, new Tag { Id = createdTag.Id, Name = newName, State = TagState.Hidden }); var updatedTag = await client.Tags.GetAsync(test.Space.Id, createdTag.Id); updatedTag.Name.ShouldBe(newName); updatedTag.Id.ShouldBe(createdTag.Id); await client.Tags.DeleteAsync(test.Space.Id, updatedTag.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var newTicket = new Ticket { Summary = "Test Ticket", Priority = TicketPriority.Highest }; var createdTicket = await client.Tickets.CreateAsync(test.Space.WikiName, newTicket); createdTicket.ShouldNotBeNull(); createdTicket.Summary.ShouldBe(newTicket.Summary); createdTicket.Priority.ShouldBe(newTicket.Priority); var tag = await client.Tags.CreateAsync(test.Space.WikiName, new Tag { Name = "Test Tag" }); await client.Tickets.UpdateAsync(test.Space.WikiName, new Ticket { Number = createdTicket.Number, Priority = TicketPriority.Lowest, Tags = new[] { tag.Name } }); var updatedTicket = await client.Tickets.GetByNumberAsync(test.Space.WikiName, createdTicket.Number); updatedTicket.ShouldNotBeNull(); updatedTicket.Summary.ShouldBe(createdTicket.Summary); updatedTicket.Priority.ShouldBe(TicketPriority.Lowest); var ticketTags = await client.Tickets.GetTicketTagsAsync(test.Space.WikiName, createdTicket.Number); ticketTags.Single().Name.ShouldBe(tag.Name); await client.Tickets.DeleteAsync(test.Space.WikiName, createdTicket.Number); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace("File Test Space", ToolType.Files, ToolType.Tickets)) { await TestWithNoExtraData(client, test); await TestWithExtraData(client, test); await TestAttachToTicket(client, test); } }
private static async Task TestWithNoExtraData(IAssemblaClient client, DisposableSpace test) { const string fileContent = "HelloWorld"; const string fileName = "hello-world.txt"; var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, FileContent.FromString(fileContent, fileName: fileName)); uploadedFile.FileName.ShouldBe(fileName); uploadedFile.CreatedBy.ShouldBe(test.CurrentUser.Id); }
public async Task Execute(IAssemblaClient client) { var currentUser = await client.Users.GetAsync(); using (var test = await client.CreateDisposableSpace()) { var userRolesInSpace = await client.Users.UserRoles.GetAsync(test.Space.Id); userRolesInSpace.ShouldContain(ur => ur.UserId == currentUser.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var customField = await client.Tickets.CustomFields.CreateAsync(test.Space.WikiName, new CustomField { Title = "Type", IsRequired = true, Type = CustomFieldType.List, ListOptions = new[] { "Research", "Development", "Maintenance" }, }); var ticketWithRequiredCustomField = await client.Tickets.CreateAsync(test.Space.WikiName, new Ticket { Summary = "Ticket with required custom field", CustomFields = new Dictionary <string, string>() { { "Type", "Development" } } }); ticketWithRequiredCustomField.CustomFields[customField.Title].ShouldBe("Development"); var customFieldwithDefault = await client.Tickets.CustomFields.CreateAsync(test.Space.WikiName, new CustomField { Title = "TypeDefault", IsRequired = true, Type = CustomFieldType.List, ListOptions = new[] { "Research", "Development", "Maintenance" }, DefaultValue = "Maintenance" }); var ticketWithDefaultCustomField = await client.Tickets.CreateAsync(test.Space.WikiName, new Ticket { Summary = "Ticket with required custom field", CustomFields = new Dictionary <string, string>() { { "Type", "Development" } } }); ticketWithDefaultCustomField.CustomFields[customField.Title].ShouldBe("Development"); ticketWithDefaultCustomField.CustomFields[customFieldwithDefault.Title].ShouldBe("Maintenance"); var allCustomFields = await client.Tickets.CustomFields.GetAllAsync(test.Space.WikiName); allCustomFields.ShouldContain(c => c.Id == customField.Id); } }
public static async Task <DisposableSpace> CreateDisposableSpace(this IAssemblaClient client, string spaceName = "Test Space", params ToolType[] requiredTools) { var testSpace = await client.Spaces.CreateAsync(new Space { Name = spaceName }); foreach (var toolType in requiredTools) { await client.Spaces.Tools.AddAsync(testSpace.WikiName, toolType); } var currentUser = await client.Users.GetAsync(); return(new DisposableSpace(client, testSpace, currentUser)); }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace()) { var copiedSpace = await client.Spaces.CopyAsync(test.Space.WikiName, new Space { Name = "Copied Space", WikiName = "asd" }); copiedSpace.ShouldNotBeNull(); var listAll = await client.Spaces.GetAllAsync(); listAll.Count(c => c.Id == copiedSpace.Id).ShouldBe(1); await client.Spaces.DeleteAsync(copiedSpace.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var ticket = await client.Tickets.CreateAsync(test.Space.WikiName, new Ticket { Summary = "Test Ticket" }); var createdComment = await client.Tickets.Comments.CreateAsync(test.Space.WikiName, ticket.Number, new Comment { Text = "This is a comment" }); await client.Tickets.Comments.UpdateAsync(test.Space.WikiName, ticket.Number, new Comment { Id = createdComment.Id, Text = "Updated text" }); var updatedComment = await client.Tickets.Comments.GetAsync(test.Space.WikiName, ticket.Number, createdComment.Id); updatedComment.Id.ShouldBe(createdComment.Id); updatedComment.Text.ShouldBe("Updated text"); } }
private static async Task TestAttachToTicket(IAssemblaClient client, DisposableSpace test) { var ticket = await client.Tickets.CreateAsync(test.Space.Id, new Ticket { Summary = "Test Ticket" }); const string fileContent = "HelloWorld"; const string fileName = "hello-world.txt"; var content = FileContent.FromString(fileContent, fileName: fileName); var document = new File { AttachableId = ticket.Id, AttachableType = AttachableType.Ticket }; var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, content, document); uploadedFile.TicketId.ShouldBe(ticket.Id); uploadedFile.AttachableType.ShouldBe(AttachableType.Ticket); uploadedFile.IsAttachedToTicket().ShouldBeTrue(); }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Milestones)) { const string firstMilestoneName = "Test Milestone"; const string newMilestoneName = "Edited Milestone"; var createdMilestone = await client.Milestones.CreateAsync(test.Space.WikiName, new Milestone { Title = firstMilestoneName }); createdMilestone.Title.ShouldBe(firstMilestoneName); await client.Milestones.UpdateAsync(test.Space.WikiName, new Milestone { Id = createdMilestone.Id, Title = newMilestoneName }); var updatedMilestone = await client.Milestones.GetAsync(test.Space.WikiName, createdMilestone.Id); updatedMilestone.Title.ShouldBe(newMilestoneName); } }
private static async Task TestWithExtraData(IAssemblaClient client, DisposableSpace test) { var content = FileContent.FromObjectAsJson(test.CurrentUser, fileName: "user.txt"); var document = new File { Name = "Current User", FileName = "currentUser.txt", Description = "Some text to describe the file" }; var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, content, document); uploadedFile.FileName.ShouldBe(document.FileName); uploadedFile.Name.ShouldBe(document.Name); uploadedFile.Description.ShouldBe(document.Description); uploadedFile.CreatedBy.ShouldBe(test.CurrentUser.Id); var downloadedFile = await client.Files.DownloadAsync(test.Space.WikiName, uploadedFile.Id); var downloadedUser = JsonConvert.DeserializeObject <User>(Encoding.UTF8.GetString(downloadedFile)); downloadedUser.Login.ShouldBe(test.CurrentUser.Login); }
public DisposableSpace(IAssemblaClient client, Space testSpace, User currentUser) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (testSpace == null) { throw new ArgumentNullException(nameof(testSpace)); } if (currentUser == null) { throw new ArgumentNullException(nameof(currentUser)); } _client = client; Space = testSpace; CurrentUser = currentUser; }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var createdTickets = new List <Ticket>(); for (int i = 1; i <= 15; i++) { var ticket = CreateRandomTicket(i, (TicketPriority)(i % 5) + 1); createdTickets.Add(await client.Tickets.CreateAsync(test.Space.WikiName, ticket)); } var noInMilestone = await client.Tickets.GetInNoMilestoneAsync(test.Space.WikiName, pageSize : 20); foreach (var ticket in createdTickets) { noInMilestone.ShouldContain(i => i.Summary == ticket.Summary); } } }
public async Task Execute(IAssemblaClient client) { var currentUser = await client.Users.GetAsync(); _logger.LogInformation(currentUser, c => $"CURRENT: {c.Id} {c.Name} {c.Login} {c.Email}"); var user = await client.Users.GetAsync(currentUser.Login); user.Login.ShouldBe(currentUser.Login); user.Name.ShouldBe(currentUser.Name); var picture = await client.Users.GetPictyreAsync(currentUser.Id); _logger.LogInformation($"Retrieved {picture.Length} bytes"); using (var test = await client.CreateDisposableSpace()) { var usersInSpace = await client.Users.GetInSpaceAsync(test.Space.Id); usersInSpace.ShouldContain(u => u.Id == currentUser.Id); } }
public async Task Execute(IAssemblaClient client) { using (var test = await client.CreateDisposableSpace(requiredTools: ToolType.Tickets)) { var createdClosedStatus = await client.Tickets.Statuses.CreateAsync(test.Space.WikiName, new TicketStatus { Name = "Duplicate", State = TicketState.Closed }); var createdOpenStatus = await client.Tickets.Statuses.CreateAsync(test.Space.WikiName, new TicketStatus { Name = "Waiting for External", State = TicketState.Open }); var existingStatuses = await client.Tickets.Statuses.GetAllAsync(test.Space.WikiName); existingStatuses.ShouldContain(c => c.Id == createdClosedStatus.Id); existingStatuses.ShouldContain(c => c.Id == createdOpenStatus.Id); await client.Tickets.Statuses.DeleteAsync(test.Space.WikiName, createdClosedStatus.Id); await client.Tickets.Statuses.UpdateAsync(test.Space.WikiName, new TicketStatus { Id = createdOpenStatus.Id, Name = "Updated Ticket Status" }); var updatedStatus = await client.Tickets.Statuses.GetAsync(test.Space.WikiName, createdOpenStatus.Id); updatedStatus.Name.ShouldBe("Updated Ticket Status"); } }