Example #1
0
        public void AuthorsFileDifferentIdsForUsersWithSameEmail()
        {
            string[] authors =
            {
                @"Domain\Test.User = Test User <*****@*****.**>",
                @"Domain\Different.User = Three Name User < *****@*****.** >",
                @"Domain\Yet.Another.User = Mr. 3 <*****@*****.**>"
            };

            AuthorsFile authFile = _SetupAuthorsFile(authors);

            Assert.NotNull(authFile.AuthorsByGitUserId);

            // multiple users with the same email -> 3 tfs users, 1 git user
            Assert.Equal <int>(authors.Length, authFile.Authors.Count);
            Assert.Single(authFile.AuthorsByGitUserId);

            // contains all tfs users
            Assert.True(authFile.Authors.ContainsKey(@"Domain\Test.User"));
            Assert.True(authFile.Authors.ContainsKey(@"Domain\Different.User"));
            Assert.True(authFile.Authors.ContainsKey(@"Domain\Yet.Another.User"));

            // contains all git users
            Assert.True(authFile.AuthorsByGitUserId.ContainsKey(Author.BuildGitUserId("*****@*****.**")));

            // return the first tfs user id in the authors file when multiple
            // match to the same git id.
            Tuple <string, string> git_author = new Tuple <string, string>("Test User", "*****@*****.**");
            Author a = authFile.FindAuthor(git_author);

            Assert.NotNull(a);
            Assert.Equal(@"Domain\Test.User", a.TfsUserId);
        }
Example #2
0
        public void AuthorsFileFindAuthors()
        {
            string[] authors =
            {
                @"Domain\Test.User = Test User <*****@*****.**>",
                @"Domain\Different.User = Three Name User < *****@*****.** >",
                @"Domain\Yet.Another.User = Mr. 3 <*****@*****.**>"
            };

            AuthorsFile authFile = _SetupAuthorsFile(authors);

            // find existing author
            Tuple <string, string> gitAuthor = new Tuple <string, string>("Test User", "*****@*****.**");
            Author existingAuthor            = authFile.FindAuthor(gitAuthor);

            Assert.NotNull(existingAuthor);

            // try to find unknown author
            Tuple <string, string> gitUnknownAuthor = new Tuple <string, string>("Test User", "*****@*****.**");
            Author unknownAuthor = authFile.FindAuthor(gitUnknownAuthor);

            Assert.Null(unknownAuthor);
        }