示例#1
0
 public void test003_PutRemote()
 {
     global::GitSharp.Core.Config c = new global::GitSharp.Core.Config();
     c.setString("sec", "ext", "name", "value");
     c.setString("sec", "ext", "name2", "value2");
     string expText = "[sec \"ext\"]\n\tname = value\n\tname2 = value2\n";
     Assert.AreEqual(expText, c.toText());
 }
示例#2
0
        public void test003_PutRemote()
        {
            global::GitSharp.Core.Config c = new global::GitSharp.Core.Config();
            c.setString("sec", "ext", "name", "value");
            c.setString("sec", "ext", "name2", "value2");
            string expText = "[sec \"ext\"]\n\tname = value\n\tname2 = value2\n";

            Assert.AreEqual(expText, c.toText());
        }
示例#3
0
 public void test004_PutGetSimple()
 {
     global::GitSharp.Core.Config c = new global::GitSharp.Core.Config();
     c.setString("my", null, "somename", "false");
     Assert.AreEqual("false", c.getString("my", null, "somename"));
     Assert.AreEqual("[my]\n\tsomename = false\n", c.toText());
 }
示例#4
0
        public void test007_readUserConfig()
        {
            MockSystemReader mockSystemReader = new MockSystemReader();

            SystemReader.setInstance(mockSystemReader);
            string hostname = mockSystemReader.getHostname();

            global::GitSharp.Core.Config userGitConfig = mockSystemReader.openUserConfig();
            global::GitSharp.Core.Config localConfig   = new global::GitSharp.Core.Config(userGitConfig);
            mockSystemReader.clearProperties();

            string authorName;
            string authorEmail;

            // no values defined nowhere
            authorName  = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);

            // the system user name is defined
            mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name");
            localConfig.uncache(UserConfig.KEY);
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            Assert.AreEqual("os user name", authorName);

            if (hostname != null && hostname.Length != 0)
            {
                authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
                Assert.AreEqual("os user name@" + hostname, authorEmail);
            }

            // the git environment variables are defined
            mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
            mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
            localConfig.uncache(UserConfig.KEY);
            authorName  = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("git author name", authorName);
            Assert.AreEqual("author@email", authorEmail);

            // the values are defined in the global configuration
            userGitConfig.setString("user", null, "name", "global username");
            userGitConfig.setString("user", null, "email", "author@globalemail");
            authorName  = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("global username", authorName);
            Assert.AreEqual("author@globalemail", authorEmail);

            // the values are defined in the local configuration
            localConfig.setString("user", null, "name", "local username");
            localConfig.setString("user", null, "email", "author@localemail");
            authorName  = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);

            authorName  = localConfig.get(UserConfig.KEY).getCommitterName();
            authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);
        }
示例#5
0
 public void test004_PutGetSimple()
 {
     global::GitSharp.Core.Config c = new global::GitSharp.Core.Config();
     c.setString("my", null, "somename", "false");
     Assert.AreEqual("false", c.getString("my", null, "somename"));
     Assert.AreEqual("[my]\n\tsomename = false\n", c.toText());
 }
示例#6
0
        public void test007_readUserConfig()
        {
            MockSystemReader mockSystemReader = new MockSystemReader();
            SystemReader.setInstance(mockSystemReader);
            string hostname = mockSystemReader.getHostname();
            global::GitSharp.Core.Config userGitConfig = mockSystemReader.openUserConfig();
            global::GitSharp.Core.Config localConfig = new global::GitSharp.Core.Config(userGitConfig);
            mockSystemReader.clearProperties();

            string authorName;
            string authorEmail;

            // no values defined nowhere
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);

            // the system user name is defined
            mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name");
            localConfig.uncache(UserConfig.KEY);
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            Assert.AreEqual("os user name", authorName);

            if (hostname != null && hostname.Length != 0)
            {
                authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
                Assert.AreEqual("os user name@" + hostname, authorEmail);
            }

            // the git environment variables are defined
            mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
            mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
            localConfig.uncache(UserConfig.KEY);
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("git author name", authorName);
            Assert.AreEqual("author@email", authorEmail);

            // the values are defined in the global configuration
            userGitConfig.setString("user", null, "name", "global username");
            userGitConfig.setString("user", null, "email", "author@globalemail");
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("global username", authorName);
            Assert.AreEqual("author@globalemail", authorEmail);

            // the values are defined in the local configuration
            localConfig.setString("user", null, "name", "local username");
            localConfig.setString("user", null, "email", "author@localemail");
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);

            authorName = localConfig.get(UserConfig.KEY).getCommitterName();
            authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);
        }