Exemplo n.º 1
0
 private void MemberCodeKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return || e.Key == Key.Enter)
     {
         AddMemberCommand.Execute(null);
     }
 }
        public void ReturnMessage_WhenMemberWasAdded()
        {
            var userName = "******";
            var teamName = "alpha";
            var people   = new Dictionary <string, IPerson>();
            var teams    = new Dictionary <string, ITeam>();

            var databaseMock = new Mock <IDataBase>();
            var teamMock     = new Mock <ITeam>();
            var personMock   = new Mock <IPerson>();

            personMock.SetupGet(p => p.UserName).Returns(userName);
            databaseMock.SetupGet(x => x.Teams).Returns(teams);
            databaseMock.SetupGet(x => x.People).Returns(people);

            teams.Add(teamName, teamMock.Object);
            people.Add(userName, personMock.Object);
            teams[teamName].AddMember(personMock.Object);

            var sut = new AddMemberCommand(databaseMock.Object);

            var message = sut.Execute(new List <string> {
                userName, "to", teamName
            });

            Assert.AreEqual($" {userName} was added to {teamName}", message);
        }
        public void ReturnMessage_WhenUserNameNotExist()
        {
            var userName = "******";
            var teamName = "alpha";

            var people = new Dictionary <string, IPerson>();
            var teams  = new Dictionary <string, ITeam>();

            var databaseMock = new Mock <IDataBase>();

            var teamMock = new Mock <ITeam>();

            //var personMock = new Mock<IPerson>();

            databaseMock.SetupGet(x => x.Teams).Returns(teams);
            databaseMock.SetupGet(x => x.People).Returns(people);
            teams.Add(teamName, teamMock.Object);

            var sut = new AddMemberCommand(databaseMock.Object);

            var message = sut.Execute(new List <string> {
                userName, "to", teamName
            });

            Assert.AreEqual($"{userName} not exists.", message);
        }
Exemplo n.º 4
0
        public void AddMember_ReturnsCorrectOutput()
        {
            var factory = new Mock <IFactory>();
            var command = new AddMemberCommand(new List <string>()
            {
                "Member1", "Team1"
            }, database, factory.Object);

            Assert.AreEqual("Member: 'Member1' added to team: 'Team1'.", command.Execute());
        }
        public void ThrowException_WhenPassedInvalidParametersCount()
        {
            var expectedMessage = "Failed to parse AddMember command parameters.";
            var databaseMock    = new Mock <IDataBase>();

            var parameters = new List <string>()
            {
                "userName", "to"
            };

            var sut = new AddMemberCommand(databaseMock.Object);

            var ex = Assert.ThrowsException <ArgumentException>(() => sut.Execute(parameters));

            Assert.AreEqual(expectedMessage, ex.Message);
        }
        public void ReturnMessage_WhenTeamNameNotExist()
        {
            var teamName   = "alpha";
            var parameters = new List <string>()
            {
                "userName", "to", teamName
            };

            var teams = new Dictionary <string, ITeam>();

            var databaseMock = new Mock <IDataBase>();
            var teamMock     = new Mock <ITeam>();


            databaseMock.SetupGet(x => x.Teams).Returns(teams);

            var sut = new AddMemberCommand(databaseMock.Object);

            var message = sut.Execute(parameters);

            Assert.AreEqual($"{teamName} not exists.", message);
        }