Ejemplo n.º 1
0
        public void TestEmptyFactorsToTokensReturnsInput()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> >();
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(55);

            Assert.AreEqual("55", actual);
        }
Ejemplo n.º 2
0
        public void TestOutputSingleFactorTest()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(3, "Fizz")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(3);

            Assert.AreEqual("Fizz", actual);
        }
Ejemplo n.º 3
0
        public void TestDuplicateFactorsAreAllowed()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(2, "Chicken"),
                new KeyValuePair <int, string>(2, "Turkey")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(2);

            Assert.AreEqual("ChickenTurkey", actual);
        }
Ejemplo n.º 4
0
        public void TestNoFactorsReturnsInput()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(2, "Bear"),
                new KeyValuePair <int, string>(3, "Deer")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(7);

            Assert.AreEqual("7", actual);
        }
Ejemplo n.º 5
0
        public void TestZeroAcceptsAllFactors()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(2, "Bear"),
                new KeyValuePair <int, string>(3, "Deer")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(0);

            Assert.AreEqual("BearDeer", actual);
        }
Ejemplo n.º 6
0
        public void TestFactorOnNegativeInput()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(2, "Cat"),
                new KeyValuePair <int, string>(3, "Duck")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(-12);

            Assert.AreEqual("CatDuck", actual);
        }
Ejemplo n.º 7
0
        public void TestOutputMultipleFactorsOrderIsRespectedTest()
        {
            IList <KeyValuePair <int, string> > factorsToTokens = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(4, "Bang"),
                new KeyValuePair <int, string>(2, "Fizz"),
                new KeyValuePair <int, string>(3, "Buzz")
            };
            OutputTokenizer outputTokenizer = new OutputTokenizer(factorsToTokens);
            string          actual          = outputTokenizer.GetOutputString(12);

            Assert.AreEqual("BangFizzBuzz", actual);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            WindowCreateInfo windowCI = new WindowCreateInfo()
            {
                X            = 1920,
                Y            = 100,
                WindowWidth  = 1920,
                WindowHeight = 1920,
                WindowTitle  = "Veldrid Tutorial"
            };
            Sdl2Window window = VeldridStartup.CreateWindow(ref windowCI);

            _graphicsDevice = VeldridStartup.CreateGraphicsDevice(window, GraphicsBackend.OpenGL);

            CreateResources(window);

            var pty         = new LinuxPty();
            var readStream  = new ConsoleLoggingStream(pty.ReadStream, "READ");
            var writeStream = new ConsoleLoggingStream(pty.WriteStream, "WRIT");

            var charsWidth  = (int)(window.Width / (float)_fontAtlas.CellWidth);
            var charsHeight = (int)(window.Height / (float)_fontAtlas.CellHeight);

            pty.SetSize(charsWidth, charsHeight);

            _tokenizer = new OutputTokenizer(_textLayout);

            var inputProcessor = new InputKeyStreamer {
                OutStream = writeStream
            };

#pragma warning disable 4014
            PipePtyToScreen(readStream);
#pragma warning restore 4014

            while (window.Exists)
            {
                var input = window.PumpEvents();
                inputProcessor.ProcessToStream(input);

                if (window.Exists)
                {
                    Draw();
                }
            }

            DisposeResources();
        }