public void ShouldReturnErrorMessageWhenCommandIsInvalid() { var addFriendHandler = new AddFriendHandler(this.friendRepository); var command = new AddFriendCommand() { Name = null, Latitude = 1234, Longitude = 4321 }; var result = addFriendHandler.Handler(command); result.IsSuccessful.Should().BeFalse(); result.Messages.Should() .Contain(m => m.MessageType == MessageType.Validation && m.Property == "Name" && m.Description == "Nome não pode ser vazio ou nulo."); }
public void ShouldReturnSuccessfulWhenNotExistsNotifications() { A.CallTo(() => this.friendRepository.LocationAlreadyExists(A <int> .Ignored, A <int> .Ignored)).Returns(false); A.CallTo(() => this.friendRepository.Add(A <Friend> .Ignored)).Returns(true); var addFriendHandler = new AddFriendHandler(this.friendRepository); var command = new AddFriendCommand() { Name = "Some Name", Latitude = 1234, Longitude = 4321 }; var result = addFriendHandler.Handler(command); result.IsSuccessful.Should().BeTrue(); result.Messages.Should() .Contain(m => m.MessageType == MessageType.Information && m.Description == "Amigo cadastrado com sucesso!"); }
public void ShouldReturnErrorMessageWhenHasAnotherFriendInSameLocation() { A.CallTo(() => this.friendRepository.LocationAlreadyExists(A <int> .Ignored, A <int> .Ignored)) .Returns(true); var addFriendHandler = new AddFriendHandler(this.friendRepository); var command = new AddFriendCommand() { Name = "Some Name", Latitude = 1234, Longitude = 4321 }; var result = addFriendHandler.Handler(command); result.IsSuccessful.Should().BeFalse(); result.Messages.Should() .Contain(m => m.MessageType == MessageType.Validation && m.Property == "Location" && m.Description == "Já existe um amigo cadastrado nesta localização."); }