예제 #1
1
 private static TestResult RunTests( string assemFile, ConsoleListener l )
 {
     TestPackage testPackage = new TestPackage( assemFile );
     RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
     remoteTestRunner.Load( testPackage );
     return remoteTestRunner.Run( l, TestFilter.Empty, false, LoggingThreshold.Debug );
 }
예제 #2
0
        public void ShouldFilterAssertionLibraryImplementationDetailsWhenLibraryNamespacesAreSpecified()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();

                var convention = new SelfTestConvention();

                convention
                .AssertionLibrary
                .Namespace(typeof(SampleAssert).Namespace);

                convention.Execute(listener, typeof(SampleTestClass));

                console
                .Output.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
                .Select(x => Regex.Replace(x, @":line \d+", ":line #"))     //Avoid brittle assertion introduced by stack trace line numbers.
                .ShouldEqual(
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.DivideByZero' failed: System.DivideByZeroException",
                    "Attempted to divide by zero.",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.DivideByZero() in " + PathToThisFile() + ":line #",
                    "",
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.FailedAssertion' failed: ",
                    "Expected 1, but was 0.",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.FailedAssertion() in " + PathToThisFile() + ":line #",
                    "",
                    "");
            }
        }
예제 #3
0
        public void ShouldReportPassFailSkipCounts()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();
                var assembly = typeof(ConsoleListener).Assembly;
                var version  = assembly.GetName().Version;

                var assemblyResult   = new AssemblyResult(assembly.Location);
                var conventionResult = new ConventionResult("Fake Convention");
                var classResult      = new ClassResult("Fake Class");
                assemblyResult.Add(conventionResult);
                conventionResult.Add(classResult);
                classResult.Add(CaseResult.Passed("A", TimeSpan.Zero));
                classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter())));
                classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter())));
                classResult.Add(CaseResult.Skipped("D", "Reason"));
                classResult.Add(CaseResult.Skipped("E", "Reason"));
                classResult.Add(CaseResult.Skipped("F", "Reason"));

                listener.AssemblyCompleted(assembly, assemblyResult);

                console.Lines().ShouldEqual("1 passed, 2 failed, 3 skipped, took 0.00 seconds (Fixie " + version + ").");
            }
        }
예제 #4
0
        public void ShouldReportResultsToTheConsole()
        {
            using (var console = new RedirectedConsole())
                using (var listener = new ConsoleListener())
                {
                    typeof(PassFailTestClass).Run(listener, SelfTestConvention.Build());

                    var testClass = typeof(PassFailTestClass).FullName;

                    console.Lines()
                    .Select(CleanBrittleValues)
                    .ShouldEqual(
                        "------ Testing Assembly Fixie.Tests.dll ------",
                        "Test '" + testClass + ".SkipWithReason' skipped: Skipped due to naming convention.",
                        "Test '" + testClass + ".SkipWithoutReason' skipped",
                        "Console.Out: FailA",
                        "Console.Error: FailA",
                        "Console.Out: FailB",
                        "Console.Error: FailB",
                        "Console.Out: PassA",
                        "Console.Error: PassA",
                        "Console.Out: PassB",
                        "Console.Error: PassB",
                        "Console.Out: PassC",
                        "Console.Error: PassC",

                        "Test '" + testClass + ".FailA' failed: Fixie.Tests.FailureException",
                        "'FailA' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailA() in " + PathToThisFile() + ":line #",
                        "Test '" + testClass + ".FailB' failed: Fixie.Tests.FailureException",
                        "'FailB' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailB() in " + PathToThisFile() + ":line #",
                        "3 passed, 2 failed, 2 skipped, took 1.23 seconds (Fixie 1.2.3.4).");
                }
        }
예제 #5
0
 private static void InitializeConsoleListener(ListenerConfiguration configuration)
 {
     try
     {
         lock (m_ListenerLock)
         {
             //we can't register the console listener more than once, and it isn't designed for good register/unregister handling
             //so we just have a simple bool to see if we did it.
             if ((m_ConsoleListenerRegistered == false) && (configuration.EnableConsole))
             {
                 ConsoleListener.RegisterConsoleIntercepter();
                 m_ConsoleListenerRegistered = true;
             }
         }
     }
     catch (Exception ex)
     {
         if (!Log.SilentMode)
         {
             Log.Write(LogMessageSeverity.Error, LogWriteMode.Queued, ex, true, "Gibraltar.Agent",
                       "Unable to initialize Common Language Runtime Listener due to " + ex.GetBaseException().GetType().Name,
                       "While attempting to do a routine initialization / re-initialization of the console listener, an exception was raised: {0}", ex.Message);
         }
     }
 }
예제 #6
0
        public void ShouldReportResultsToTheConsole()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();

                new SelfTestConvention().Execute(listener, typeof(PassFailTestClass));

                var testClass = typeof(PassFailTestClass).FullName;

                console.Lines()
                .Select(x => Regex.Replace(x, @":line \d+", ":line #"))        //Avoid brittle assertion introduced by stack trace line numbers.
                .ShouldEqual(
                    "Test '" + testClass + ".SkipA' skipped",
                    "Console.Out: FailA",
                    "Console.Error: FailA",
                    "Console.Out: FailB",
                    "Console.Error: FailB",
                    "Console.Out: PassA",
                    "Console.Error: PassA",
                    "Console.Out: PassB",
                    "Console.Error: PassB",
                    "Console.Out: PassC",
                    "Console.Error: PassC",

                    "Test '" + testClass + ".FailA' failed: Fixie.Tests.FailureException",
                    "'FailA' failed!",
                    "   at Fixie.Tests.Listeners.ConsoleListenerTests.PassFailTestClass.FailA() in " + PathToThisFile() + ":line #",
                    "Test '" + testClass + ".FailB' failed: Fixie.Tests.FailureException",
                    "'FailB' failed!",
                    "   at Fixie.Tests.Listeners.ConsoleListenerTests.PassFailTestClass.FailB() in " + PathToThisFile() + ":line #");
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            IntPtr inHandle = GetStdHandle(STD_INPUT_HANDLE);
            uint   mode     = 0;

            GetConsoleMode(inHandle, ref mode);
            mode &= ~ENABLE_QUICK_EDIT_MODE;
            mode |= ENABLE_WINDOW_INPUT;
            mode |= ENABLE_MOUSE_INPUT;
            SetConsoleMode(inHandle, mode);
            Console.SetWindowSize(80, 40);

            using var _ = Terminal.Initialize();

            ConsoleListener.Start();
            ConsoleListener.MouseEvent += ConsoleListener_MouseEvent;
            ConsoleListener.KeyEvent   += ConsoleListener_KeyEvent;
            Console.CursorVisible       = false;
            Console.SetCursorPosition(0, 0);
            Console.Title = "Work in progress";

            timer.Elapsed  += OnTimedEvent;
            timer.Interval  = gameSpeed;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
        public void ShouldNotAffectOutputByDefault()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();

                typeof(SampleTestClass).Run(listener, SelfTestConvention.Build());

                console
                .Output.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
                .Select(CleanBrittleValues)
                .ShouldEqual(
                    "------ Testing Assembly Fixie.Tests.dll ------",
                    "",
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.DivideByZero' failed: System.DivideByZeroException",
                    "Attempted to divide by zero.",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.DivideByZero() in " + PathToThisFile() + ":line #",
                    "",
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.FailedAssertion' failed: Fixie.Tests.SampleAssertionLibrary.AssertionException",
                    "Expected 1, but was 0.",
                    "   at Fixie.Tests.SampleAssertionLibrary.SampleAssert.AreEqual(Int32 expected, Int32 actual) in " + PathToThisFile() + ":line #",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.FailedAssertion() in " + PathToThisFile() + ":line #",
                    "",
                    "0 passed, 2 failed, took 1.23 seconds (Fixie 1.2.3.4).",
                    "",
                    "");
            }
        }
        public void ShouldFilterAssertionLibraryImplementationDetailsWhenLibraryTypesAreSpecified()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();

                var convention = SelfTestConvention.Build();

                convention
                .HideExceptionDetails
                .For <SampleAssertionLibrary.AssertionException>()
                .For(typeof(SampleAssertionLibrary.SampleAssert));

                typeof(SampleTestClass).Run(listener, convention);

                console
                .Output.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
                .Select(CleanBrittleValues)
                .ShouldEqual(
                    "------ Testing Assembly Fixie.Tests.dll ------",
                    "",
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.DivideByZero' failed: System.DivideByZeroException",
                    "Attempted to divide by zero.",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.DivideByZero() in " + PathToThisFile() + ":line #",
                    "",
                    "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.FailedAssertion' failed: ",
                    "Expected 1, but was 0.",
                    "   at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.FailedAssertion() in " + PathToThisFile() + ":line #",
                    "",
                    "0 passed, 2 failed, took 1.23 seconds (Fixie 1.2.3.4).",
                    "",
                    "");
            }
        }
예제 #10
0
    private static void Main(string[] args)
    {
        var listener = new ConsoleListener();

        listener.OnQuit           += OnExit;
        listener.OnCommandEntered += OnCommand;
        listener.StartListening();
    }
예제 #11
0
 /// <summary>
 /// Обновляет все игровые объекты.
 /// </summary>
 private void UpdateGameObjects()
 {
     foreach (var gameObject in AllObgects)
     {
         gameObject.Update();
     }
     ConsoleListener.Update(this);
 }
예제 #12
0
 private void Awake() //This must be onenable, only for hook log
 {
     LerpedCore.lerpedCore = LerpedCore.AutoHookCore();
     Debug.HookLog(!string.IsNullOrEmpty(m_defLogPath) ? m_defLogPath : Path.Combine(Application.dataPath, LerpedCore.defaultLogFilePath));
     if (m_runConsoleAtPlayEvent)
     {
         ConsoleListener.StartConsole();
     }
 }
예제 #13
0
        public void ShouldNotReportSkipCountsWhenZeroTestsHaveBeenSkipped()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();
                var assembly = typeof(ConsoleListener).Assembly;
                var version  = assembly.GetName().Version;

                listener.AssemblyCompleted(assembly, new AssemblyResult(1, 2, 0));

                console.Lines().ShouldEqual("1 passed, 2 failed (Fixie " + version + ").");
            }
        }
예제 #14
0
    static void RunTests()
    {
        string assemFile = GetAssembly();
        ConsoleListener l = new ConsoleListener();

        TestResult result = RunTests( assemFile, l );
        if( result.IsSuccess ) {
            Debug.Log( String.Format( "{0} tests successful", l.numTests ) );
        }
        else {
            Debug.LogError( "Test failed" );
        }
    }
예제 #15
0
        static void Main(string[] args)
        {
            //Events of the same type for phrases will be triggered according to the specified order.
            ConsoleListener.IntaractivePhrases = new List <Phrase>()
            {
                new Phrase(word),
                new Phrase(url),
                new Phrase(sector),
            };

            foreach (var phrase in ConsoleListener.IntaractivePhrases)
            {
                phrase.ConsoleMouseUpEvent    += OnPhraseMouseUp;
                phrase.ConsoleMouseDownEvent  += OnPhraseMouseDown;
                phrase.ConsoleMouseClickEvent += OnPhraseMouseClick;
                phrase.ConsoleMouseEnterEvent += OnPhraseMouseEnter;
                phrase.ConsoleMouseLeaveEvent += OnPhraseMouseLeave;
            }
            ConsoleListener.Start();

            Console.WriteLine(@"Lorem /ipsum dolor sit amet, /consectetur/ adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud /exercitation/ ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui /officia/ deserunt mollit anim id est laborum.");

            Console.WriteLine();

            curLeft = Console.CursorLeft;
            curTop  = Console.CursorTop + 1;

            Console.WriteLine("https://github.com/Vovanda");
            var tempUrl = new Phrase(url);

            Phrase.FindInPosition(0, curTop - 1, ref tempUrl);
            SetUrlPhraseColor(tempUrl, ConsoleColor.DarkCyan, 0, curTop++);

            Console.WriteLine("https://vk.com/vuvu_man");
            Phrase.FindInPosition(0, curTop - 1, ref tempUrl);
            SetUrlPhraseColor(tempUrl, ConsoleColor.DarkCyan, 0, curTop++);

            Console.ReadKey();

            ConsoleListener.Stop();
            foreach (var phrase in ConsoleListener.IntaractivePhrases)
            {
                phrase.ConsoleMouseUpEvent    -= OnPhraseMouseUp;
                phrase.ConsoleMouseDownEvent  -= OnPhraseMouseDown;
                phrase.ConsoleMouseClickEvent -= OnPhraseMouseClick;
                phrase.ConsoleMouseEnterEvent -= OnPhraseMouseEnter;
                phrase.ConsoleMouseLeaveEvent -= OnPhraseMouseLeave;
            }
        }
예제 #16
0
        /// <summary>
        /// Run listener
        /// </summary>
        private static async Task RunEventListenerAsync()
        {
            var logger = ConsoleLogger.Create();
            var bus    = new ServiceBusEventBus(new ServiceBusClientFactory(
                                                    new ServiceBusConfig(null)), logger);
            var listener = new ConsoleListener();

            using (var subscriber1 = new ApplicationEventBusSubscriber(bus, listener.YieldReturn()))
                using (var subscriber2 = new EndpointEventBusSubscriber(bus, listener.YieldReturn())) {
                    var tcs = new TaskCompletionSource <bool>();
                    AssemblyLoadContext.Default.Unloading += _ => tcs.TrySetResult(true);
                    await tcs.Task;
                }
        }
예제 #17
0
        private static void Main(string[] args)
        {
            //
            //  TODO: Parse the app arguments.
            //
            string outputFilePath = null;
            string inputFilePath  = null;

            if (null != args)
            {
                if (0 < args.Length)
                {
                    outputFilePath = args[0];
                }
                if (1 < args.Length)
                {
                    inputFilePath = args[1];
                }
            }

            ConsoleListener listener = null;

            try
            {
                if (null != inputFilePath)
                {
                    listener = new ConsoleListener(outputFilePath, inputFilePath);
                }
                else if (null != outputFilePath)
                {
                    listener = new ConsoleListener(outputFilePath);
                }
                else
                {
                    listener = new ConsoleListener();
                }

                StarTrekClassic.Program.Main(PlaybackTest.ProgramArgs);
                Debug.WriteLine(listener.InputRecord);
            }
            finally
            {
                if (null != listener)
                {
                    listener.Dispose();
                }
            }
        }
예제 #18
0
 public SpaceUpdater(ISceneProcesser sceneProcesser, ISceneLoader sceneLoader)
 {
     this.sceneLoader    = sceneLoader;
     this.sceneProcesser = sceneProcesser;
     consoleListener     = new ConsoleListener(c =>
     {
         if (c == "end")
         {
             ConsoleControl.HideWindow();
         }
         else
         {
             sceneProcesser.Process(c);
         }
     });
 }
예제 #19
0
        public void ShouldProvideDiagnosticDescriptionWhenNoTestsWereExecuted()
        {
            void NoTestsFound(Discovery discovery)
            => discovery.Methods.Where(x => false);

            var listener = new ConsoleListener();

            using (var console = new RedirectedConsole())
            {
                Run(listener, NoTestsFound);

                console.Output
                .Lines()
                .Last()
                .ShouldEqual("No tests found.");
            }
        }
예제 #20
0
        public void ShouldReportResults()
        {
            var listener = new ConsoleListener();

            using (var console = new RedirectedConsole())
            {
                Run(listener);

                console.Output
                .CleanStackTraceLineNumbers()
                .CleanDuration()
                .Lines()
                .ShouldEqual(
                    "Console.Out: Fail",
                    "Console.Error: Fail",
                    "Test '" + TestClass + ".Fail' failed:",
                    "",
                    "'Fail' failed!",
                    "",
                    "Fixie.Tests.FailureException",
                    At("Fail()"),
                    "",

                    "Console.Out: FailByAssertion",
                    "Console.Error: FailByAssertion",
                    "Test '" + TestClass + ".FailByAssertion' failed:",
                    "",
                    "Expected: 2",
                    "Actual:   1",
                    "",
                    "Fixie.Assertions.AssertActualExpectedException",
                    At("FailByAssertion()"),
                    "",

                    "Console.Out: Pass",
                    "Console.Error: Pass",

                    "Test '" + TestClass + ".SkipWithReason' skipped:",
                    "Skipped with reason.",
                    "",
                    "Test '" + TestClass + ".SkipWithoutReason' skipped",
                    "",
                    "1 passed, 2 failed, 2 skipped, took 1.23 seconds");
            }
        }
예제 #21
0
        public void ShouldNotReportSkipCountsWhenZeroTestsHaveBeenSkipped()
        {
            void ZeroSkipped(Discovery discovery)
            => discovery.Methods.Where(x => !x.Name.StartsWith("Skip"));

            var listener = new ConsoleListener();

            using (var console = new RedirectedConsole())
            {
                Run(listener, ZeroSkipped);

                console.Output
                .Lines()
                .Last()
                .CleanDuration()
                .ShouldEqual("1 passed, 2 failed, took 1.23 seconds");
            }
        }
예제 #22
0
        private static void SafeMain(string[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
                return;
            }

            ConsoleListener.EnsureConsole();

            if (args.Any(s => s == "/?" || s == "-?"))
            {
                PrintUsage();
                return;
            }

            if (Trace.Listeners.Count == 0 || Trace.Listeners.Count == 1 &&
                Trace.Listeners[0].GetType() == typeof(DefaultTraceListener))
            {
                Trace.Listeners.Add(new ConsoleTraceListener());
            }

            Settings settings;

            if (args.Length > 2)
            {
                settings = Settings.Deserialize(args[2]);
            }
            else
            {
                settings = Settings.GetDefault();
            }

            // XmlSerializer serializer = new XmlSerializer(typeof(Settings));
            // using (Stream s = File.OpenWrite("settings.xml"))
            // serializer.Serialize(s, settings);
            var exporter = new Exporter(args[0], settings);
            var result   = exporter.Export(args[1]);

            Logger.Current.Log(LogCategory.Summary, "Directories: " + result.Directories);
            Logger.Current.Log(LogCategory.Summary, "Files:       " + result.Files);
        }
예제 #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // if (double.TryParse("0,", out double res)) Console.WriteLine(res);
            // else Console.WriteLine("Err");
            // ExpressionPlus plus = new ExpressionPlus();
            // Console.WriteLine(plus.GetType().IsSubclassOf(typeof(ExpressionPriorityOperation)));
            // return;

            Expression             expression   = new Expression();
            ExpressionEventChannel eventChannel = new ExpressionEventChannel();

            eventChannel.Subscribe(expression);

            ConsoleListener listener = new ConsoleListener(eventChannel);

            listener.Listen();
        }
예제 #24
0
        public void ShouldNotReportSkipCountsWhenZeroTestsHaveBeenSkipped()
        {
            using (var console = new RedirectedConsole())
                using (var listener = new ConsoleListener())
                {
                    var convention = SelfTestConvention.Build();

                    convention
                    .Methods
                    .Where(method => !method.Has <SkipAttribute>());

                    typeof(PassFailTestClass).Run(listener, convention);

                    var testClass = typeof(PassFailTestClass).FullName;

                    console.Lines()
                    .Select(CleanBrittleValues)
                    .ShouldEqual(
                        "------ Testing Assembly Fixie.Tests.dll ------",
                        "",
                        "Console.Out: FailA",
                        "Console.Error: FailA",
                        "Console.Out: FailB",
                        "Console.Error: FailB",
                        "Console.Out: PassA",
                        "Console.Error: PassA",
                        "Console.Out: PassB",
                        "Console.Error: PassB",
                        "Console.Out: PassC",
                        "Console.Error: PassC",

                        "Test '" + testClass + ".FailA' failed: Fixie.Tests.FailureException",
                        "'FailA' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailA() in " + PathToThisFile() + ":line #",
                        "",
                        "Test '" + testClass + ".FailB' failed: Fixie.Tests.FailureException",
                        "'FailB' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailB() in " + PathToThisFile() + ":line #",
                        "",
                        "3 passed, 2 failed, took 1.23 seconds (" + Framework.Version + ").");
                }
        }
예제 #25
0
        public void ShouldReportResultsToTheConsole()
        {
            using (var console = new RedirectedConsole())
                using (var listener = new ConsoleListener())
                {
                    var convention = SelfTestConvention.Build();
                    convention.CaseExecution.Skip(x => x.Method.Has <SkipAttribute>(), x => x.Method.GetCustomAttribute <SkipAttribute>().Reason);

                    typeof(PassFailTestClass).Run(listener, convention);

                    var testClass = typeof(PassFailTestClass).FullName;

                    console.Lines()
                    .Select(CleanBrittleValues)
                    .ShouldEqual(
                        "------ Testing Assembly Fixie.Tests.dll ------",
                        "",
                        "Test '" + testClass + ".SkipWithReason' skipped: Skipped with reason.",
                        "Test '" + testClass + ".SkipWithoutReason' skipped",
                        "Console.Out: FailA",
                        "Console.Error: FailA",
                        "Console.Out: FailB",
                        "Console.Error: FailB",
                        "Console.Out: PassA",
                        "Console.Error: PassA",
                        "Console.Out: PassB",
                        "Console.Error: PassB",
                        "Console.Out: PassC",
                        "Console.Error: PassC",

                        "Test '" + testClass + ".FailA' failed: Fixie.Tests.FailureException",
                        "'FailA' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailA() in " + PathToThisFile() + ":line #",
                        "",
                        "Test '" + testClass + ".FailB' failed: Fixie.Tests.FailureException",
                        "'FailB' failed!",
                        "   at Fixie.Tests.ConsoleRunner.ConsoleListenerTests.PassFailTestClass.FailB() in " + PathToThisFile() + ":line #",
                        "",
                        "3 passed, 2 failed, 2 skipped, took 1.23 seconds (" + Framework.Version + ").");
                }
        }
예제 #26
0
        private static int Execute(ServerParameters arg)
        {
            var config = arg.BuildServerConfig();

            EnsureRequiredApplications(arg, config);
            config.DllFolder = EnvironmentInfo.ResolvePath("@repos@/.build/bin/all");
            var command = arg.Get("command", "");

            if (string.IsNullOrWhiteSpace(command))
            {
                Console.WriteLine("LOGLEVEL " + config.LogLevel);
            }
            var hostServer = new HostServer(config);

            hostServer.Initialize();
            var consoleContext = new ConsoleContext
            {
                Container  = hostServer.Container,
                Parameters = arg
            };
            var listener = new ConsoleListener(consoleContext);

            if (!string.IsNullOrWhiteSpace(command))
            {
                var task = listener.Call(command);
                task.Wait();
            }
            else
            {
                LogHostInfo(arg, config);
                hostServer.Start();
                Console.WriteLine("LOGLEVEL " + config.LogLevel);

                listener.Log = hostServer.Container.Get <ILoggyManager>().Get("console");
                listener.Run();
                hostServer.Stop();
            }
            return(0);
        }
예제 #27
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string [] args)
        {
            var service = new AdministrationService()
            {
                CanStop = true,
            };

            if (args.Any())
            {
                var listener = new ConsoleListener();
                listener.EnableEvents(HomeHubEventSource.Log, EventLevel.Informational);

                ThreadPool.QueueUserWorkItem(service.StartService);
                Console.WriteLine("Services started. Waiting. Press enter to exit.");
                Console.Read();
                service.StopService();
            }
            else
            {
                ServiceBase.Run(service);
            }
        }
예제 #28
0
        private static void InitializeConsoleListener(ListenerConfiguration configuration)
        {
            try
            {
                lock (m_ListenerLock)
                {
                    //we can't register the console listener more than once, and it isn't designed for good register/unregister handling
                    //so we just have a simple bool to see if we did it.
                    if ((m_ConsoleListenerRegistered == false) && (configuration.EnableConsole))
                    {
                        ConsoleListener.RegisterConsoleIntercepter();
                        m_ConsoleListenerRegistered = true;
                    }
                }
            }
            catch (Exception ex)
            {
                GC.KeepAlive(ex);
#if DEBUG
                Log.Write(LogMessageSeverity.Error, LogWriteMode.Queued, ex, "Gibraltar.Agent", "Error while Initializing Console Listener",
                          "While attempting to do a routine initialization / re-initialization of the console listener, an exception was raised: {0}", ex.Message);
#endif
            }
        }
예제 #29
0
        /// <summary>
        /// Main.
        /// </summary>
        /// <param name="args">Args to main...</param>
        public static void Main(string[] args)
        {
            var listener = new ConsoleListener();

            listener.EnableEvents(Trace, EventLevel.Informational);
            Trace.Startup();
            startupTimer = new Timer(Program.Run, null, 1000, Timeout.Infinite);

            startupHandle.WaitOne();
            string line;

            do
            {
                // Write the prompt
                Program.WritePrompt();


                line = Console.ReadLine();
                line = line.Trim().ToLowerInvariant();
                var pargs = line.Split(' ');

                switch (pargs[0])
                {
                case "push":
                {
                    if (pargs.Length < 3)
                    {
                        Console.WriteLine("Invalid args.");
                        break;
                    }
                    var queueName = pargs[1];
                    var value     = pargs[2];
                    QueueManager.Intance[queueName].Enqueue(value);
                }
                break;

                case "pop":
                {
                    if (pargs.Length < 2)
                    {
                        Console.WriteLine("Invalid args.");
                        break;
                    }
                    var queueName = pargs[1];
                    var item      = QueueManager.Intance[queueName].Dequeue()?.Payload;

                    Console.WriteLine(item ?? "Queue empty");
                }
                break;

                case "list":
                {
                    foreach (var queue in QueueManager.Intance.List)
                    {
                        Console.WriteLine($"Name: {queue.Name} Length: {queue.Count} Index: {queue.Index} Enabed: {queue.IsEnabled}");
                    }
                    break;
                }

                case "purge":
                {
                    if (pargs.Length < 2)
                    {
                        Console.WriteLine("Invalid args.");
                        break;
                    }
                    var queueName = pargs[1];
                    QueueManager.Intance[queueName].IsEnabled = false;
                    break;
                }

                case "enable":
                {
                    if (pargs.Length < 2)
                    {
                        Console.WriteLine("Invalid args.");
                        break;
                    }
                    var queueName = pargs[1];
                    QueueManager.Intance[queueName].IsEnabled = true;
                    break;
                }

                case "exit":
                    break;

                case "":
                    break;

                default:
                    Console.WriteLine("Invalid Argument");
                    break;
                }
            }while (false == String.Equals("exit", line, StringComparison.OrdinalIgnoreCase));

            // Finish the program
            Program.Cleanup();
        }
예제 #30
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        public static void Init()
        {
            Running = true;

            Logger.WriteLog("--------- Server Started at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " ---------");
            Logger.Log("Debug mode started", LogType.Debug);
            //TODO Add debug messages
            //TODO load the level if it exists
            Block.InIt();
            Logger.Log("Starting update timer", LogType.Debug);
            UpdateTimer = new System.Threading.Timer((e) => Update(), null, 0, 100);
            Logger.Log("Log timer started", LogType.Debug);
            Logger.Log("Loading DLL's", LogType.Debug);
            LoadAllDlls.Init();
            Logger.Log("Finished loading DLL's", LogType.Debug);
            Logger.Log("Sending Heartbeat..", LogType.Debug);
            Logger.Log("Auto-Updater Starting..", LogType.Debug);
            Updater.InIt();
            HeartThread = new Thread(new ThreadStart(Heartbeat.ActivateHeartBeat));
            HeartThread.Start();
            Logger.Log("Starting Physics Tick..", LogType.Debug);
            PhysicsBlock.InIt();
            CmdReloadCmds reload = new CmdReloadCmds();

            reload.Initialize();

            Groups.PlayerGroup.Load();
            VerifyGroup = Groups.PlayerGroup.Find(ServerSettings.GetSetting("VerifyGroup"));
            Mainlevel   = Level.LoadLevel(ServerSettings.GetSetting("Main-Level"));
            if (Mainlevel == null)
            {
                Mainlevel = Level.CreateLevel(new Vector3S(256, 128, 64), Level.LevelTypes.Flat);
                ServerSettings.SetSetting("Main-Level", null, "main");
            }
            Level.Levels.Add(Mainlevel);
            if (ServerSettings.GetSettingBoolean("LoadAllLevels"))
            {
                Level.LoadAllLevels();
            }
            BlockQueue.Start();
            Backup.StartBackup();

            Database.Init();

            CreateCoreFiles();

            InternetUtils = new InetUtils();
            InetUtils.InternetAvailable = InetUtils.CanConnectToInternet();

            Logger.Log("Loading Bans", LogType.Debug);
            Logger.Log("IPBANS", LogType.Debug);
            IPBans = new List <string>(File.ReadAllLines("bans/IPBans.txt"));
            Logger.Log("IPBANS", LogType.Debug);
            UsernameBans = new List <string>(File.ReadAllLines("bans/NameBans.txt"));
            StartListening();
            Started = true;

            if (OnServerFinishSetup != null)
            {
                OnServerFinishSetup();
            }
            blockThread = new Thread(new ThreadStart(delegate
            {
                while (true)
                {
                    Thread.Sleep(60000);
                    Level.Levels.ForEach(delegate(Level l)
                    {
                        try
                        {
                            l.SaveToBinary();
                        }
                        catch (Exception e)
                        {
                            Logger.LogError(e);
                        }
                    });
                }
            }));
            blockThread.Start();
            Logger.Log("[Important]: Server Started.", Color.Black, Color.White);
            if (!ServerSettings.GetSettingBoolean("VerifyNames"))
            {
                Logger.Log("[Important]: The server is running with verify names off! This could lead to bad things! Please turn on verify names if you dont know the risk and dont want these bad things to happen!", LogType.Critical);
            }

            if (ServerSettings.GetSettingBoolean("IRC-Enabled"))
            {
                try
                {
                    IRC = new ServerChat();
                    IRC.Connect();
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }

            if (ServerSettings.GetSettingBoolean("GC-Enabled"))
            {
                GC = new GlobalChat();
                try
                {
                    GC.Connect();
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }

            try
            {
                RC = new ConsoleListener();
                RC.Start();
            }
            catch { }

            PlayerConnectionTimeoutChecker = new Thread(() => {
                int sleep = ServerSettings.GetSettingInt("AutoTimeout");
                if (sleep < 0)
                {
                    sleep = 30;
                }
                if (sleep != 0)
                {
                    while (Running)
                    {
                        for (int i = 0; i < sleep && Running; i++)
                        {
                            Thread.Sleep(1000);
                        }
                        if (!Running)
                        {
                            break;
                        }
                        foreach (Player p in Players)
                        {
                            if (p.lastReceived.AddSeconds(sleep) < DateTime.Now)
                            {
#if !DEBUG
                                p.Kick("The connection timed out");
#endif
                            }
                        }
                    }
                }
            });
            PlayerConnectionTimeoutChecker.Start();
        }
예제 #31
0
            public ControlTraceListener(Control ctrl, bool withConsole)
            {
                this.m_traceCtrl = ctrl;
                TraceListenerCollection traceListeners = Trace.Listeners;
                if (!traceListeners.Contains(this))
                {
                    traceListeners.Add(this);
                }

                if (withConsole)
                {
                    this.m_consoleListener = new ConsoleListener(this);
                    Console.SetOut(this.m_consoleListener);
                }
            }
예제 #32
0
        private static void RunApplication(object data)
        {
            try
            {
                bool   verboseOff  = (bool)((object[])data)[0];
                string oprFilename = (string)((object[])data)[1];

                // check whether opr file exists
                if (oprFilename == null)
                {
                    Console.WriteLine("Error: -r switch was not specified.");
                    _exitCode = 3;
                    return;
                }

                FileInfo fileInfo = new FileInfo(oprFilename);
                if (!fileInfo.Exists)
                {
                    Console.WriteLine("Error: cannot find input file " + oprFilename);
                    _exitCode = 4;
                    return;
                }


                // open OPR
                CompositionManager composition = new CompositionManager();

                if (!verboseOff)
                {
                    Console.WriteLine("Loading project file " + fileInfo.FullName + "...");
                }
                composition.LoadFromFile(fileInfo.FullName);


                // prepare listeners
                if (!verboseOff)
                {
                    Console.WriteLine("Preparing listener(s)...");
                }
                ArrayList listOfListeners = new ArrayList();

                // logfile listener
                if (composition.LogToFile != null && composition.LogToFile != "")
                {
                    // get composition file's directory to logfile is saved in same directory
                    string          logFileName     = Utils.GetFileInfo(fileInfo.DirectoryName, composition.LogToFile).FullName;
                    LogFileListener logFileListener = new LogFileListener(composition.ListenedEventTypes, logFileName);
                    listOfListeners.Add(logFileListener);
                }

                // console listener
                if (!verboseOff)
                {
                    ConsoleListener consoleListener = new ConsoleListener(composition.ListenedEventTypes);
                    listOfListeners.Add(consoleListener);
                }

                // create proxy listener
                ProxyListener proxyListener = new ProxyListener();
                proxyListener.Initialize(listOfListeners);

                // run simulation
                if (!verboseOff)
                {
                    Console.WriteLine("Starting composition run...");
                }
                composition.Run(proxyListener, true);

                if (!verboseOff)
                {
                    Console.WriteLine("Closing composition...");
                }
                composition.Release();

                _exitCode = 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occured: " + e.ToString());
                _exitCode = -2;
                return;
            }
        }