Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Flexible Plugin System

, 3 Sep 2008 LGPL3
A generic plugin system used to load and manage plugins
fadd-15373.zip
trunk
dlls
xunit.dll
Examples
Plugins
ExampleApplication.Shared
Properties
ExampleApplication
Properties
ExamplePlugin.Shared
Properties
ExamplePlugin
Properties
Fadd.Globalization.Yaml
fadd.snk
Properties
Tests
fadd
Commands
Net
Tests
fadd.snk
Globalization
Tests
Logging
Plugins
Properties
Tests
Validation
#if DEBUG
using System.Globalization;
using Xunit;
#pragma warning disable 1591

namespace Fadd.Globalization.Tests
{
    public class LanguageTest
    {
        private readonly LanguageNode _languageNode;

        public LanguageTest()
        {
            _languageNode = new MemLanguageNode(CultureInfo.CurrentCulture.LCID, "root");
        }

        [Fact]
        public void TestNoCategory()
        {
            Assert.Equal<LanguageNode>(LanguageNode.Empty, _languageNode.GetNode("Invalid"));
        }

        [Fact]
        public void TestEmpty()
        {
            Assert.NotNull(_languageNode);
            Assert.Equal("[name]", _languageNode["name"]);
            Assert.Equal("[name]", _languageNode["name", int.MaxValue]);
            Assert.Equal("[name]", _languageNode["name", _languageNode.DefaultLCID]);
        }

        [Fact]
        public void TestNode()
        {
            _languageNode.Add("voodoo", _languageNode.DefaultLCID, "voodooBase");
            LanguageNode language = _languageNode.AddNode("testNode");
            Assert.Equal("voodooBase", language["voodoo"]);

            language.Add("voodoo", _languageNode.DefaultLCID, "voodooSub");
            Assert.Equal("voodooSub", language["voodoo"]);

            Assert.Equal("[voodoMisspelled]", language["voodoMisspelled"]);
        }

        [Fact]
        public void TestLanguages()
        {
            LanguageNode language = _languageNode.AddNode("subNode");
            language.Add("language", _languageNode.DefaultLCID, "swedish");
            language.Add("language", 1052, "�nglish");
            language.Add("language", 1051, "tyskish");

            Assert.Equal("swedish", language["language", _languageNode.DefaultLCID]);
            Assert.Equal("�nglish", language["language", 1052]);
            Assert.Equal("tyskish", language["language", 1051]);
            Assert.Equal("swedish", language["language", int.MaxValue]);

            language = language.AddNode("subSubNode");
            Assert.Equal("swedish", language["language", int.MaxValue]);
        }

        [Fact]
        public void TestNull()
        {
            Assert.Null(_languageNode.GetNodeUnsafe("Undefined"));
        }
    }
}
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

jgauffin
Founder Gauffin Interactive AB
Sweden Sweden
Founder of OneTrueError, a .NET service which captures, analyzes and provide possible solutions for exceptions.
 
blog | twitter
Follow on   Twitter   LinkedIn

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 3 Sep 2008
Article Copyright 2008 by jgauffin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid