Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

TestSubscriber.cs

using System.Net;
using StackExchange.Redis;

namespace Nop.Tests.Nop.Services.Tests.Caching;

public class TestSubscriber : ISubscriber
{
    protected static IList> _handlers = new List>();
    
    public Task PingAsync(CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public bool TryWait(Task task)
    {
        throw new NotImplementedException();
    }

    public void Wait(Task task)
    {
        throw new NotImplementedException();
    }

    public T Wait(Task task)
    {
        throw new NotImplementedException();
    }

    public void WaitAll(params Task[] tasks)
    {
        throw new NotImplementedException();
    }

    public IConnectionMultiplexer Multiplexer => null;

    public TimeSpan Ping(CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public EndPoint IdentifyEndpoint(RedisChannel channel, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public Task IdentifyEndpointAsync(RedisChannel channel, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public bool IsConnected(RedisChannel channel = new RedisChannel())
    {
        throw new NotImplementedException();
    }

    /// Posts a message to the given channel.
    /// The channel to publish to.
    /// The message to publish.
    /// The command flags to use.
    /// 
    /// The number of clients that received the message *on the destination server*,
    /// note that this doesn't mean much in a cluster as clients can get the message through other nodes.
    /// 
    /// 
    public long Publish(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None)
    {
        foreach (var handler in _handlers) 
            handler(channel, message);

        return _handlers.Count;
    }

    /// 
    public Task PublishAsync(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None)
    {
        return Task.FromResult(Publish(channel, message, flags));
    }

    /// 
    /// Subscribe to perform some operation when a message to the preferred/active node is broadcast, without any guarantee of ordered handling.
    /// 
    /// The channel to subscribe to.
    /// The handler to invoke when a message is received on .
    /// The command flags to use.
    /// 
    /// ,
    /// 
    /// 
    public void Subscribe(RedisChannel channel, Action handler, CommandFlags flags = CommandFlags.None)
    {
        _handlers.Add(handler);
    }

    /// 
    public Task SubscribeAsync(RedisChannel channel, Action handler, CommandFlags flags = CommandFlags.None)
    {
        _handlers.Add(handler);

        return Task.CompletedTask;
    }

    public ChannelMessageQueue Subscribe(RedisChannel channel, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public Task SubscribeAsync(RedisChannel channel, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public EndPoint SubscribedEndpoint(RedisChannel channel)
    {
        throw new NotImplementedException();
    }

    public void Unsubscribe(RedisChannel channel, Action handler = null, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public Task UnsubscribeAsync(RedisChannel channel, Action handler = null, CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public void UnsubscribeAll(CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }

    public Task UnsubscribeAllAsync(CommandFlags flags = CommandFlags.None)
    {
        throw new NotImplementedException();
    }
}