Пример #1
0
        public async Task Run_WhenNoDataIsCahced_RunsChildActivitiy()
        {
            var authToken = new AuthorizationToken {
                Token = "1"
            };
            var activity        = New <Filter_Object_List_By_Incoming_Message_v1>();
            var activityContext = new ActivityContext
            {
                HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(),
                ActivityPayload = new ActivityPayload
                {
                    CrateStorage       = new CrateStorage(),
                    ChildrenActivities = new List <ActivityPayload>()
                },
                AuthorizationToken = authToken
            };
            var containerExecutionContext = HealthMonitor_FixtureData.ExecutionContextWithOnlyOperationalState();
            //Initial and followup config
            await activity.Configure(activityContext);

            activityContext.ActivityPayload.CrateStorage.UpdateControls <Filter_Object_List_By_Incoming_Message_v1.ActivityUi>(x => x.DataSourceSelector.Value = ActivityTemplates[0].Id.ToString());
            await activity.Configure(activityContext);

            // var childActivity = new ActivityPayload
            // {
            //     ActivityTemplate = ActivityTemplates[0]
            // };
            // AddChild(activityContext.ActivityPayload, childActivity, 1);

            //Run
            await activity.Run(activityContext, containerExecutionContext);

            var operationalState = containerExecutionContext.PayloadStorage.FirstCrate <OperationalStateCM>().Content;

            Assert.AreEqual(ActivityResponse.Success.ToString(), operationalState.CurrentActivityResponse.Type, "Child activities should be ran during normal execution flow");
        }
Пример #2
0
        public async Task Run_Always_FiltersDataAndSkipsChildActivities()
        {
            //Setup
            var containerExecutionContext = HealthMonitor_FixtureData.ExecutionContextWithOnlyOperationalState();

            containerExecutionContext.PayloadStorage.Add(Crate <KeyValueListCM> .FromContent("Message is here", new KeyValueListCM(new KeyValueDTO("Message", "This message should be checked for keywords"))));
            var authToken = new AuthorizationToken {
                Token = "1"
            };
            var activity        = New <Filter_Object_List_By_Incoming_Message_v1>();
            var activityContext = new ActivityContext
            {
                HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(),
                ActivityPayload = new ActivityPayload
                {
                    CrateStorage       = new CrateStorage(),
                    ChildrenActivities = new List <ActivityPayload>()
                },
                AuthorizationToken = authToken
            };
            //Initial and followup config
            await activity.Configure(activityContext);

            activityContext.ActivityPayload.CrateStorage.UpdateControls <Filter_Object_List_By_Incoming_Message_v1.ActivityUi>(x =>
            {
                x.DataSourceSelector.Value         = ActivityTemplates[0].Id.ToString();
                x.IncomingTextSelector.selectedKey = "Message";
                x.IncomingTextSelector.Value       = "This message should be checked for keywords";
            });
            await activity.Configure(activityContext);

            var crateStorage        = activityContext.ActivityPayload.CrateStorage;
            var configurationValues = crateStorage.FirstCrate <KeyValueListCM>(x => x.Label == "Configuration Values");

            configurationValues.Content.Values.First(x => x.Key == "Cache Created At").Value = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
            crateStorage.Add(Crate <StandardTableDataCM> .FromContent("Cached table",
                                                                      new StandardTableDataCM
            {
                FirstRowHeaders = true,
                Table           = new List <TableRowDTO>
                {
                    new TableRowDTO {
                        Row = new List <TableCellDTO> {
                            new TableCellDTO {
                                Cell = new KeyValueDTO("Header", "Header")
                            }
                        }
                    },
                    //Will pass filter
                    new TableRowDTO {
                        Row = new List <TableCellDTO> {
                            new TableCellDTO {
                                Cell = new KeyValueDTO("Header", "message")
                            }
                        }
                    },
                    new TableRowDTO {
                        Row = new List <TableCellDTO> {
                            new TableCellDTO {
                                Cell = new KeyValueDTO("Header", "checked")
                            }
                        }
                    },
                    //Won't pass filter
                    new TableRowDTO {
                        Row = new List <TableCellDTO> {
                            new TableCellDTO {
                                Cell = new KeyValueDTO("Header", "nothing")
                            }
                        }
                    },
                    new TableRowDTO {
                        Row = new List <TableCellDTO> {
                            new TableCellDTO {
                                Cell = new KeyValueDTO("Header", "anything")
                            }
                        }
                    }
                }
            }));
            await activity.Configure(activityContext);

            var childActivity = new ActivityPayload
            {
                ActivityTemplate = Mapper.Map <ActivityTemplateSummaryDTO>(ActivityTemplates[0])
            };

            AddChild(activityContext.ActivityPayload, childActivity, 1);
            //Run
            await activity.Run(activityContext, containerExecutionContext);

            var operationalState = containerExecutionContext.PayloadStorage.FirstCrate <OperationalStateCM>().Content;

            Assert.AreEqual(ActivityResponse.SkipChildren.ToString(), operationalState.CurrentActivityResponse.Type, "Child activities should be skipped during normal execution flow");
            var filteredData = containerExecutionContext.PayloadStorage.FirstCrate <StandardTableDataCM>().Content;

            Assert.AreEqual(3, filteredData.Table.Count, "Filtered data doesn't contain proper row count");
        }