public void Simple_Flow_Is_Serialized_With_Full_Abbreviations() { TypeAbbreviationCache.Clear(); TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, useFullName: true, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestJsNode>() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); Console.WriteLine(definition); definition.ShouldNotBeNull().ShouldNotBeEmpty(); definition.ShouldContain("Banzai.Json.Test"); }
public void Flow_With_ShouldExecuteBlock_Is_Deserialized() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >().SetShouldExecuteBlock <ShouldNotExecuteTestBlock>() .AddChild <ITestJsNode>() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition); deserializedComponent.ShouldNotBeNull(); deserializedComponent.Children[0].ShouldExecuteBlockType.ShouldEqual(typeof(ShouldNotExecuteTestBlock)); }
public void Simple_Flow_Is_Serialized_With_Full_Abbreviations() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, true, false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); _testOutputHelper.WriteLine(definition); definition.Should().NotBeNullOrEmpty(); definition.Should().Contain("Banzai.Serialization.SystemJson.Test"); }
public void Flow_With_ShouldExecuteBlock_Is_Serialized_With_Abbreviations() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >().SetShouldExecuteBlock <ShouldNotExecuteTestBlock>() .AddChild <ITestJsNode>() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); Console.WriteLine(definition); definition.ShouldNotBeNull().ShouldNotBeEmpty(); definition.ShouldContain("\"ShouldExecuteBlockType\":\"ShouldNotExecuteTestBlock\""); }
public void Simple_Flow_Is_Deserialized() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); var deserializedComponent = serializer.Deserialize <object>(definition); deserializedComponent.Should().NotBeNull(); deserializedComponent.Children[0].Children.Count.Should().Be(1); }
public void Simple_Flow_With_ShouldExecuteJavaScript_Is_Deserialized() { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestJsNode>() .AddChild <ITestNode2>() .ForChild <ITestJsNode>() .SetShouldExecuteJavaScript("var x = 1;"); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition); deserializedComponent.ShouldNotBeNull(); var pipelineComponent = deserializedComponent.Children[0]; pipelineComponent.Children.Count.ShouldEqual(2); var jsNode = pipelineComponent.Children[0]; jsNode.GetShouldExecuteJavaScript().ShouldEqual("var x = 1;"); }
public async void Deserialized_Flow_Component_Can_Be_Built_And_Run() { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); containerBuilder.RegisterBanzaiNodes(typeof(JavaScriptMetaDataBuilder).Assembly, true); var flowBuilder = new FlowBuilder <TestObjectA>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <TestObjectA> >() .AddChild <ITestJsNode2>() .AddChild <ITestNode2>() .ForChild <ITestJsNode2>() .SetExecutedJavaScript("context.Subject.TestValueString = 'Hello JavaScript';"); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); Console.WriteLine(definition); FlowComponent <TestObjectA> deserializedComponent = serializer.Deserialize <TestObjectA>(definition); deserializedComponent.ShouldNotBeNull(); flowBuilder.RootComponent = deserializedComponent; flowBuilder.Register(); var container = containerBuilder.Build(); var factory = container.Resolve <INodeFactory <TestObjectA> >(); var flowRootNode = factory.BuildFlow("TestFlow1"); NodeResult result = await flowRootNode.ExecuteAsync(new TestObjectA()); result.Status.ShouldEqual(NodeResultStatus.Succeeded); var subject = result.GetSubjectAs <TestObjectA>(); subject.TestValueString.ShouldEqual("Hello JavaScript"); }
public void Simple_Flow_Is_Serialized() { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestJsNode>().SetExecutedJavaScript("var x = 1;") .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); definition.ShouldNotBeNull().ShouldNotBeEmpty(); }
public async void Deserialized_Flow_Component_Can_Be_Built_And_Run() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlow1") .AddRoot <IPipelineNode <object> >() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); string definition = serializer.Serialize(rootComponent); Console.WriteLine(definition); FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition); flowBuilder.RootComponent = deserializedComponent; flowBuilder.Register(); var container = containerBuilder.Build(); var factory = container.Resolve <INodeFactory <object> >(); var flowRootNode = factory.BuildFlow("TestFlow1"); NodeResult result = await flowRootNode.ExecuteAsync(new object()); result.Status.ShouldEqual(NodeResultStatus.Succeeded); }
public async Task Deserialized_Flow_Component_With_ShouldExecuteBlock_Can_Be_Built_And_Attempted() { TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true); var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder)); flowBuilder.CreateFlow("TestFlowDeserializeShouldExecute") .AddRoot <IPipelineNode <object> >().SetShouldExecuteBlock <ShouldNotExecuteTestBlock>() .AddChild <ITestNode2>(); var rootComponent = flowBuilder.RootComponent; var serializer = new JsonComponentSerializer(); var definition = serializer.Serialize(rootComponent); var deserializedComponent = serializer.Deserialize <object>(definition); flowBuilder.RootComponent = deserializedComponent; flowBuilder.Register(); var container = containerBuilder.Build(); var factory = container.Resolve <INodeFactory <object> >(); var flowRootNode = factory.BuildFlow("TestFlowDeserializeShouldExecute"); var result = await flowRootNode.ExecuteAsync(new object()); result.Status.Should().Be(NodeResultStatus.NotRun); }