public void Decline_RequestDoesNotExist_DbNotChanged() { // Arrange MockRequestServiceThrowsInvalidKeyValueException(); Exception exception = null; var emailMessage = new EmailMessageBuilder().Build(); MockMailService(emailMessage); var expected = new TournamentRequestBuilder().Build(); MockGetRequestByIdQuery(expected); MockGetUser(); var sut = BuildSUT(); // Act try { sut.Decline(INVALID_REQUEST_ID, emailMessage.Body); } catch (MissingEntityException ex) { exception = ex; } // Assert VerifyDeleteRequest(INVALID_REQUEST_ID, Times.Once(), Times.Never()); }
public void Create_TournamentRequesExist_RequestNotAdded() { // Arrange var newTournamentRequest = new TournamentRequestBuilder() .WithId(EXISTING_ID) .WithTeamId(EXISTING_ID) .WithGroupId(EXISTING_ID) .WithUserId(EXISTING_ID) .Build(); var emailMessage = new EmailMessageBuilder().Build(); MockMailService(emailMessage); MockUserService(); _tournamentRequestRepositoryMock.Setup( tr => tr.Add( It.IsAny <TournamentRequest>())) .Callback <TournamentRequest>(t => t.Id = EXISTING_ID); MockGetAllTournamentRequestQuery(newTournamentRequest); var sut = BuildSUT(); // Act sut.Create(newTournamentRequest); // Assert VerifyCreateTournamentRequest(newTournamentRequest, Times.Never(), "Parameter request is not equal to Instance of request"); }
public void GetById_RequestExists_RequestReturned() { // Arrange var expected = new TournamentRequestBuilder().WithId(EXISTING_ID).Build(); MockGetRequestByIdQuery(expected); var sut = BuildSUT(); // Act var actual = sut.Get(EXISTING_ID); // Assert Assert.Equal <TournamentRequest>(expected, actual, new TournamentRequestComparer()); }
public void Decline_RequestExist_RequestDeleted() { // Arrange var expected = new TournamentRequestBuilder().Build(); MockGetRequestByIdQuery(expected); var emailMessage = new EmailMessageBuilder().Build(); MockMailService(emailMessage); MockGetUser(); var sut = BuildSUT(); // Act sut.Decline(EXISTING_ID, emailMessage.Body); // Assert VerifyDeleteRequest(EXISTING_ID, Times.Once()); }
public void Create_InvalidUserId_ExceptionThrows() { var newTournamentRequest = new TournamentRequestBuilder() .Build(); _tournamentRequestRepositoryMock.Setup( tr => tr.Add( newTournamentRequest)) .Callback <TournamentRequest>(t => t.UserId = -1); // Arrange var sut = BuildSUT(); // Act Action act = () => sut.Create(newTournamentRequest); //Assert act.Should().Throw <ArgumentException>("User's id is wrong"); }
public void Confirm_RequestExists_TeamAdded() { // Arrange var expected = new TournamentRequestBuilder().WithId(EXISTING_ID).Build(); MockGetRequestByIdQuery(expected); _tournamentRepositoryMock.Setup(tr => tr.AddTeamToTournament(It.IsAny <int>(), It.IsAny <int>())); var emailMessage = new EmailMessageBuilder().Build(); MockGetUser(); MockRemoveTournamentRequest(); MockMailService(emailMessage); var sut = BuildSUT(); // Act sut.Confirm(EXISTING_ID); // Assert VerifyAddedTeam(expected.Id, expected.TournamentId, expected.GroupId, Times.Once(), Times.AtLeastOnce()); }
public void Confirm_RequestExists_TeamAdded() { // Arrange var expected = new TournamentRequestBuilder().WithId(EXISTING_ID).Build(); MockGetRequestByIdQuery(expected); _tournamentServiceMock.Setup(tr => tr.AddTeamsToTournament(It.IsAny <List <TeamTournamentAssignmentDto> >())); var emailMessage = new EmailMessageBuilder().Build(); MockGetUser(); MockRemoveTournamentRequest(); MockMailService(emailMessage); var sut = BuildSUT(); // Act sut.Confirm(EXISTING_ID); // Assert VerifyAddedTeamToTournament(Times.Once()); }