Пример #1
0
        public void WriteLine_ShouldWriteUsingNextColour()
        {
            //Arrange
            var testConsole        = new TestConsole();
            var translateOutputter = new TranslateOutput(testConsole);

            //Act
            for (var language = 0; language <= 20; language++)
            {
                translateOutputter.WriteLine(language.ToString(), "s");
            }
            translateOutputter.WriteLine("5", "s");
            translateOutputter.WriteLine("10", "s");

            //Assert
            for (var language = 0; language < 15; language++)
            {
                //Ignore black (0)
                var expectedColour = (ConsoleColor)(language + 1);
                AssertColour(testConsole, language, expectedColour);
            }

            //once we've exhausted all 15 colours then should start again at 1
            AssertColour(testConsole, 15, (ConsoleColor)1);
            AssertColour(testConsole, 16, (ConsoleColor)2);
            AssertColour(testConsole, 17, (ConsoleColor)3);
            AssertColour(testConsole, 18, (ConsoleColor)4);
            AssertColour(testConsole, 19, (ConsoleColor)5);
            AssertColour(testConsole, 20, (ConsoleColor)6);

            //should reuse the same colours for each language
            AssertColour(testConsole, 5, (ConsoleColor)6);
            AssertColour(testConsole, 10, (ConsoleColor)11);
        }
Пример #2
0
 /// <summary>
 /// 根据元素节点,上级code 赋值对象
 /// </summary>
 /// <param name="data"></param>
 private TranslateOutput GetTranslateOutput(XElement data)
 {
     try
     {
         TranslateOutput obj = new TranslateOutput();
         obj.Code    = data.Attribute("Code").Value;
         obj.Chinese = data.Attribute("Chinese").Value;
         obj.English = data.Attribute("English").Value;
         return(obj);
     }
     catch { return(null); }
 }