/// <summary>
        ///     Processes a GetNeighbourResponse item from stream.
        /// </summary>
        /// <param name="peerNeighborsRequest"></param>
        /// <param name="channelHandlerContext"></param>
        /// <param name="senderPeerId"></param>
        /// <param name="correlationId"></param>
        /// <returns></returns>
        protected override PeerNeighborsResponse HandleRequest(PeerNeighborsRequest peerNeighborsRequest,
                                                               IChannelHandlerContext channelHandlerContext,
                                                               PeerId senderPeerId,
                                                               ICorrelationId correlationId)
        {
            Guard.Argument(peerNeighborsRequest, nameof(peerNeighborsRequest)).NotNull();
            Guard.Argument(channelHandlerContext, nameof(channelHandlerContext)).NotNull();
            Guard.Argument(senderPeerId, nameof(senderPeerId)).NotNull();

            Logger.Debug("PeerNeighborsRequest Message Received");

            var activePeersList = _repository.GetActivePeers(Constants.NumberOfRandomPeers);

            Guard.Argument(activePeersList).MinCount(1);

            var peerNeighborsResponseMessage = new PeerNeighborsResponse();

            for (var i = 0; i < Constants.NumberOfRandomPeers; i++)
            {
                peerNeighborsResponseMessage.Peers.Add(activePeersList.RandomElement().PeerId);
            }

            return(peerNeighborsResponseMessage);
        }
 private static void AddMockPeerToDbAndSetReturnExpectation(IReadOnlyList <Peer> peer,
                                                            IPeerRepository repository)
 {
     repository.Add(peer);
     repository.GetActivePeers(Arg.Any <int>()).Returns(peer);
 }