public void WhenThereIsNoOutputConfigured_ThrowApplicationException()
        {
            //Arrange
            var helloWorld = new HelloWorldBuilder().Build();
            //Act
            Action print = () => helloWorld.Print();

            //Assert
            print.Should().Throw <ApplicationException>();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var hello = new HelloWorldBuilder()
                        .UseLanguage(Language.English)
                        .UseMessage("Hello there!")
                        .PrintToConsole(configuration => configuration
                                        .WithForegroundColor(ConsoleColor.Cyan)
                                        .WithBackgroundColor(ConsoleColor.DarkGreen))
                        .Build();

            hello.Print();
        }
        public void WhenPrintIsCalled_RaiseOnPrintEvent()
        {
            //Arrange
            var message    = "Hello, World!";
            var helloWorld = new HelloWorldBuilder()
                             .UseMessage(message)
                             .PrintToConsole()
                             .Build();

            string messageFromEvent = null;

            helloWorld.OnPrint += (sender, args) => messageFromEvent = args.Message;
            //Act
            helloWorld.Print();
            //Assert
            messageFromEvent.Should().BeEquivalentTo(message);
        }
Ejemplo n.º 4
0
        private static void RunHelloWorld()
        {
            const string FileName = "HelloWorld";
            const string SrcFile  = FileName + ".cs";
            const string ExeFile  = FileName + ".exe";

            // Create code graph
            CodeCompileUnit codeGraph = HelloWorldBuilder.Build();

            // Generate file based on code graph
            FileGenerator.CreateFile(codeGraph, SrcFile);

            // Compile generated source file into an executable output file
            CodeCompiler.Compile(SrcFile, ExeFile);

            // Execute compiled app
            Process.Start(ExeFile);
        }
Ejemplo n.º 5
0
 public DIController(HelloWorldBuilder builder)
 {
     Builder = builder;
 }
Ejemplo n.º 6
0
 public DIController(HelloWorldBuilder builder)
 {
     Builder = builder;
 }