public void WritesOverloads()
        {
            var capture = new ConsoleCapture();

            var o = new object();

            HConsole.Configure(o, config => config.SetMaxLevel(0));

            using (capture.Output())
            {
                HConsole.WriteLine(o, "text0");
                HConsole.WriteLine(o, 0, "text1");
                HConsole.WriteLine(o, 2);
                HConsole.WriteLine(o, 0, 3);
                HConsole.WriteLine(o, "-{0}-", 4);
                HConsole.WriteLine(o, 0, "-{0}-", 5);

                HConsole.WriteLine(o, 1, "text1");
                HConsole.WriteLine(o, 1, 3);
                HConsole.WriteLine(o, 1, "-{0}-", 5);
            }

            Assert.That(capture.ReadToEnd().ToLf(), Is.EqualTo($@"{Prefix()}text0
{Prefix()}text1
{Prefix()}2
{Prefix()}3
{Prefix()}-4-
{Prefix()}-5-
".ToLf()));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Authenticator"/> class.
        /// </summary>
        public Authenticator(AuthenticationOptions options, SerializationService serializationService)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _serializationService = serializationService ?? throw new ArgumentNullException(nameof(serializationService));

            HConsole.Configure(x => x.Set(this, config => config.SetIndent(4).SetPrefix("AUTH")));
        }
Exemplo n.º 3
0
        public void WritesOverloads()
        {
            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx.SetLevel(0)));

            HConsole.WriteLine(o, "text0");
            HConsole.WriteLine(o, 0, "text1");
            HConsole.WriteLine(o, 2);
            HConsole.WriteLine(o, 0, 3);
            HConsole.WriteLine(o, "-{0}-", 4);
            HConsole.WriteLine(o, 0, "-{0}-", 5);

            HConsole.WriteLine(o, 1, "text1");
            HConsole.WriteLine(o, 1, 3);
            HConsole.WriteLine(o, 1, "-{0}-", 5);

            Assert.That(HConsole.Text.ToLf(), Is.EqualTo($@"{Prefix()}text0
{Prefix()}text1
{Prefix()}2
{Prefix()}3
{Prefix()}-4-
{Prefix()}-5-
".ToLf()));
        }
Exemplo n.º 4
0
        public async Task Cluster()
        {
            // this test expects a server

            HConsole.Configure(x => x.Configure(this).SetIndent(0).SetPrefix("TEST"));
            HConsole.WriteLine(this, "Begin");

            HConsole.WriteLine(this, "Cluster?");

            var serializationService = new SerializationServiceBuilder(new NullLoggerFactory())
                                       .SetVersion(1)
                                       .Build();

            var options = new HazelcastOptions();

            //options.Networking.Addresses.Add("sgay-l4");
            options.Networking.Addresses.Add("localhost");

            var cluster = new Cluster(options, serializationService, new NullLoggerFactory());
            await cluster.Connections.ConnectAsync(CancellationToken.None).CfAwait();

            // now we can send messages...
            //await cluster.SendAsync(new ClientMessage()).CAF();

            // events?
            await Task.Delay(4000).CfAwait();

            HConsole.WriteLine(this, "End");
            await Task.Delay(100).CfAwait();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterMessaging"/> class.
        /// </summary>
        /// <param name="clusterState">The cluster state.</param>
        /// <param name="clusterMembers">The cluster members.</param>
        public ClusterMessaging(ClusterState clusterState, ClusterMembers clusterMembers)
        {
            _clusterState   = clusterState;
            _clusterMembers = clusterMembers;

            HConsole.Configure(x => x.Configure <ClusterMessaging>().SetPrefix("MSGING"));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerSocketListener"/> class.
        /// </summary>
        /// <param name="endpoint">The socket endpoint.</param>
        /// <param name="hcname">An HConsole name complement.</param>
        public ServerSocketListener(IPEndPoint endpoint, string hcname)
        {
            _endpoint = endpoint;
            _hcname   = hcname;

            HConsole.Configure(x => x.Configure(this).SetIndent(24).SetPrefix("LISTENER".Dot(hcname)));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Authenticator"/> class.
        /// </summary>
        public Authenticator(AuthenticationOptions options, SerializationService serializationService, ILoggerFactory loggerFactory)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _serializationService = serializationService ?? throw new ArgumentNullException(nameof(serializationService));
            _logger = (loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory))).CreateLogger <Authenticator>();

            HConsole.Configure(x => x.Configure <Authenticator>().SetIndent(4).SetPrefix("AUTH"));
        }
        public HConsoleLoggerProvider(TestingLoggerOptions options = null)
        {
            _options = options ?? new TestingLoggerOptions();

#if HZ_CONSOLE
            HConsole.Configure(x => x.Configure <HConsoleLoggerProvider>().SetPrefix("LOG"));
#endif
        }
        public async Task Test()
        {
            //var host = Dns.GetHostEntry(_hostname);
            //var ipAddress = host.AddressList[0];
            //var endpoint = new IPEndPoint(ipAddress, _port);

            var address = NetworkAddress.Parse("127.0.0.1:11001");

            HConsole.Configure(this, config => config.SetIndent(0).SetPrefix("TEST"));
            HConsole.WriteLine(this, "Begin");

            HConsole.WriteLine(this, "Start server");
            var server = new Server(address, ReceiveMessage, LoggerFactory);
            await server.StartAsync().CAF();

            var options = HazelcastOptions.Build(Array.Empty <string>(), configure: (configuration, options) =>
            {
                options.Networking.Addresses.Add("127.0.0.1:11001");
            });

            HConsole.WriteLine(this, "Start client 1");
            await using var client1 = (HazelcastClient)HazelcastClientFactory.CreateClient(options);
            await client1.StartAsync().CAF();

            HConsole.WriteLine(this, "Send message 1 to client 1");
            var message  = CreateMessage("ping");
            var response = await client1.Cluster.Messaging.SendAsync(message, CancellationToken.None).CAF();

            HConsole.WriteLine(this, "Got response: " + GetText(response));

            HConsole.WriteLine(this, "Start client 2");
            await using var client2 = (HazelcastClient)HazelcastClientFactory.CreateClient(options);
            await client2.StartAsync().CAF();

            HConsole.WriteLine(this, "Send message 1 to client 2");
            message  = CreateMessage("a");
            response = await client2.Cluster.Messaging.SendAsync(message, CancellationToken.None).CAF();

            HConsole.WriteLine(this, "Got response: " + GetText(response));

            HConsole.WriteLine(this, "Send message 2 to client 1");
            message  = CreateMessage("foo");
            response = await client1.Cluster.Messaging.SendAsync(message, CancellationToken.None).CAF();

            HConsole.WriteLine(this, "Got response: " + GetText(response));

            //XConsole.WriteLine(this, "Stop client");
            //await client1.CloseAsync().CAF();

            HConsole.WriteLine(this, "Stop server");
            await server.StopAsync().CAF();

            await Task.Delay(1000).CAF();

            HConsole.WriteLine(this, "End");
            await Task.Delay(100).CAF();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerSocketConnection"/> class.
        /// </summary>
        /// <param name="id">The unique identifier of the connection.</param>
        /// <param name="socket">The underlying network socket.</param>
        /// <param name="hcname">An HConsole name complement.</param>
        public ServerSocketConnection(Guid id, Socket socket, string hcname)
            : base(id)
        {
            _acceptingSocket = socket ?? throw new ArgumentNullException(nameof(socket));

            var prefix = "SVR.CONN".Dot(hcname);

            HConsole.Configure(x => x.Configure(this).SetIndent(32).SetPrefix($"{prefix} [{id}]"));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientSocketConnection"/> class.
 /// </summary>
 /// <param name="id">The unique identifier of the connection.</param>
 /// <param name="endpoint">The socket endpoint.</param>
 /// <param name="options">Socket options.</param>
 /// <param name="sslOptions">SSL options.</param>
 /// <param name="loggerFactory">A logger factory.</param>
 /// <param name="prefixLength">An optional prefix length.</param>
 public ClientSocketConnection(int id, IPEndPoint endpoint, SocketOptions options, SslOptions sslOptions, ILoggerFactory loggerFactory, int prefixLength = 0)
     : base(id, prefixLength)
 {
     _endpoint      = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
     _socketOptions = options ?? throw new ArgumentNullException(nameof(options));
     _sslOptions    = sslOptions ?? throw new ArgumentNullException(nameof(sslOptions));
     _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     HConsole.Configure(this, config => config.SetIndent(16).SetPrefix($"CONN.CLIENT [{id}]"));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientSocketConnection"/> class.
        /// </summary>
        /// <param name="id">The unique identifier of the connection.</param>
        /// <param name="endpoint">The socket endpoint.</param>
        /// <param name="options">Networking options.</param>
        /// <param name="sslOptions">SSL options.</param>
        /// <param name="loggerFactory">A logger factory.</param>
        /// <param name="prefixLength">An optional prefix length.</param>
        public ClientSocketConnection(Guid id, IPEndPoint endpoint, NetworkingOptions options, SslOptions sslOptions, ILoggerFactory loggerFactory, int prefixLength = 0)
            : base(id, prefixLength)
        {
            _endpoint      = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
            _options       = options ?? throw new ArgumentNullException(nameof(options));
            _sslOptions    = sslOptions ?? throw new ArgumentNullException(nameof(sslOptions));
            _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));

            HConsole.Configure(x => x.Configure(this).SetIndent(16).SetPrefix($"CLT.CONN [{id.ToShortString()}]"));
        }
Exemplo n.º 13
0
        public void WritesOtherLevelsIfConfigured()
        {
            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx.SetLevel(1)));

            HConsole.WriteLine(o, "text0"); // default level is 0
            HConsole.WriteLine(o, 1, "text1");

            Assert.That(HConsole.Text.ToLf(), Is.EqualTo($"{Prefix()}text0\n{Prefix()}text1\n".ToLf()));
        }
Exemplo n.º 14
0
        public void WritesWithPrefix()
        {
            HConsole.Configure(x => x.Set <object>(xx => xx.SetPrefix("XX")));

            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx.SetLevel(0)));

            HConsole.WriteLine(o, "text0");

            Assert.That(HConsole.Text.ToLf(), Is.EqualTo($"{Prefix("XX")}text0\n".ToLf()));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Server"/> class.
        /// </summary>
        /// <param name="address">The socket network address.</param>
        /// <param name="handler">A handler for incoming messages.</param>
        /// <param name="loggerFactory">A logger factory.</param>
        public Server(NetworkAddress address, Func <Server, ClientMessageConnection, ClientMessage, ValueTask> handler, ILoggerFactory loggerFactory)
        {
            _address       = address;
            _endpoint      = address.IPEndPoint;
            _handler       = handler;
            _loggerFactory = loggerFactory;

            _clusterId = Guid.NewGuid();
            _memberId  = Guid.NewGuid();

            HConsole.Configure(this, config => config.SetIndent(20).SetPrefix("SERVER"));
        }
        public void ArgumentExceptions()
        {
            Assert.Throws <ArgumentNullException>(() => HConsole.WriteLine(null, "text"));
            Assert.Throws <ArgumentNullException>(() => HConsole.WriteLine(null, 1));
            Assert.Throws <ArgumentNullException>(() => HConsole.WriteLine(null, 0, "text"));
            Assert.Throws <ArgumentNullException>(() => HConsole.WriteLine(null, 0, "{0}", 0));
            Assert.Throws <ArgumentNullException>(() => HConsole.WriteLine(null, 0, 1));
            Assert.Throws <ArgumentNullException>(() => HConsole.Configure(new object(), null));
            Assert.Throws <ArgumentNullException>(() => HConsole.Configure <object>(null));

            Assert.Throws <ArgumentNullException>(() => HConsole.Lines(null, 0, ""));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterState"/> class.
        /// </summary>
        public ClusterState(IClusterOptions options, string clusterName, string clientName, Partitioner partitioner, ILoggerFactory loggerFactory)
        {
            Options       = options;
            ClusterName   = clusterName;
            ClientName    = clientName;
            Partitioner   = partitioner;
            LoggerFactory = loggerFactory;

            _stateChangeQueue = new StateChangeQueue(loggerFactory);

            HConsole.Configure(x => x.Configure <ClusterState>().SetPrefix("CLUST.STATE"));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberConnection"/> class.
        /// </summary>
        /// <param name="address">The network address.</param>
        /// <param name="messagingOptions">Messaging options.</param>
        /// <param name="socketOptions">Socket options.</param>
        /// <param name="sslOptions">SSL options.</param>
        /// <param name="connectionIdSequence">A sequence of unique connection identifiers.</param>
        /// <param name="correlationIdSequence">A sequence of unique correlation identifiers.</param>
        /// <param name="loggerFactory">A logger factory.</param>
        /// <remarks>
        /// <para>The <paramref name="connectionIdSequence"/> parameter can be used to supply a
        /// sequence of unique connection identifiers. This can be convenient for tests, where
        /// using unique identifiers across all clients can simplify debugging.</para>
        /// </remarks>
        public MemberConnection(NetworkAddress address, MessagingOptions messagingOptions, SocketOptions socketOptions, SslOptions sslOptions, ISequence <int> connectionIdSequence, ISequence <long> correlationIdSequence, ILoggerFactory loggerFactory)
        {
            Address                = address ?? throw new ArgumentNullException(nameof(address));
            _messagingOptions      = messagingOptions ?? throw new ArgumentNullException(nameof(messagingOptions));
            _socketOptions         = socketOptions ?? throw new ArgumentNullException(nameof(socketOptions));
            _sslOptions            = sslOptions ?? throw new ArgumentNullException(nameof(sslOptions));
            _connectionIdSequence  = connectionIdSequence ?? throw new ArgumentNullException(nameof(connectionIdSequence));
            _correlationIdSequence = correlationIdSequence ?? throw new ArgumentNullException(nameof(correlationIdSequence));
            _loggerFactory         = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            _logger                = loggerFactory.CreateLogger <MemberConnection>();

            HConsole.Configure(this, config => config.SetIndent(4).SetPrefix("CLIENT"));
        }
Exemplo n.º 19
0
        public void HazelcastTestBaseOneTimeRootSetUp()
        {
            // setup the logger
            LoggerFactory = CreateLoggerFactory();
            Logger        = LoggerFactory.CreateLogger(GetType());
            Logger.LogInformation($"Setup {GetType()}");

            // start fresh
            HConsole.Configure(x => x.ClearAll());

            // top-level overrides
            HazelcastTestBaseOneTimeSetUp();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberConnection"/> class.
        /// </summary>
        /// <param name="address">The network address.</param>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="messagingOptions">Messaging options.</param>
        /// <param name="networkingOptions">Networking options.</param>
        /// <param name="sslOptions">SSL options.</param>
        /// <param name="correlationIdSequence">A sequence of unique correlation identifiers.</param>
        /// <param name="loggerFactory">A logger factory.</param>
        public MemberConnection(NetworkAddress address, Authenticator authenticator, MessagingOptions messagingOptions, NetworkingOptions networkingOptions, SslOptions sslOptions, ISequence <long> correlationIdSequence, ILoggerFactory loggerFactory)
        {
            Address                = address ?? throw new ArgumentNullException(nameof(address));
            _authenticator         = authenticator ?? throw new ArgumentNullException(nameof(authenticator));
            _messagingOptions      = messagingOptions ?? throw new ArgumentNullException(nameof(messagingOptions));
            _networkingOptions     = networkingOptions ?? throw new ArgumentNullException(nameof(networkingOptions));
            _sslOptions            = sslOptions ?? throw new ArgumentNullException(nameof(sslOptions));
            _correlationIdSequence = correlationIdSequence ?? throw new ArgumentNullException(nameof(correlationIdSequence));
            _loggerFactory         = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            _logger                = loggerFactory.CreateLogger <MemberConnection>();

            HConsole.Configure(x => x.Configure <MemberConnection>().SetIndent(4).SetPrefix("MBR.CONN"));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Starts the server.
        /// </summary>
        /// <returns>A task that will complete when the server has started.</returns>
        public async Task StartAsync()
        {
            HConsole.WriteLine(this, $"Start server at {_endpoint}");

            _listener = new ServerSocketListener(_endpoint)
            {
                OnAcceptConnection = AcceptConnection, OnShutdown = ListenerShutdown
            };
            HConsole.Configure(_listener, config => config.SetIndent(24).SetPrefix("LISTENER"));
            _open = true;
            await _listener.StartAsync().CAF();

            HConsole.WriteLine(this, "Server started");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Server"/> class.
        /// </summary>
        /// <param name="address">The socket network address.</param>
        /// <param name="handler">A handler for incoming messages.</param>
        /// <param name="state">A server-state object.</param>
        /// <param name="hcname">An HConsole name complement.</param>
        /// <param name="loggerFactory">A logger factory.</param>
        public Server(NetworkAddress address, Func <Server, ClientMessageConnection, ClientMessage, ValueTask> handler, ILoggerFactory loggerFactory, object state = null, string hcname = "")
        {
            Address        = address;
            State          = state;
            _endpoint      = address.IPEndPoint;
            _handler       = handler;
            _loggerFactory = loggerFactory;
            _hcname        = hcname;

            ClusterId = Guid.NewGuid();
            MemberId  = Guid.NewGuid();

            HConsole.Configure(x => x.Configure(this).SetIndent(20).SetPrefix("SERVER".Dot(_hcname)));
        }
Exemplo n.º 23
0
        public void ConfigureToString()
        {
            HConsole.Configure(x => x.Set <object>(xx => xx
                                                   .SetIndent(4)
                                                   .SetLevel(3)));

            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx
                                          .SetPrefix("XX")
                                          .SetLevel(4)));

            Assert.That(HConsole.Options.Get(o).ToString(), Is.EqualTo("indent = 4, prefix = \"XX\", level = 4"));
        }
        public void ConfigureToString()
        {
            HConsole.Configure <object>(x => x
                                        .SetIndent(4)
                                        .SetMaxLevel(3));

            var o = new object();

            HConsole.Configure(o, x => x
                               .SetPrefix("XX")
                               .SetMaxLevel(4));

            Assert.That(HConsole.GetConfig(o).ToString(), Is.EqualTo("{Config: 4, \"XX\", 4}"));
        }
Exemplo n.º 25
0
        public async Task CanRetryAndSucceed()
        {
            var address = NetworkAddress.Parse("127.0.0.1:11001");

            HConsole.Configure(x => x.Configure(this).SetIndent(0).SetPrefix("TEST"));
            HConsole.WriteLine(this, "Begin");

            HConsole.WriteLine(this, "Start server");
            var count = 0;

            await using var server = new Server(address, async(xsvr, xconn, xmsg)
                                                => await HandleAsync(xsvr, xconn, xmsg, async(svr, conn, msg) =>
            {
                HConsole.WriteLine(svr, "Handle request.");
                ClientMessage response;
                if (++count > 3)
                {
                    HConsole.WriteLine(svr, "Respond with success.");
                    response = ClientPingServerCodec.EncodeResponse();
                }
                else
                {
                    HConsole.WriteLine(svr, "Respond with error.");
                    response        = CreateErrorMessage(RemoteError.RetryableHazelcast);
                    response.Flags |= ClientMessageFlags.BeginFragment | ClientMessageFlags.EndFragment;
                }
                response.CorrelationId = msg.CorrelationId;
                await conn.SendAsync(response).CfAwait();
            }), LoggerFactory);
            await server.StartAsync().CfAwait();

            HConsole.WriteLine(this, "Start client");
            var options = HazelcastOptions.Build(configure: (configuration, options) =>
            {
                options.Networking.Addresses.Add("127.0.0.1:11001");
            });

            await using var client = (HazelcastClient) await HazelcastClientFactory.StartNewClientAsync(options);

            HConsole.WriteLine(this, "Send message");
            var message = ClientPingServerCodec.EncodeRequest();

            var token = new CancellationTokenSource(3_000).Token;
            await client.Cluster.Messaging.SendAsync(message, token); // default is 120s

            Assert.AreEqual(4, count);

            await server.StopAsync().CfAwait();
        }
Exemplo n.º 26
0
        public void CanResetConfiguration()
        {
            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx.SetLevel(1)));

            HConsole.WriteLine(o, 1, "text1");

            Assert.That(HConsole.Text.ToLf(), Is.EqualTo($"{Prefix()}text1\n".ToLf()));

            HConsole.Reset();

            HConsole.WriteLine(o, 1, "text0");

            Assert.That(HConsole.Text, Is.EqualTo(""));
        }
        public void WritesOtherLevelsIfConfigured()
        {
            var capture = new ConsoleCapture();

            var o = new object();

            HConsole.Configure(o, config => config.SetMaxLevel(1));

            using (capture.Output())
            {
                HConsole.WriteLine(o, "text0"); // default level is 0
                HConsole.WriteLine(o, 1, "text1");
            }

            Assert.That(capture.ReadToEnd().ToLf(), Is.EqualTo($"{Prefix()}text0\n{Prefix()}text1\n".ToLf()));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DistributedEventScheduler"/> class.
        /// </summary>
        /// <param name="loggerFactory">A logger factory.</param>
        public DistributedEventScheduler(ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _logger = loggerFactory.CreateLogger <DistributedEventScheduler>();

            // TODO: how many queues should we retain?
            const int size = 10;

            _pool = new SimpleObjectPool <Queue>(() => new Queue(), size);

            HConsole.Configure(x => x.Configure <DistributedEventScheduler>().SetPrefix("EVENTS"));
        }
        public void Configure()
        {
            HConsole.Configure <object>(x => x
                                        .SetIndent(4)
                                        .SetPrefix("XX")
                                        .SetMaxLevel(3));

            var config = HConsole.GetConfig(new object());

            Assert.That(config.Prefix, Is.EqualTo("XX"));
            Assert.That(config.Indent, Is.EqualTo(4));
            Assert.That(config.MaxLevel, Is.EqualTo(3));

            HConsole.Configure <object>(x => x
                                        .ClearIndent()
                                        .ClearPrefix()
                                        .ClearMaxLevel());

            config = HConsole.GetConfig(new object());

            Assert.That(config.Prefix, Is.Null);
            Assert.That(config.Indent, Is.EqualTo(0));
            Assert.That(config.MaxLevel, Is.EqualTo(-1));

            HConsole.ClearConfiguration <object>();

            var o = new object();

            HConsole.Configure(o, x => x
                               .SetIndent(4)
                               .SetPrefix("XX")
                               .SetMaxLevel(3));

            config = HConsole.GetConfig(o);

            Assert.That(config.Prefix, Is.EqualTo("XX"));
            Assert.That(config.Indent, Is.EqualTo(4));
            Assert.That(config.MaxLevel, Is.EqualTo(3));

            HConsole.ClearConfiguration(o);

            config = HConsole.GetConfig(o);

            Assert.That(config.Prefix, Is.Null);
            Assert.That(config.Indent, Is.EqualTo(0));
            Assert.That(config.MaxLevel, Is.EqualTo(-1));
        }
        public void WritesWithPrefix()
        {
            HConsole.Configure <object>(config => config.SetPrefix("XX"));

            var capture = new ConsoleCapture();

            var o = new object();

            HConsole.Configure(o, config => config.SetMaxLevel(0));

            using (capture.Output())
            {
                HConsole.WriteLine(o, "text0");
            }

            Assert.That(capture.ReadToEnd().ToLf(), Is.EqualTo($"{Prefix("XX")}text0\n".ToLf()));
        }