public void CorrectMessage_WhenValidParametersArePassed() { //Arrange var validBoarName = "Valid"; var validTeamname = "ValidTeam"; var boardMock = new Mock <IBoard>(); var teamMock = new Mock <ITeam>(); // teamMock.Setup(x => x.AddBoardToTeam(It.IsAny<IBoard>())); var historyEventWriterMock = new Mock <IHistoryEventWriter>(); var componentsFactoryMock = new Mock <IComponentsFactory>(); componentsFactoryMock.Setup(x => x.CreateBoard(validBoarName, teamMock.Object)).Returns(boardMock.Object); var gettersMock = new Mock <IGetters>(); gettersMock.Setup(x => x.GetTeam(validTeamname)).Returns(teamMock.Object); var sut = new CreateBoardCommand(historyEventWriterMock.Object, componentsFactoryMock.Object, gettersMock.Object); var parameters = new List <string>() { validBoarName, validTeamname }; var expectedReturn = string.Format(CommandsConsts.ObjectCreated, nameof(Board), validBoarName); //Act var actualReturn = sut.Execute(parameters); //Assert Assert.AreEqual(expectedReturn, actualReturn); }
public void ThrowArgumentException_WhenNullBoardIsReturned() { //Arrange var validBoarName = "Valid"; var validTeamname = "ValidTeam"; var boardMock = new Mock <IBoard>(); var teamMock = new Mock <ITeam>(); var historyEventWriterMock = new Mock <IHistoryEventWriter>(); var componentsFactoryMock = new Mock <IComponentsFactory>(); var gettersMock = new Mock <IGetters>(); gettersMock.Setup(x => x.GetTeam(validTeamname)).Returns(teamMock.Object); var sut = new CreateBoardCommand(historyEventWriterMock.Object, componentsFactoryMock.Object, gettersMock.Object); var parameters = new List <string>() { validBoarName, validTeamname }; //Act, Assert Assert.ThrowsException <ArgumentException>(() => sut.Execute(parameters)); }
public void ExecuteAllFourMethodsOnce_WhenValidParametersArePassed() { //Arrange var validBoarName = "Valid"; var validTeamname = "ValidTeam"; var boardMock = new Mock <IBoard>(); var teamMock = new Mock <ITeam>(); var historyEventWriterMock = new Mock <IHistoryEventWriter>(); var componentsFactoryMock = new Mock <IComponentsFactory>(); componentsFactoryMock.Setup(x => x.CreateBoard(validBoarName, teamMock.Object)).Returns(boardMock.Object); var gettersMock = new Mock <IGetters>(); gettersMock.Setup(x => x.GetTeam(validTeamname)).Returns(teamMock.Object); var sut = new CreateBoardCommand(historyEventWriterMock.Object, componentsFactoryMock.Object, gettersMock.Object); var parameters = new List <string>() { validBoarName, validTeamname }; //Act sut.Execute(parameters); //Assert gettersMock.Verify(x => x.GetTeam(validTeamname), Times.Once); componentsFactoryMock.Verify(x => x.CreateBoard(validBoarName, teamMock.Object), Times.Once); teamMock.Verify(x => x.AddBoardToTeam(It.IsAny <IBoard>()), Times.Once); historyEventWriterMock.Verify(x => x.AddHistoryEvent(It.IsAny <string>(), null, boardMock.Object, teamMock.Object, null), Times.Once); }
public void CreateBoard() { var command = new CreateBoardCommand("A board"); var id = command.Execute(_model); var board = _model.Boards.Values.Single(); Assert.AreEqual(id, board.Id); Assert.AreEqual(command.BoardName, board.Name); }
public void BoardCreation_Execute_Less_Params_ThrowEx() { //Arrange var list = new List <string>(); var fakeBoardProvider = new FakeBoardProvider(); var sut = new CreateBoardCommand(list, fakeBoardProvider); //Act & Assert Assert.ThrowsException <ArgumentException>(() => sut.Execute(), "Parameters count is not valid!"); }
public void ThrowExeptionWhenCommandParametersAreLessThanItShoul() { string name = "BoardName"; IBoard board = new Board(name); database.Boards.Add(board); List <string> parameters = new List <string> { }; CreateBoardCommand command = new CreateBoardCommand(parameters); command.Execute(); Assert.IsTrue(database.Boards.Any(x => x.Name == name)); }
public void BoardCreation_Execute_BoardWithSameNameAlreadyExists_ThrowEx() { //Arrange Commons.currentTeam = new Team("FakeTeamName"); var list = new List <string>() { "BoardName" }; var fakeBoardProvider = new FakeBoardProvider(); fakeBoardProvider.Add(new Board("BoardName")); var sut = new CreateBoardCommand(list, fakeBoardProvider); Assert.ThrowsException <ArgumentException>(() => sut.Execute(), "Board with name BoardName already exists." + Environment.NewLine + $"You can see all available boards with command listboards."); }
public void CreateBoardSuccess() { //Arrange Commons.currentTeam = new Team("FakeTeamName"); var list = new List <string>() { "BoardName" }; var fakeBoardProvider = new FakeBoardProvider(); var sut = new CreateBoardCommand(list, fakeBoardProvider); //Act var result = sut.Execute(); //Assert Assert.IsTrue(result.StartsWith("Created Board")); }
public void CreateBoardCommand() { string name = "BoardName"; IBoard board = new Board(name); database.Boards.Add(board); List <string> parameters = new List <string> { name }; CreateBoardCommand command = new CreateBoardCommand(parameters); command.Execute(); Assert.IsTrue(database.Boards.Any(x => x.Name == name)); }