Example #1
0
        public void ExecuteAllMethodsOnce_WhenValidParametersArePassed()
        {
            //Arrange
            var workItemMock = new Mock<IFeedback>();
            var sut = new ChangeRatingOfFeedbackCommand(historyEventWriterMock.Object, gettersMock.Object);
            gettersMock.Setup(x => x.GetBoard(validTeamName, validBoardName)).Returns(boardMock.Object);
            gettersMock.Setup(x => x.GetWorkItem(boardMock.Object, validWorkItemTitle))
                .Returns(workItemMock.Object);
            workItemMock.Setup(x => x.Rating).Returns(int.Parse(validRating));
            workItemMock.Setup(x => x.Title).Returns(validWorkItemTitle);
            workItemMock.Setup(x => x.Board).Returns(boardMock.Object);
            historyEventWriterMock.Setup(x => x.AddHistoryEvent(It.IsAny<string>(), It.IsAny<IPerson>(), It.IsAny<IBoard>(), It.IsAny<ITeam>(), It.IsAny<IWorkItem>()));

            var parameters = new List<string>()
            {
                validTeamName,
                validBoardName,
                validWorkItemTitle,
                validRating,
            };
            var expectedMessage = string.Format(CommandsConsts.FeedbackRatingChange, workItemMock.Object.Title, validRating);
            //Act
            var returnMessage = sut.Execute(parameters);

            //Assert
            gettersMock.Verify(x => x.GetWorkItem(boardMock.Object, validWorkItemTitle), Times.Once);
            gettersMock.Verify(x => x.GetBoard(validTeamName, validBoardName), Times.Once);
            workItemMock.VerifySet(x => x.Rating = 6, Times.Once);
            historyEventWriterMock.Verify(x => x.AddHistoryEvent(It.IsAny<string>(), It.IsAny<IPerson>(), It.IsAny<IBoard>(), It.IsAny<ITeam>(), It.IsAny<IWorkItem>()), Times.Once);

        }
Example #2
0
 public void ThrowArgumentException_WhenNullWorkItemIsPassed()
 {
     //Arrange
     var workItemMock = new Mock<IFeedback>();
     var sut = new ChangeRatingOfFeedbackCommand(historyEventWriterMock.Object, gettersMock.Object);
     gettersMock.Setup(x => x.GetBoard(validTeamName, validBoardName)).Returns(boardMock.Object);
     workItemMock.Setup(x => x.Title).Returns(validWorkItemTitle);
     workItemMock.Setup(x => x.Board).Returns(boardMock.Object);
     historyEventWriterMock.Setup(x => x.AddHistoryEvent(It.IsAny<string>(), It.IsAny<IPerson>(), It.IsAny<IBoard>(), It.IsAny<ITeam>(), It.IsAny<IWorkItem>()));
     var parameters = new List<string>()
     {
         validTeamName,
         validBoardName,
         validWorkItemTitle,
         validRating,
     };
     var expectedMessage = string.Format(Consts.NULL_OBJECT, nameof(WorkItem));
     //Act
     var exeption = Assert.ThrowsException<ArgumentException>(() => sut.Execute(parameters));
     //Assert
     Assert.AreEqual(exeption.Message, expectedMessage);
 }
Example #3
0
 public void ReturnCorrectMessage_WhenCorrectParametrsArePassed()
 {
     //Arrange
     var workItemMock = new Mock<IFeedback>();
     var sut = new ChangeRatingOfFeedbackCommand(historyEventWriterMock.Object, gettersMock.Object);
     gettersMock.Setup(x => x.GetBoard(validTeamName, validBoardName)).Returns(boardMock.Object);
     gettersMock.Setup(x => x.GetWorkItem(boardMock.Object, validWorkItemTitle))
         .Returns(workItemMock.Object);
     workItemMock.Setup(x => x.Title).Returns(validWorkItemTitle);
     workItemMock.Setup(x => x.Board).Returns(boardMock.Object);
     historyEventWriterMock.Setup(x => x.AddHistoryEvent(It.IsAny<string>(), It.IsAny<IPerson>(), It.IsAny<IBoard>(), It.IsAny<ITeam>(), It.IsAny<IWorkItem>()));
     var parameters = new List<string>()
     {
         validTeamName,
         validBoardName,
         validWorkItemTitle,
         validRating,
     };
     var expectedMessage = string.Format(CommandsConsts.FeedbackRatingChange, workItemMock.Object.Title, validRating);
     //Act
     var returnMessage = sut.Execute(parameters);
     //Assert
     Assert.AreEqual(returnMessage, expectedMessage);
 }