public Task <bool> TryAddCaseFileItem(CaseFileItemInstance caseFileItem, CasePlanInstanceAggregate casePlanInstance, CancellationToken token) { if (casePlanInstance.IsFileExists(caseFileItem.Id)) { return(Task.FromResult(false)); } casePlanInstance.TryAddCaseFileItem(caseFileItem.Id, CaseFileItemType, "value"); return(Task.FromResult(true)); }
public async Task When_Execute_FileItem() { var instance = CasePlanInstanceBuilder.New("1", "firstCase") .AddFileItem("2", "directory", (_) => { _.DefinitionType = CMMNConstants.ContentManagementTypes.FAKE_CMIS_DIRECTORY; }) .AddEmptyTask("3", "emptytask", (_) => { _.AddEntryCriteria("entry", (__) => { __.AddFileItemOnPart("2", CMMNTransitions.AddChild); }); }) .Build(); var jobServer = FakeCaseJobServer.New(); try { await jobServer.RegisterCasePlanInstance(instance, CancellationToken.None); jobServer.Start(); await jobServer.EnqueueCasePlanInstance("1", CancellationToken.None); await jobServer.PublishExternalEvt("addchild", "1", CaseFileItemInstance.BuildId("1", "2"), new Dictionary <string, string> { { "fileId", "file" } }, CancellationToken.None); var casePlanInstance = await jobServer.MonitorCasePlanInstance("1", (c) => { if (c == null) { return(false); } return(c.State == CaseStates.Completed); }, CancellationToken.None); var firstFileItem = casePlanInstance.FileItems.ElementAt(0) as CaseFileItemInstance; var firstEmptyTask = casePlanInstance.StageContent.Children.ElementAt(0) as EmptyTaskElementInstance; Assert.Equal(CaseStates.Completed, casePlanInstance.State); Assert.Equal(CaseFileItemStates.Available, firstFileItem.State); Assert.Equal(TaskStageStates.Completed, firstEmptyTask.State); } finally { jobServer.Stop(); } }
protected override string BuildId() { return(CaseFileItemInstance.BuildId(CasePlanInstanceId, EltId)); }