Exemplo n.º 1
0
        public string RegisterUser(string username, string password, string confirmPassword)
        {
            if (this.Database.CurrentUser != null)
            {
                return "There is already a logged in user";
            }

            if (password != confirmPassword)
            {
                return "The provided passwords do not match";
            }

            if (this.Database.UsersByUsername.ContainsKey(username))
            {
                return string.Format("A user with username {0} already exists", username);
            }

            var user = new User(username, password);
            this.Database.UsersByUsername.Add(username, user);
            return string.Format("User {0} registered successfully", username);
        }
Exemplo n.º 2
0
 public Comment(User author, string text)
 {
     this.Author = author;
     this.Text = text;
 }
Exemplo n.º 3
0
        public void GetMyIssues_WithValidUser_ShouldCallTheDatabaseWithCorrectUser()
        {
            var mock = new Mock<IIssueTrackerDatabase>();
            var mockDictionary = new Mock<MultiDictionary<User, Issue>>(true);
            mock.Setup(d => d.IssuesByUser).Returns(mockDictionary.Object);
            
            mockDictionary.Setup(d => d[It.IsAny<User>()]).Returns(new Issue[] { });
            var user = new User("Admin", "password");
            mock.SetupProperty(d => d.CurrentUser, user);
            var database = mock.Object;
            var trackerTest = new IssueTracker(database);

            trackerTest.GetMyIssues();

            mockDictionary.Verify(d => d[user], Times.Exactly(1));
        }