コード例 #1
0
        public async void should_correctly_save_and_load_file()
        {
            var filename = "example_save.bin";

            Console.WriteLine("{0}/{1}", Environment.CurrentDirectory, filename);

            var fileEndpoint = new FileEndpoint(filename);
            var serializer   = new JsonSerializer();
            var deserializer = new JsonDeserializer();

            var dummyData = GameData.CreateRandom();
            var output    = serializer.Serialize(dummyData);

            await fileEndpoint.Send(output);

            var content = await fileEndpoint.Receive();

            var deserializedDummyData = deserializer.Deserialize <GameData>(content);

            Assert.Equal(dummyData, deserializedDummyData);
        }
コード例 #2
0
        public async void should_correctly_fork_stream_for_object_with_builder()
        {
            var expectedString = "hello there some new pipeline";
            var data           = "hello";
            var dummyPipeline  = new PipelineBuilder()
                                 .StartFromInput()
                                 .ThenInvoke(x => Task.FromResult((object)(x + " there")))
                                 .ThenInvoke(x => Task.FromResult((object)(x + " some")))
                                 .ThenInvoke(x => Task.FromResult((object)(x + " old")))
                                 .ThenInvoke(x => Task.FromResult((object)(x + " pipeline")))
                                 .Build();

            var forkedPipeline = new PipelineBuilder()
                                 .ForkObjectFrom(dummyPipeline, 2)
                                 .ThenInvoke(x => Task.FromResult((object)(x + " new")))
                                 .ThenInvoke(x => Task.FromResult((object)(x + " pipeline")))
                                 .Build();

            var actualOutput = await forkedPipeline.Execute(data);

            Assert.Equal(expectedString, actualOutput);
        }
コード例 #3
0
        public async void should_wiretap_correctly()
        {
            var dummyPipeline = new PipelineBuilder()
                                .StartFrom(x => Task.FromResult((object)"hello"))
                                .ThenInvoke(x => Task.FromResult((object)"there"))
                                .Build()
                                .AsWireTappable();

            var ranCount = 0;

            dummyPipeline.StartWiretap(1, (x, y) =>
            {
                Assert.Equal("hello", x);
                ranCount++;
            });
            dummyPipeline.StartWiretap(2, (x, y) =>
            {
                Assert.Equal("there", x);
                ranCount++;
            });

            dummyPipeline.Execute();
            Assert.Equal(2, ranCount);
        }
コード例 #4
0
        public async void should_correctly_build_new_pipeline_class()
        {
            var dummyPipeline = new DummyBuiltPipeline();

            Assert.Equal(3, dummyPipeline.Steps.Count());
        }