コード例 #1
0
        public async Task <FlowResult <FlowInstance> > InitFlowAsync(InitFlowModel initModel)
        {
            var result = await HandleRequestAsync(new InitFlowRequest(StateManager, InstanceService, StepService),
                                                  initModel);

            return(result);
        }
コード例 #2
0
        public async Task FlowInstance_CorrectCreation_MustHaveInitializingStep()
        {
            //Arrange
            var stateManager = new MockState().MockStateManager();
            var flowManager  = new ManagerFactory().GetFlowManager(stateManager);
            var initModel    = new InitFlowModel()
            {
                TypeId        = MockData.GetFlowTypes()[0].Id,
                AccessPhrase  = "secure",
                InitializerId = "1",
                Payload       = "null",
                Title         = "Hire devlnull"
            };
            //Act
            var act = await flowManager.InitFlowAsync(initModel);

            var flowReportManager = new ManagerFactory().GetFlowReportManager(stateManager);
            var steps             = await flowReportManager.GetInstanceStepsAsync(act.Result.Id);

            //Assert
            LogTestInfo(initModel, act);
            Assert.True(act.Succeeded);
            Assert.NotNull(act.Result);
            Assert.NotEmpty(steps.Result);
        }
コード例 #3
0
        public async Task <FlowResult <FlowInstance> > CreateFlowInstanceAsync(InitFlowModel model)
        {
            var set     = StateManager.GetFlowSet <FlowInstance>();
            var typeSet = StateManager.GetFlowSet <FlowType>();

            var type = await typeSet.GetByIdAsync(model.TypeId);

            if (type == null)
            {
                return(FlowResult <FlowInstance>
                       .Failed(new FlowError(FlowErrors.ItemNotFound, nameof(type))));
            }

            var entity = FlowEntity.InitializeType(new FlowInstance()
            {
                Title         = model.Title,
                Payload       = model.Payload,
                TypeId        = type.Id,
                InitializerId = model.InitializerId,
                AccessPhrase  = model.AccessPhrase,
            });

            var result = await set.CreateAsync(entity);

            return(FlowResult <FlowInstance> .Successful(result));
        }
コード例 #4
0
        public async Task IntiFlowInstance_EmptyPayload_MustWarn()
        {
            //Arrange
            var stateManager = new MockState().MockStateManager();
            var flowManager  = new ManagerFactory().GetFlowManager(stateManager);
            var initModel    = new InitFlowModel()
            {
                TypeId        = MockData.GetFlowTypes()[0].Id,
                AccessPhrase  = "secure",
                InitializerId = "1",
                Payload       = null,
                Title         = "Hire devlnull"
            };
            //Act
            var act = await flowManager.InitFlowAsync(initModel);

            //Assert
            LogTestInfo(initModel, act);
            Assert.True(act.Warned);
            Assert.NotEmpty(act.Warns);
        }