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.Lines(null, 0, ""));
        }
        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, ""));
        }
        public async Task Auth()
        {
            // need to start a real server (not the RC thing!)

            //var address = NetworkAddress.Parse("sgay-l4");
            var address = NetworkAddress.Parse("localhost");

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

            HConsole.WriteLine(this, "Start client ");
            var client1 = new MemberConnection(address, new MessagingOptions(), new SocketOptions(), new SslOptions(), new Int64Sequence(), new NullLoggerFactory());
            await client1.ConnectAsync(CancellationToken.None).CAF();

            // RC assigns a GUID but the default cluster name is 'dev'
            var clusterName          = "dev";
            var username             = (string)null; // null
            var password             = (string)null; // null
            var clientId             = Guid.NewGuid();
            var clientType           = "CSP";        // CSharp
            var serializationVersion = (byte)0x01;
            var clientVersion        = "4.0";
            var clientName           = "hz.client_0";
            var labels         = new HashSet <string>();
            var requestMessage = ClientAuthenticationCodec.EncodeRequest(clusterName, username, password, clientId, clientType, serializationVersion, clientVersion, clientName, labels);

            HConsole.WriteLine(this, "Send auth request");
            var invocation      = new Invocation(requestMessage, new MessagingOptions(), null, CancellationToken.None);
            var responseMessage = await client1.SendAsync(invocation, CancellationToken.None).CAF();

            HConsole.WriteLine(this, "Rcvd auth response " +
                               HConsole.Lines(this, 1, responseMessage.Dump()));
            var response = ClientAuthenticationCodec.DecodeResponse(responseMessage);

            var status = (AuthenticationStatus)response.Status;

            NUnit.Framework.Assert.AreEqual(AuthenticationStatus.Authenticated, status);

            HConsole.WriteLine(this, "Stop client");
            await client1.DisposeAsync().CAF();

            HConsole.WriteLine(this, "End");
            await Task.Delay(100).CAF();
        }
Esempio n. 4
0
        public void Lines()
        {
            var o = new object();

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

            const string source = @"aaa
bbb
ccc";

            Assert.That(HConsole.Lines(o, 1, source), Is.EqualTo(""));

            Assert.That(HConsole.Lines(o, 0, source).ToLf(), Is.EqualTo(@"
       aaa
       bbb
       ccc".ToLf()));

            HConsole.Configure(x => x.Set <object>(xx => xx.SetPrefix("XX")));

            Assert.That(HConsole.Lines(o, 0, source).ToLf(), Is.EqualTo($@"
         aaa
         bbb
         ccc".ToLf()));
        }