public async Task WorkItemManager_ExecuteCommand_Invoke() { // arrange var manager = new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String", initialValue: "a"), PropertyDescriptor.Create("B", "String"), }, stages: new StageDescriptor[] { new StageDescriptor("stage-aa", new PropertyValueConditionDescriptor("A", "aa"), Array.Empty <StagePropertyDescriptor>(), new CommandDescriptor[] { new ChangePropertyValueCommandDescriptor("make-bb", "MakeBBC", "B", "bbc") }), }) )); var issue = await manager.CreateAsync("FOO", "BAR", new Property[] { new Property("A", "String", "aa"), new Property("B", "String", "bb"), }); // act var result = await manager.ExecuteCommandAsync("FOO", issue.Id, "make-bb"); // assert Assert.True(result.Success); Assert.Collection(result.UpdatedWorkItem.Properties, p => { Assert.Equal("aa", p.Value); Assert.Equal("A", p.Name); }, p => { Assert.Equal("bbc", p.Value); Assert.Equal("B", p.Name); } ); }
public async Task WorkItemManager_CreateTemplate_WithDefaultValues() { // arrange var workItemManager = new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String", initialValue: "a"), PropertyDescriptor.Create("B", "String"), }) )); // act var template = await workItemManager.CreateTemplateAsync("FOO", "BAR"); // assert Assert.NotNull(template); Assert.Equal("BAR", template.WorkItemType); Assert.Collection(template.Properties, p => { Assert.Equal("A", p.Name); Assert.Equal("a", p.Value); }, p => { Assert.Equal("B", p.Name); Assert.Equal("", p.Value); } ); }
private static WorkItemManager BuildManager() { return(new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String"), PropertyDescriptor.Create("B", "String"), }) ))); }
private static WorkItemManager BuildManager() { return(new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String", validators: new ValidatorDescriptor[] { new StringLengthValidatorDescriptor(3, 5), }), PropertyDescriptor.Create("B", "String"), }) ))); }
private static WorkItemManager BuildManager() { return(new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String", validators: new ValidatorDescriptor[] { new MandatoryValidatorDescriptor(), }), PropertyDescriptor.Create("B", "String", valueProvider: new EnumValueProviderDescriptor(new EnumValue("d", "D"), new EnumValue("c", "C"))), PropertyDescriptor.Create("C", "String", propertyType: PropertyType.MultipleValueFromProvider, valueProvider: new EnumValueProviderDescriptor(new EnumValue("d", "D"), new EnumValue("c", "C"))), }) ))); }
private static WorkItemManager BuildManager() { return(new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String"), PropertyDescriptor.Create("B", "String", isEditable: false), }, stages: new StageDescriptor[] { new StageDescriptor("default", new PropertyValueConditionDescriptor("A", "aa"), Array.Empty <StagePropertyDescriptor>(), new CommandDescriptor[] { new ChangePropertyValueCommandDescriptor("set", "SET B to a", "B", "a") }) }) ))); }
public async Task WorkItemManager_ExecuteCommand_NotFound() { // arrange var manager = new WorkItemManager(new InMemoryDataProvider(), new InMemoryDescriptorProvider( WorkItemDescriptor.Create("BAR", new PropertyDescriptor[] { PropertyDescriptor.Create("A", "String", initialValue: "a"), PropertyDescriptor.Create("B", "String"), }) )); var issue = await manager.CreateAsync("FOO", "BAR", new Property[] { new Property("A", "String", "aa"), new Property("B", "String", "bb"), }); // act var result = await manager.ExecuteCommandAsync("FOO", issue.Id, "Close"); // assert Assert.False(result.Success); }