コード例 #1
0
        public void Get_WidthParameters_IncorrectID_ReturnsErroredString()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());
            var text      = container.Get("wrongtext", "param");

            Assert.That(text, Is.EqualTo("**!wrongtext!**"));
        }
コード例 #2
0
 /// <summary>
 /// Adds a language container to this manager
 /// </summary>
 /// <param name="container">The container to add</param>
 public void AddLanguage(LanguageContainer container)
 {
     if (_containers.ContainsKey(container.Language))
     {
         throw new InvalidOperationException("The language (" + container.Language.ToString() + ") have alread been added");
     }
     _containers.Add(container.Language, container);
 }
コード例 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fallbackLanguageContainer">The container of the language to fallback to if an identifier is not found in current language</param>
 public LanguageManager(LanguageContainer fallbackLanguageContainer)
 {
     if (fallbackLanguageContainer == null)
     {
         throw new ArgumentNullException("fallbackLanguageContainer");
     }
     _fallbackLanguage = fallbackLanguageContainer;
     _containers       = new Dictionary <SystemLanguage, LanguageContainer>();
     AddLanguage(_fallbackLanguage);
 }
コード例 #4
0
        public void Get_WithOneParameter_ReturnsParameterizedString()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.Get("test4", "awesome"), Is.EqualTo("Text with one awesome parameter."));
        }
コード例 #5
0
        public string Get_IncorrectID_ReturnsErroredString(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.Get(id));
        }
コード例 #6
0
        public bool Contains_ReturnsCorrect(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.Contains(id));
        }
コード例 #7
0
        public void Count_Correct()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.Count, Is.EqualTo(8));
        }
コード例 #8
0
        public void UsedCharacters_Correct()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.UsedCharacters.Length, Is.EqualTo(30));
        }
コード例 #9
0
        public void Language_Correct(SystemLanguage language)
        {
            var container = new LanguageContainer(language, GetLanguageFile());

            Assert.That(container.Language, Is.EqualTo(language));
        }
コード例 #10
0
        public int HighestParameter_ReturnsCorrectNumber(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.HighestParameter(id));
        }
コード例 #11
0
        public bool HasParameter_ReturnsCorrect(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.HasParameter(id));
        }
コード例 #12
0
        public void Get_WithWrongNumberOfParamters_FormatException()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            container.Get("test1", "wrongparam");
        }
コード例 #13
0
        public void Get_WithHighParameter_ReturnsParameterizedString()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.Get("test8", "icy", "sweet", "and pretty"), Is.EqualTo("Text with high and pretty parameter."));
        }
コード例 #14
0
        public void Get_WithMixedParameters_ReturnsParameterizedString()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.Get("test7", "icy", "sweet", "and pretty"), Is.EqualTo("Text with mixed sweet, and pretty, icy parameters."));
        }
コード例 #15
0
        public void Get_WithTwoParameters_ReturnsParameterizedString()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            Assert.That(container.Get("test5", "cool", "and great"), Is.EqualTo("Text with two cool, and great parameters."));
        }