public void PostsToTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ActivityTypesClient(connection); var newActivityType = new NewActivityType("name", ActivityTypeIcon.Bell); client.Create(newActivityType); connection.Received().Post <ActivityType>(Arg.Is <Uri>(u => u.ToString() == "activityTypes"), Arg.Is <NewActivityType>(nc => nc.Name == "name" && nc.IconKey == ActivityTypeIcon.Bell)); }
/// <summary> /// Add a new custom activity to this workflow instance /// </summary> /// <param name="instance"></param> private void AddNewActivity() { //create an instance of the specified new activity if (NewActivityType != null && NumberProperty != null) { //create a workflow changes object WorkflowChanges wfChanges = new WorkflowChanges(this); //find the SequenceActivity that is a placeholder //for new activities CompositeActivity placeholder = wfChanges.TransientWorkflow.GetActivityByName( "sequencePlaceholder") as CompositeActivity; if (placeholder == null) { return; } //construct an instance of the activity //using reflection ConstructorInfo ctor = NewActivityType.GetConstructor(Type.EmptyTypes); Activity newActivity = ctor.Invoke(null) as Activity; //bind the TestNumber property of the activity //to the TestNumber property of the workflow newActivity.SetBinding(NumberProperty, new ActivityBind(this.Name, "TestNumber")); //add the new custom activity to the workflow placeholder.Activities.Add(newActivity); //validate the structural changes before applying them ValidationErrorCollection errors = wfChanges.Validate(); if (errors.Count == 0) { //apply the changes to the workflow instance this.ApplyWorkflowChanges(wfChanges); } else { //the proposed changes are not valid foreach (ValidationError error in errors) { Console.WriteLine(error.ToString()); } } } }
public async Task CanCreate() { var pipedrive = Helper.GetAuthenticatedClient(); var fixture = pipedrive.ActivityType; var newActivityType = new NewActivityType("name", ActivityTypeIcon.Addressbook); var activityType = await fixture.Create(newActivityType); Assert.NotNull(activityType); var retrievedAll = await fixture.GetAll(); var retrieved = retrievedAll.Where(ac => ac.Name == "name").FirstOrDefault(); Assert.NotNull(retrieved); // Cleanup await fixture.Delete(activityType.Id); }
public async Task CanEdit() { var pipedrive = Helper.GetAuthenticatedClient(); var fixture = pipedrive.ActivityType; var newActivityType = new NewActivityType("new-name", ActivityTypeIcon.Plane); var activityType = await fixture.Create(newActivityType); var editActivityType = activityType.ToUpdate(); editActivityType.Name = "updated-name"; editActivityType.IconKey = ActivityTypeIcon.Sound; var updatedActivityType = await fixture.Edit(activityType.Id, editActivityType); Assert.Equal("updated-name", updatedActivityType.Name); Assert.Equal(ActivityTypeIcon.Sound, updatedActivityType.IconKey); // Cleanup await fixture.Delete(updatedActivityType.Id); }
public async Task CanDelete() { var pipedrive = Helper.GetAuthenticatedClient(); var fixture = pipedrive.ActivityType; var newActivityType = new NewActivityType("new-name", ActivityTypeIcon.Signpost); var activityType = await fixture.Create(newActivityType); var createdActivityTypes = await fixture.GetAll(); var createdActivityType = createdActivityTypes.Where(ac => ac.Name == "new-name").FirstOrDefault(); Assert.NotNull(createdActivityType); await fixture.Delete(createdActivityType.Id); var deletedActivityTypes = await fixture.GetAll(); var deletedActivityType = deletedActivityTypes.Where(ac => ac.Name == "new-name").FirstOrDefault(); Assert.False(deletedActivityType.ActiveFlag); }