Exemplo n.º 1
0
 private static void Main()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     var database = new IssueTrackerDatabase();
     var issueTracker = new IssueTracker(database);
     var dispatcher = new Dispatcher(issueTracker);
     var engine = new Engine(dispatcher);
     engine.Run();
 }
Exemplo n.º 2
0
        public void SearchForIssues_WithValidUser_ShouldCallTheCorrectDatabaseCollection()
        {
            var mock = new Mock<IIssueTrackerDatabase>();
            var mockDictionary = new Mock<MultiDictionary<string, Issue>>(true);
            mock.Setup(d => d.IssuesByTag).Returns(mockDictionary.Object);
            mockDictionary.Setup(d => d[It.IsAny<string>()]).Returns(new Issue[] { });
            mock.SetupProperty(d => d.CurrentUser, new User("Admin", "password"));
            var tags = new string[] { "tag1", "tag2" };
            var database = mock.Object;
            var trackerTest = new IssueTracker(database);

            trackerTest.SearchForIssues(tags);

            mockDictionary.Verify(d => d[It.IsAny<string>()]);
        }
Exemplo n.º 3
0
        public void RegisterUser_WithAValidUser_ShouldAddAnEntryToTheUsersCollectionInTheDatabase()
        {
            var mock = new Mock<IIssueTrackerDatabase>();
            var mockDictionary = new Mock<IDictionary<string, User>>();
            mock.Setup(d => d.UsersByUsername).Returns(mockDictionary.Object);

            var name = "Name";
            var password = "******";
            var database = mock.Object;
            var trackerTest = new IssueTracker(database);

            trackerTest.RegisterUser(name, password, password);

            mockDictionary.Verify(d => d.Add(It.IsAny<string>(), It.IsAny<User>()), Times.Exactly(1));
        }
Exemplo n.º 4
0
 public void InitializeTest()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     this.tracker = new IssueTracker();
 }
Exemplo n.º 5
0
        public void RegisterUser_ShouldAddAnEntryWithTheCorrectKeyAndValueToTheCollection()
        {
            var mock = new Mock<IIssueTrackerDatabase>();
            var mockDictionary = new Mock<IDictionary<string, User>>();

            string expectedUsername = null;
            User expectedUser = null;
            mockDictionary.Setup(d => d.Add(It.IsAny<string>(), It.IsAny<User>()))
                .Callback<string, User>(
                    (name, user) =>
                    {
                        expectedUsername = name;
                        expectedUser = user;
                    });

            mock.Setup(d => d.UsersByUsername).Returns(mockDictionary.Object);

            var username = "******";
            var password = "******";
            var database = mock.Object;
            var trackerTest = new IssueTracker(database);

            trackerTest.RegisterUser(username, password, password);

            Assert.AreEqual(expectedUsername, username);
            Assert.AreEqual(expectedUser.Name, username);
            Assert.AreEqual(expectedUser.Password, HashUtility.HashPassword(password));
        }
Exemplo n.º 6
0
        public void GetMyIssues_WithValidUser_ShouldCallTheCorrectDatabaseCollection()
        {
            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[] { });
            mock.SetupProperty(d => d.CurrentUser, new User("Admin", "password"));
            var database = mock.Object;
            var trackerTest = new IssueTracker(database);

            trackerTest.GetMyIssues();

            mockDictionary.Verify(d => d[It.IsAny<User>()], Times.Exactly(1));
        }