Example #1
0
        public async Task StopSystem()
        {
            TestingLogger logger = new TestingLogger();

            if (this.ScenarioContext.TestError != null)
            {
                List <IContainerService> containers = this.TestingContext.DockerHelper.Containers.Where(c => c.Name == this.TestingContext.DockerHelper.EstateManagementContainerName).ToList();

                // The test has failed, grab the logs from all the containers
                foreach (IContainerService containerService in containers)
                {
                    ConsoleStream <String> logStream = containerService.Logs();
                    IList <String>         logData   = logStream.ReadToEnd();

                    foreach (String s in logData)
                    {
                        logger.LogInformation(s);
                    }
                }
            }

            String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");

            logger.LogInformation($"About to Stop Containers for Scenario Run - {scenarioName}");
            await this.TestingContext.DockerHelper.StopContainersForScenarioRun().ConfigureAwait(false);

            logger.LogInformation($"Containers for Scenario Run Stopped  - {scenarioName}");
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsoleControl"/> class.
        /// </summary>
        public ConsoleControl()
        {
            //  Initialise the component.
            InitializeComponent();

            //  Show diagnostics disabled by default.
            ShowDiagnostics = false;

            //  Input enabled by default.
            IsInputEnabled = true;

            //  Disable special commands by default.
            SendKeyboardCommandsToProcess = false;

            //  Initialise the keymappings.
            InitialiseKeyMappings();

            //  Handle process events.
            processInterace.OnProcessOutput += processInterace_OnProcessOutput;
            processInterace.OnProcessError  += processInterace_OnProcessError;
            processInterace.OnProcessInput  += processInterace_OnProcessInput;
            processInterace.OnProcessExit   += processInterace_OnProcessExit;

            //  Wait for key down messages on the rich text box.
            richTextBoxConsole.KeyDown += richTextBoxConsole_KeyDown;

            //just
            FConsole = new ConsoleStream(richTextBoxConsole);

            //this.richTextBoxConsole.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            //this.richTextBoxConsole.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
Example #3
0
        static void Main(string[] args)
        {
            var console      = new ConsoleStream();
            var orchestrator = new GameOrchestrator(console, console);

            orchestrator.Start();
        }
 public Console()
 {
     System.Console.SetOut(new System.IO.StreamWriter(text = new ConsoleStream {
         Console = this
     })
     {
         AutoFlush = true
     });
 }
Example #5
0
        public void Standard()
        {
            using (StringWriter writer = new StringWriter())
            {
                Console.SetOut(writer);
                ConsoleStream output = new ConsoleStream();
                output.Standard("this is a standard message");

                Assert.AreEqual("this is a standard message", writer.ToString().Trim());
            }
        }
Example #6
0
        public void Error()
        {
            using (StringWriter writer = new StringWriter())
            {
                Console.SetError(writer);
                ConsoleStream output = new ConsoleStream();
                output.Error("this is an error");

                Assert.AreEqual("this is an error", writer.ToString().Trim());
            }
        }
Example #7
0
        public void Standard()
        {
            using (StringWriter writer = new StringWriter())
            {
                Console.SetOut(writer);
                ConsoleStream output = new ConsoleStream();
                output.Standard("this is a standard message");

                Assert.AreEqual("this is a standard message", writer.ToString().Trim());
            }
        }
Example #8
0
        public void Error()
        {
            using (StringWriter writer = new StringWriter())
            {
                Console.SetError(writer);
                ConsoleStream output = new ConsoleStream();
                output.Error("this is an error");

                Assert.AreEqual("this is an error",writer.ToString().Trim());
            }
        }
Example #9
0
        /// <summary>
        ///   Reads a <see cref="ConsoleStream{T}" /> until <see cref="ConsoleStream{T}.IsFinished" /> is set to true
        ///   or a timeout occured on a read.
        /// </summary>
        /// <typeparam name="T">The type of returned items in the console stream.</typeparam>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="millisTimeout">
        ///   The amount of time to wait on a single <see cref="ConsoleStream{T}.TryRead" /> before returning.
        /// </param>
        /// <returns>A list of items read from the console stream.</returns>
        public static IList <T> ReadToEnd <T>(this ConsoleStream <T> stream, int millisTimeout = 5000) where T : class
        {
            var list = new List <T>();

            while (!stream.IsFinished)
            {
                var line = stream.TryRead(millisTimeout);
                if (null == line)
                {
                    break;
                }
                list.Add(line);
            }

            return(list);
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            #region Exercise 1 Reverse string and solution comparison

            var maxLoop = 10000;

            var a = "anitalavalatina";
            //Extension method ReverseStringBuilder
            var ex1Test1 = new Stopwatch();
            ex1Test1.Start();
            for (int i = 0; i < maxLoop; ++i)
            {
                a.ReverseStringBuilder();
            }
            ex1Test1.Stop();

            //Extension method ReverseStringArray
            var ex1Test2 = new Stopwatch();

            ex1Test2.Start();
            for (int i = 0; i < maxLoop; ++i)
            {
                a.ReverseStringArray();
            }
            ex1Test2.Stop();

            //Extension method ReverseStringDirectArray
            var ex1Test3 = new Stopwatch();

            ex1Test3.Start();
            for (int i = 0; i < maxLoop; ++i)
            {
                a.ReverseStringDirectArray();
            }
            ex1Test3.Stop();

            //Built-in linq
            var ex1Test4 = new Stopwatch();
            ex1Test4.Start();
            for (int i = 0; i < maxLoop; ++i)
            {
                a.Reverse().ToString();
            }
            ex1Test4.Stop();

            Console.WriteLine("EXCERCISE 1 Reverse string method comparison  TESTS {0} executions", maxLoop);
            Console.WriteLine("String:{0}, Reverse:{1}", a, a.Reverse().ToString());

            Console.WriteLine("Extension method ReverseStringBuilder: {0}", ex1Test1.Elapsed.TotalMilliseconds.ToString("G0"));
            Console.WriteLine("Extension method ReverseStringArray: {0}", ex1Test2.Elapsed.TotalMilliseconds.ToString("G0"));
            Console.WriteLine("Extension method ReverseStringDirectArray: {0}", ex1Test3.Elapsed.TotalMilliseconds.ToString("G0"));
            Console.WriteLine("Linq Build-in: {0}", ex1Test4.Elapsed.TotalMilliseconds.ToString("G0"));
            Console.WriteLine();
            #endregion

            #region Exercise 2 Fibonacci
            Console.WriteLine("EXCERCISE 2 Fibonacci functionality");
            Fibonacci fibo   = new Fibonacci();
            long      fTest1 = 4;
            long      fTest2 = 9;
            Console.WriteLine("f({0}) = {1}", fTest1, fibo.GetFibonacci(fTest1));
            Console.WriteLine("f({0}) = {1}", fTest2, fibo.GetFibonacci(fTest2));
            #endregion

            #region Exercise 3
            //The common way
            Console.WriteLine("EXCERCISE 3 table multiplication");
            Console.WriteLine("--------The common way -------------");
            var TableNumber = 12;
            var MaxTimes    = 12;
            var ex3Test1    = new Stopwatch();
            ex3Test1.Start();
            for (int times = 1; times <= MaxTimes; ++times)
            {
                Console.WriteLine("{0} X {1} = {2}", TableNumber, times, TableNumber * times);
            }
            ex3Test1.Stop();
            Console.WriteLine();

            Console.WriteLine("-----------Kind of Dynamic way using interfaces and separation of concerns---------");
            var ex3Test2 = new Stopwatch();
            ex3Test2.Start();
            var generator = new MultiplicationTableGenerator();
            var rawTable  = generator.GetTable(TableNumber, MaxTimes);
            var printer   = new ConsoleStream();
            printer.Print(rawTable);
            ex3Test2.Stop();

            Console.WriteLine("Ex1: {0}", ex3Test1.Elapsed.TotalMilliseconds.ToString("G0"));
            Console.WriteLine("Ex2: {0}", ex3Test2.Elapsed.TotalMilliseconds.ToString("G0"));

            Console.ReadLine();
            #endregion
        }
Example #11
0
        public CSRepl()
        {
            InitializeComponent();

            textEditor = new CSReplTextEditor();
            textEditor.FontFamily = new FontFamily("Consolas");
            var convertFrom = new FontSizeConverter().ConvertFrom("10pt");
            if (convertFrom != null) textEditor.FontSize = (double)convertFrom;
            textEditor.TextArea.PreviewKeyDown += TextAreaOnPreviewKeyDown;
            textEditor.IsEnabled = false;
            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
            textEditor.FileName = "repl.csx";
            textEditor.Repl = this;
            this.Content = textEditor;

            commandHistory = new CommandHistory();

            var errorStream = new ConsoleStream(TextType.Error, Write);
            var errorWriter = new StreamWriter(errorStream);
            errorWriter.AutoFlush = true;
            Console.SetError(errorWriter);

            var stdoutStream = new ConsoleStream(TextType.Output, Write);
            var stdoutWriter = new StreamWriter(stdoutStream);
            stdoutWriter.AutoFlush = true;
            Console.SetOut(stdoutWriter);

            ShowConsoleOutput = true;
            ResetColor();

            //supress duplicate using warnings
            SuppressWarning("CS0105");

            //clears the console and prints the headers
            // when clearing the initial transormers are removed too but we want to keep them
            initialTransformers = textEditor.TextArea.TextView.LineTransformers.ToArray();
            Clear();
        }
 public Console()
 {
     System.Console.SetOut(new System.IO.StreamWriter(text = new ConsoleStream { Console = this }) { AutoFlush = true });
 }