Exemple #1
0
        public void ReturnCorrectMessage_WhenCorrectParametrsArePassed()
        {
            //Arrange
            this.gettersMock.Setup(x => x.GetBoard(this.validTeamName, this.validBoardName)).Returns(this.boardMock.Object);

            this.componentsFactoryMock
            .Setup(x => x.CreateStory(this.validTitle, this.validDescription, this.validPriority, this.validStorySize, boardMock.Object, null))
            .Returns(this.storyMock.Object);

            var sut        = new CreateStoryCommand(this.historyEventWriterMock.Object, this.componentsFactoryMock.Object, this.gettersMock.Object);
            var parameters = new List <string>()
            {
                this.validTitle,
                this.validDescription,
                this.validPriority.ToString(),
                this.validStorySize.ToString(),
                this.validTeamName,
                this.validBoardName
            };

            var expectedReturn = string.Format(CommandsConsts.ObjectCreated, nameof(Story), this.validTitle);

            //Act
            var actualReturn = sut.Execute(parameters);

            //Assert
            Assert.AreEqual(expectedReturn, actualReturn);
        }
Exemple #2
0
        public void ThrowWhen_NoItemsInBoard()
        {
            //Arrange
            var fakeProvider = new FakeWorkItemProvider();
            var list         = new List <string>();
            var sut          = new CreateStoryCommand(list, fakeProvider);

            //Act & Assert
            Assert.ThrowsException <ArgumentException>(() => sut.Execute());
        }
Exemple #3
0
        public void Execute_Less_Params_ThrowEx()
        {
            var fakeProvider = new FakeWorkItemProvider();
            var listParams   = new List <string>()
            {
                "CreatedNewStory", "CSDescription", "high"
            };;

            var sut = new CreateStoryCommand(listParams, fakeProvider);

            //Act & Assert
            Assert.ThrowsException <ArgumentException>(() => sut.Execute(), "Parameters count is not valid!");
        }
Exemple #4
0
        public void ThrowExeptionWhenCommandParametersAreLessThanItShouldCorrectly()
        {
            string storyTitle  = "MnogoLoshoStory";
            string description = "Story description";
            IStory story       = new Story(storyTitle, description);

            database.Stories.Add(story);

            List <string> parameters = new List <string>
            {
                storyTitle
            };

            CreateStoryCommand command = new CreateStoryCommand(parameters);

            command.Execute();
            Assert.IsTrue(database.Stories.Any(x => x.Title == storyTitle));
        }
Exemple #5
0
        public void ExecuteAllFourMethodsOnce_WhenValidParametersArePassed()
        {
            //Arrange
            this.gettersMock.Setup(x => x.GetBoard(this.validTeamName, this.validBoardName)).Returns(this.boardMock.Object);

            this.componentsFactoryMock
            .Setup(x => x.CreateStory(this.validTitle, this.validDescription, this.validPriority, this.validStorySize, boardMock.Object, null))
            .Returns(this.storyMock.Object);

            var sut        = new CreateStoryCommand(this.historyEventWriterMock.Object, this.componentsFactoryMock.Object, this.gettersMock.Object);
            var parameters = new List <string>()
            {
                this.validTitle,
                this.validDescription,
                this.validPriority.ToString(),
                this.validStorySize.ToString(),
                this.validTeamName,
                this.validBoardName
            };

            //Act
            var returnMessage = sut.Execute(parameters);

            //Assert
            this.gettersMock.Verify(x => x.GetBoard(this.validTeamName, this.validBoardName), Times.Once);
            this.componentsFactoryMock
            .Verify(x => x.CreateStory(
                        this.validTitle,
                        this.validDescription,
                        this.validPriority,
                        this.validStorySize,
                        boardMock.Object,
                        null),
                    Times.Once);
            this.boardMock.Verify(x => x.AddWorkItemToBoard(this.storyMock.Object), Times.Once);
            this.historyEventWriterMock.
            Verify(x => x.AddHistoryEvent(
                       returnMessage,
                       It.IsAny <IPerson>(),
                       boardMock.Object,
                       It.IsAny <ITeam>(),
                       null
                       ), Times.Once);
        }
Exemple #6
0
        public void ReturnCorrectString()
        {
            //Arrange
            var fakeProvider = new FakeWorkItemProvider();
            var board        = new Board("Trello");
            var listParams   = new List <string>()
            {
                "CreatedNewStory", "CSDescription", "high", "large"
            };

            Commons.currentBoard = board;
            var sut = new CreateStoryCommand(listParams, fakeProvider);

            //Act
            var result = sut.Execute();

            //Assert
            Assert.AreEqual(result, $"CreatedNewStory story added to Trello board!" + Commons.CreateStoryText());
        }
Exemple #7
0
        public void CreateStoryCommand()
        {
            string storyTitle  = "MnogoLoshoStory";
            string description = "Story description";
            IStory story       = new Story(storyTitle, description);

            database.Stories.Add(story);

            List <string> parameters = new List <string>
            {
                storyTitle,
                description,
            };

            CreateStoryCommand command = new CreateStoryCommand(parameters);

            command.Execute();
            Assert.IsTrue(database.Stories.Any(x => x.Title == storyTitle));
        }
Exemple #8
0
        public void ThrowArgumentException_WhenNullStoryIsReturned()
        {
            //Arrange
            this.gettersMock.Setup(x => x.GetBoard(this.validTeamName, this.validBoardName)).Returns(this.boardMock.Object);

            this.componentsFactoryMock
            .Setup(x => x.CreateStory(this.validTitle, this.validDescription, this.validPriority, this.validStorySize, boardMock.Object, null));

            var sut        = new CreateStoryCommand(this.historyEventWriterMock.Object, this.componentsFactoryMock.Object, this.gettersMock.Object);
            var parameters = new List <string>()
            {
                this.validTitle,
                this.validDescription,
                this.validPriority.ToString(),
                this.validStorySize.ToString(),
                this.validTeamName,
                this.validBoardName
            };

            //Act, Assert
            Assert.ThrowsException <ArgumentException>(() => sut.Execute(parameters));
        }