示例#1
0
        private static void ShowError(IConsole console, ConsoleReader reader, ConsoleString msg)
        {
            var text = reader.Text;

            reader.Text = "";

            var red = Color.NoColor.WithForeground("red");

            var message = new ConsoleString(msg.Select(s => new ConsoleStringSegment(s.Content, s.HasColor ? s.Color : red)));

            console.TemporaryShift(c => c.Write(message));

            console.TemporaryShift(c => c.ReadKey(true));
            console.TemporaryShift(c => c.Write(new string(' ', message.Length)));

            reader.Text = text;
        }
示例#2
0
        private static void ValidateStringCharacteristics(string expected, ConsoleString actual)
        {
            Assert.AreEqual(expected, string.Join("", actual.Select(c => c.Value)));
            Assert.AreEqual(expected, actual.ToString());
            Assert.AreEqual(expected.Length, actual.Length);

            var expectedEnumerator = expected.GetEnumerator();

            foreach (var character in actual)
            {
                expectedEnumerator.MoveNext();
                Assert.AreEqual(expectedEnumerator.Current + "", character.ToString());
                Assert.AreEqual(expectedEnumerator.Current, character.Value);
                character.Write();
            }

            Assert.IsFalse(expectedEnumerator.MoveNext());
        }
示例#3
0
        private static void ValidateStringCharacteristics(string expected, ConsoleString actual)
        {
            Assert.AreEqual(expected, string.Join("", actual.Select(c => c.Value)));
            Assert.AreEqual(0, actual.CompareTo(expected));
            Assert.AreEqual(expected, actual.ToString());
            Assert.AreEqual(expected.Length, actual.Length);

            var expectedEnumerator = expected.GetEnumerator();
            foreach (var character in actual)
            {
                expectedEnumerator.MoveNext();
                Assert.AreEqual(expectedEnumerator.Current+"", character.ToString());
                Assert.AreEqual(expectedEnumerator.Current, character.Value);
                character.Write();
            }

            Assert.IsFalse(expectedEnumerator.MoveNext());
        }