Exemplo n.º 1
0
 public void When_dns_servers_unreachable_should_throw_SocketException()
 {
     var xmppHostsLookup = new XmppHostsLookup();
     var ipAddresses = new []{ IPAddress.Parse("1.1.1.1")}; //assuming there is no dns server at 1.1.1.1
     var logger = new ConsoleOutLogger("XmppHostsLookupTests", LogLevel.All, true, true, true, "yyyy-MM-dd HH:MM:SS");
     Assert.Throws<SocketException>( ()=> xmppHostsLookup.GetXmppHosts(ipAddresses, "host", logger));
 }
Exemplo n.º 2
0
        public void ShouldLogAtDebugLevel()
        {
            //arrange 
            var logger = new ConsoleOutLogger("Testing", LogLevel.Trace, true, true, true, string.Empty);
            var target = new DataContext(Settings.Default.Connection, new DriversEducationMappings(), logger);

            //act
            var firstDriver = new Driver("Devlin", "Liles");
            target.Add(firstDriver);
            target.Add(new Driver("Tim", "Rayburn"));
            target.Add(new Driver("Jay", "Smith"));
            target.Add(new Driver("Brian", "Sullivan"));
            target.Add(new Driver("Cori", "Drew"));

            target.Commit();

            target.Reload(firstDriver);

            foreach (var driver in target.AsQueryable<Driver>())
            {
                target.Remove(driver);
            }


            target.Commit();

            target.ExecuteSqlQuery<Driver>("Select * from Drivers Where LastName = @lastName",
                new DbParameter[] {new SqlParameter("lastName", "Liles")});

            //assert
            //Assert.Inconclusive("We fail here to get the output from console nice and easy");
        }
        /// <summary>
        /// Creates a new <see cref="ConsoleOutLogger"/> instance.
        /// </summary>
        protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat)
        {
#if !SILVERLIGHT
            ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat, this.useColor);
#else
            ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat);
#endif
            return(log);
        }
Exemplo n.º 4
0
 private static void PrintAllArgs(string[] args)
 {
     ILog logger = new ConsoleOutLogger("kernel.log", LogLevel.All, true, true, false, "yyyy/MM/dd HH:mm:ss:fff");
     logger.Debug("Hello2");
     foreach (string s in args)
     {
         logger.Debug(s);
     }
 }
Exemplo n.º 5
0
 public void When_lookup_internal_server_should_get_at_least_one_host()
 {
     //This test assumes a host on the internal network called winxmpp
     var xmppHostsLookup = new XmppHostsLookup();
     var dnsServerLookup = new WmiDnsServerLookup();
     var logger = new ConsoleOutLogger("XmppHostsLookupTests", LogLevel.All, true, true, true, "yyyy-MM-dd HH:MM:SS");
     XmppHost[] xmppHosts = xmppHostsLookup.GetXmppHosts(dnsServerLookup.GetDnsServers(), "winxmpp", logger);
     Assert.NotNull(xmppHosts);
     Assert.InRange(xmppHosts.Length, 1, int.MaxValue);
 }
Exemplo n.º 6
0
 public void When_lookup_gmail_xmpp_server_should_get_at_least_one_host()
 {
     //This test requires a working internet connection
     var xmppHostsLookup = new XmppHostsLookup();
     var dnsServerLookup = new WmiDnsServerLookup();
     var logger = new ConsoleOutLogger("XmppHostsLookupTests", LogLevel.All, true, true, true, "yyyy-MM-dd HH:MM:SS");
     XmppHost[] xmppHosts = xmppHostsLookup.GetXmppHosts(dnsServerLookup.GetDnsServers(), "gmail.com", logger);
     Assert.NotNull(xmppHosts);
     Assert.InRange(xmppHosts.Length, 1, int.MaxValue);
 }
Exemplo n.º 7
0
        public ScriptCsHost()
        {
            var logger = new ConsoleOutLogger("default", Common.Logging.LogLevel.Info, true, true, false, "dd MMM yyy hh:mm:ss");

            var scriptCsBuilder = new ScriptServicesBuilder(new ScriptConsole(), logger)
                .LogLevel(LogLevel.Debug)
                .Cache(true)
                .Repl(false)
                .ScriptEngine<RoslynScriptEngine>();

            _exec = scriptCsBuilder.Build().Executor;
        }
Exemplo n.º 8
0
        private static ConnectionInformation GetConnectionInformation(string filename)
        {
            ILog logger = new ConsoleOutLogger("kernel.log", LogLevel.All, true, true, false, "yyyy/MM/dd HH:mm:ss:fff");

            logger.Info(string.Format("Opening file {0}", filename));
            string fileContent = File.ReadAllText(@filename);
            logger.Debug(fileContent);

            ConnectionInformation connectionInformation =
                JsonConvert.DeserializeObject<ConnectionInformation>(fileContent);

            return connectionInformation;
        }
Exemplo n.º 9
0
        public LSLogger(string logName, LogLevel logLevel, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat)
        {
#if SILVERLIGHT

#if WINDOWS_PHONE
            _wrapped = new DebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);
#else
            _wrapped = new DebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);
#endif
#else
            _wrapped = new Common.Logging.Simple.ConsoleOutLogger(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);
#endif

        }
        public void Should_Execute_Query_With_Performance_Info()
        {
            //Arrange
            var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, "");
            var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(),
                                              consoleOutLogger);
            List<Foo> nullResult = context.AsQueryable<Foo>().ToList();

            //Act
            IEnumerable<Foo> result = null;

            result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, false);


            //Assert
            Assert.IsNotNull(result);
        }
        public void Should_Throw_An_Error_When_Query_Is_To_Slow()
        {
            //Arrange
            var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, "");
            var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(),
                                              consoleOutLogger);

            //Act
            IEnumerable<Foo> result = null;
            try
            {
                result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, maxAllowableMilliseconds: -1);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message.Contains("Query FindFoo"));
            }


            //Assert
            Assert.IsNull(result);
        }
        public void Should_Run_Compilation_Test_For_Context()
        {
            //Arrange
            var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, "");
            var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(),
                                              consoleOutLogger);

            //Act
            IEnumerable<Foo> result = null;
            try
            {
                var query = new FindFoo();
                context.RunStartUpPerformanceTest(query, consoleOutLogger, maxAllowableMilliseconds: -1);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message.Contains("Context Compilation in"));
            }


            //Assert
            Assert.IsNull(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a new <see cref="ConsoleOutLogger"/> instance.
        /// </summary>
        protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat)
        {
            ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat);

            return(log);
        }
 public void SetUp()
 {
     _logger = new ConsoleOutLogger(this.GetType().Name, LogLevel.All, true, false, false, "yyyy-MM-dd hh:mm:ss");
 }
Exemplo n.º 15
0
 private XmppClientSettings()
 {
     UseTLS = UseTLS.IfSupported;
     Log = new ConsoleOutLogger("XmppClient", LogLevel.All, true, true, true, "yyyy-MM-dd hh:mm:ss");
 }
        /// <summary>
        /// Creates a new <see cref="ConsoleOutLogger"/> instance.
        /// </summary>
        protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat)
        {
#if !SILVERLIGHT
            ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat, this.useColor);
#else
            ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat);
#endif
            return log;
        }
Exemplo n.º 17
0
 /// <summary>
 /// Creates a new <see cref="ConsoleOutLogger"/> instance.
 /// </summary>
 protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat)
 {
     ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat);
     return log;
 }
 private IModuleCatalog GetExternalModuleCatalog(IModuleCatalog local)
 {
     var logger = new ConsoleOutLogger("test", Common.Logging.LogLevel.All, true, true, true, "yyyy/MM/dd HH:mm:ss:fff");
     var externalModuleCatalog = new ExternalManifestModuleCatalog(local.Modules, new[] { "https://raw.githubusercontent.com/VirtoCommerce/vc-modules/master/modules.json" }, logger);
     return externalModuleCatalog;
 }