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

            //Assert
            print.Should().Throw <ApplicationException>();
        }
        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);
        }
Esempio 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);
        }
Esempio n. 5
0
 public DIController(HelloWorldBuilder builder)
 {
     Builder = builder;
 }
Esempio n. 6
0
 public DIController(HelloWorldBuilder builder)
 {
     Builder = builder;
 }