Exemple #1
0
        public void TestGetConfigLineMixedCase()
        {
            config = Config.FromText("[Section]\r\nKey=bob");

            var result = config.GetValue("section", "key", "default");

            Assert.AreEqual("bob", result);
        }
Exemple #2
0
        public void TestSetAliasWithSingleQuotes()
        {
            var config = new Config();

            Mock<IConfigService>()
                .Setup(call => call.GetConfig())
                .Returns(config);

            service.SetAlias("test", "alias 'three four'");

            Assert.AreEqual(@"alias ""three four""", config.GetValue("Aliases", "test", string.Empty));
        }
Exemple #3
0
        public void TestSetAlias()
        {
            var config = new Config();

            Mock<IConfigService>()
                .Setup(call => call.GetConfig())
                .Returns(config);

            service.SetAlias("test", "alias");
            
            Assert.AreEqual("alias", config.GetValue("Aliases", "test", string.Empty));
        }
        public void TestStoreCredentials()
        {
            var config = new Config();

            var credentials = new Credentials
            {
                Name = "Bob",
                JabberId = "123",
                Password = "******",
                ApiToken = "123456"
            };

            Mock<IConfigService>()
                .Setup(call => call.GetConfig())
                .Returns(config);

            service.SetCredentials(credentials);

            Assert.AreEqual("123456", config.GetValue("Credentials", "ApiToken", string.Empty));
            Assert.AreEqual("123", config.GetValue("Credentials", "JabberID", string.Empty));
            Assert.AreEqual("Bob", config.GetValue("Credentials", "Name", string.Empty));
            Assert.AreEqual("Password", config.GetValue("Credentials", "Password", string.Empty));
        }
        public void TestStoreCredentials()
        {
            var config = new Config();

            var credentials = new Credentials
            {
                Server = "irc.example.com",
                Port = 123,
                Password = "******"
            };

            Mock<IConfigService>()
                .Setup(call => call.GetConfig())
                .Returns(config);

            service.SetCredentials(credentials);

            Assert.AreEqual("123", config.GetValue("Credentials", "Port", string.Empty));
            Assert.AreEqual("irc.example.com", config.GetValue("Credentials", "Server", string.Empty));
            Assert.AreEqual("Password", config.GetValue("Credentials", "Password", string.Empty));
        }