Exemplo n.º 1
0
        public void Rendering_the_state_machine_with_graphviz()
        {
            var machine = new StateMachine<CreditRequest>(
                new ScanningStateProvider<CreditRequest>(),
                new CreditRequest());

            var renderer = new GraphvizRenderer();
            renderer.Render(machine);

            _output.WriteLine("Copy and paste the following output into http://www.webgraphviz.com/ :");

            _output.WriteLine(renderer.Output);
        }
Exemplo n.º 2
0
        public void Rendering_a_simple_graph()
        {
            var allStates = new State<LightsSwitches>[]
            {
                new LightOff(),
                new LightOnDim(),
                new LightOnFull(),
            };

            var switches = new LightsSwitches();
            var machine = new StateMachine<LightsSwitches>(new ManualStateProvider<LightsSwitches>(allStates), switches);

            var renderer = new GraphvizRenderer();
            renderer.Render(machine);

            _output.WriteLine(renderer.Output);
            renderer.Output.ShouldBe(GraphDsl);
        }
Exemplo n.º 3
0
        private async void GenerateAsync()
        {
            using (var conn = new SqlConnection(ConnectionString))
            {
                await conn.OpenAsync();


                ForeignKey[] fks = await Task.Run(() =>
                                                  _selectedTables.SelectMany(x => Model.retrieveForeignKeys(conn,
                                                                                                            x.Id))
                                                  .ToArray()
                                                  );

                String gv = await Task.Run(() => GraphvizRenderer.generateDotFile(UseSimpleNodes,
                                                                                  _selectedTables,
                                                                                  fks));


                await Task.Run(() => File.WriteAllText(GvFile,
                                                       gv));
            }

            string oldFile = Diagram;

            string newFile = String.Format(OutputFile,
                                           ++_imageFileNumber);

            await GenerateImage("png",
                                newFile);

            if (File.Exists(newFile))
            {
                Diagram = newFile;
            }
            else
            {
                Diagram = null;
            }
        }