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!**"));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
        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."));
        }
        public string Get_IncorrectID_ReturnsErroredString(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.Get(id));
        }
        public bool Contains_ReturnsCorrect(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.Contains(id));
        }
        public void Count_Correct()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

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

            Assert.That(container.UsedCharacters.Length, Is.EqualTo(30));
        }
        public void Language_Correct(SystemLanguage language)
        {
            var container = new LanguageContainer(language, GetLanguageFile());

            Assert.That(container.Language, Is.EqualTo(language));
        }
Ejemplo n.º 10
0
        public int HighestParameter_ReturnsCorrectNumber(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.HighestParameter(id));
        }
Ejemplo n.º 11
0
        public bool HasParameter_ReturnsCorrect(string id)
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            return(container.HasParameter(id));
        }
Ejemplo n.º 12
0
        public void Get_WithWrongNumberOfParamters_FormatException()
        {
            var container = new LanguageContainer(SystemLanguage.English, GetLanguageFile());

            container.Get("test1", "wrongparam");
        }
Ejemplo n.º 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."));
        }
Ejemplo n.º 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."));
        }
Ejemplo n.º 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."));
        }