Exemplo n.º 1
0
 /// <summary>
 /// Create an MQTT client the uses SSL encryption for communications.
 /// </summary>
 /// <param name="encryptionLevel">The encryption level to use.</param>
 /// <param name="caCertificate">The certificate for client authorities to use for authentication.</param>
 /// <returns></returns>
 public static MqttClient CreateSecureClient(SocketEncryption encryptionLevel, X509Certificate caCertificate)
 {
     var logManager = new LogCompositor();
     ActiveClientCollection.Instance.TestCanAddNewClient();
     // Each platform has its own implementation of Sockets and reader threads.
     var client = new MqttClient(new NetMfSocketAdapter(logManager, caCertificate), logManager, encryptionLevel);
     ActiveClientCollection.Instance.AddClient(client);
     return client;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create an MQTT client that does not use encryption for communications.
 /// </summary>
 /// <returns>An MQTT client ready to make connections to a broker.</returns>
 public static MqttClient CreateClient()
 {
     var logManager = new LogCompositor();
     ActiveClientCollection.Instance.TestCanAddNewClient();
     // Each platform has its own implementation of Sockets and reader threads.
     var client = new MqttClient(new NetMfSocketAdapter(logManager), logManager, SocketEncryption.None);
     ActiveClientCollection.Instance.AddClient(client);
     return client;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create an MQTT client the uses SSL encryption for communications. If the certificate is private and not
 /// signed ay a trusted Certificate Authority, the certificate must be installed in the application's
 /// certificate store ahead of making a connection.
 /// </summary>
 /// <param name="encryption">The encryption level to use.</param>
 /// <returns>An MQTT client ready to make secure connections to a broker.</returns>
 public static MqttClient CreateSecureClient(SocketEncryption encryption)
 {
     var logManager = new LogCompositor();
     logManager.AddLoggingProvider(typeof(DebugLogger));
     ActiveClientCollection.Instance.TestCanAddNewClient();
     // Each platform has its own implementation of Sockets and reader threads.
     var client = new MqttClient(new WinRTSocketAdapter(logManager), logManager, encryption);
     ActiveClientCollection.Instance.AddClient(client);
     return client;
 }
Exemplo n.º 4
0
        public void LoggingManagerCallsOnLogCallbacks()
        {
            var mgr = new LogCompositor();
            mgr.AddLoggingProvider(typeof (PluginLogger1));

            Assert.AreEqual(1, mgr.Loggers.Count);

            mgr.LogMessage("", LogLevel.Verbose, "Log message");
            mgr.LogException("", LogLevel.Error, "Log exception", new Exception());

            var plugin = (PluginLogger1)mgr.Loggers.First();

            Assert.AreEqual(1, plugin.LogMessageCallCount);
            Assert.AreEqual(1, plugin.LogExceptionCallCount);
        }
Exemplo n.º 5
0
        public void LoggingManagerThrowsExceptionForNonILoggerTypes()
        {
            var mgr = new LogCompositor();

            try
            {
                mgr.AddLoggingProvider(typeof (PluginLogger2));
                Assert.Fail("No exception thrown with incorrect type.");
            }
            catch (ArgumentException)
            {
            }
            catch (Exception)
            {
                Assert.Fail("Wrong exception type thrown with incorrect type.");
            }
        }
Exemplo n.º 6
0
 public void LoggingToManagerWithNoLoggersDoesNotFail()
 {
     var mgr = new LogCompositor();
     mgr.LogMessage("", LogLevel.Verbose, "Log message");
     mgr.LogException("", LogLevel.Error, "Log exception", new Exception());
 }