Ejemplo n.º 1
0
        private static void WriteError(string msg, string code, [CallerLineNumber] int line = 0, [CallerMemberName] string member = "XXXX", [CallerFilePath] string file = "XXXX")
        {
            string text = $"ERREUR [{code}] (ligne : {line} || membre : {member} || fichier : {file})\n\tmessage >> {msg}";

            PConsole.WErrorParsing(text);
            WriteFileLog(text);
        }
Ejemplo n.º 2
0
        private static void WriteLog(string msg)
        {
            string text = "LOG > " + msg + "\n";

            PConsole.PrintLn(text, ConsoleColor.Cyan);
            WriteFileLog(text);
        }
Ejemplo n.º 3
0
        private static void WriteLoopLog(string msg)
        {
            string text = "BOUCLE:log > " + msg + "\n";

            PConsole.PrintLn(text, ConsoleColor.Green);
            WriteFileLog(text);
        }
Ejemplo n.º 4
0
        private static async Task MainAsync(string[] args)
        {
            WriteLog("demarrage BOT...");
            try
            {
                using (client = new DiscordSocketClient())
                {
                    client.Log             += BotLog;
                    client.MessageReceived += OnMessageReceived;
                    client.Ready           += Client_Ready;

                    await client.LoginAsync(Discord.TokenType.Bot, "NjMxNDk0MDA1OTM0NTIyMzg4.XaCO9g.SNDyoXPa4iik7rlHfn_WLK1fE1Y");

                    await client.StartAsync();

                    await Task.Delay(-1);
                }
            }
            catch (Exception e)
            {
                WriteError(e.ToString(), "MainAsyncException_0x1");
                PConsole.QuitWithAsk();
            }
            finally
            {
                client?.Dispose();
            }
        }
Ejemplo n.º 5
0
        public void ShowGoogle_should_write_response_from_google_to_standard_output()
        {
            // Prig has no attributes like HostType("Moles"). Use using (new IndirectionsContext()) instead of that.
            using (new IndirectionsContext())
            {
                // Arrange
                var handler = default(DownloadStringCompletedEventHandler);
                handler = (sender, e) => { };

                // AllInstances that is the feature of Moles to mock all instance members doesn't exist, because it is default feature.
                PWebClient.AddDownloadStringCompletedDownloadStringCompletedEventHandler().Body    = (@this, value) => handler += value;
                PWebClient.RemoveDownloadStringCompletedDownloadStringCompletedEventHandler().Body = (@this, value) => handler -= value;
                PWebClient.DownloadStringAsyncUri().Body = (@this, address) =>
                {
                    // Use the stub that starts with PProxy if you want to mock against one instance.
                    var e = new PProxyDownloadStringCompletedEventArgs();
                    e.ResultGet().Body = @this_ => "google!modoki";
                    handler(@this, e);
                };
                var mockWriteLine = new Mock <IndirectionAction <string> >();
                mockWriteLine.Setup(_ => _(It.IsAny <string>()));
                PConsole.WriteLineString().Body = mockWriteLine.Object;


                // Act
                ULWebClient.ShowGoogle();


                // Assert
                mockWriteLine.Verify(_ => _("google!modoki"), Times.Once());
            }
        }
Ejemplo n.º 6
0
 private void UpdateSettingsPath(string settingsPath)
 {
     Directory.CreateDirectory(Application.dataPath + "/" + settingsPath);
     EditorPrefs.SetString("consoleSettingsPath", settingsPath);
     PConsole.SaveSettings();
     LoadSettings();
     Console.Log("Console Settings file path has been updated to 'Assets/" + settingsPath + "/'", PrefixType.NoPrefix);
     Repaint();
 }
        public void AutoConfiguredMoqPrigCustomization_should_not_mock_void_method_because_it_makes_no_effects()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var ms      = new MockStorage(MockBehavior.Default);
                var fixture = new Fixture().Customize(new AutoConfiguredMoqPrigCustomization(ms));

                PConsole.WriteLineString().Body = value => { throw new NotImplementedException(); };
                fixture.Create <PConsole>();


                // Act, Assert
                Assert.Throws <NotImplementedException>(() => Console.WriteLine("bla bla bla"));
            }
        }
Ejemplo n.º 8
0
    private void LoadSettings()
    {
        // Create or load the file
        settingsFilePath = PConsole.GetFileStream();
        if (File.Exists(settingsFilePath))
        {
            PConsole.LoadSettingsFromFile(settingsFilePath);
        }
        else
        {
            PConsole.CreateSettingsFile(settingsFilePath);
        }

        // Set datapath
        string consoleSettingsPath = EditorPrefs.GetString("consoleSettingsPath");

        newSettingsFilePath = consoleSettingsPath != string.Empty ? consoleSettingsPath : "HelloWorld Tools/PrettyConsole";
    }
Ejemplo n.º 9
0
        private static Task BotLog(LogMessage message)
        {
            string text = "";

            if (message.Exception != null)
            {
                text = $"Erreur [{message.Severity}] : " + message.Exception + "\n";
                PConsole.PrintLn(text, ConsoleColor.DarkRed);
                WriteFileLog(text);
            }
            else
            {
                text = $"Log [{message.Severity}] : " + message.Message + "\n";
                PConsole.PrintLn(text, ConsoleColor.DarkGreen);
                WriteFileLog(text);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 10
0
 public static void Log(string message, PrefixType prefixType)
 {
     Debug.Log(PConsole.GetLog(LogType.Log, message, prefixType, null, null));
 }
Ejemplo n.º 11
0
        private static async Task LoopGetServerStatus()
        {
            long i = 0;

            WriteLog("Mise en route boucle...");

            while (true)
            {
                WriteLoopLog("Boucle n " + (++i));

                WriteLoopLog("Récupération de l'état du serveur...");
                ServerStatus status = await GetServerStatus();

                WriteLoopLog("Etat serveur :");
                WriteLoopLog($"{status.status} : {status.nbPlayer} joueurs");
                if (status.status == ServerStatus.Status.Error)
                {
                    loopErrorOccured = true;
                    WriteLoopLog("Erreur !");
                    WriteError(status.error, "Loop_0x1");
                    await updateChannel.SendMessageAsync("J'ai rencontré une erreur lors de mon travail... Merci de contacter l'administrateur !");

                    WriteLoopLog("Appuyer sur une touche pour réessayer...");
                    PConsole.ReadChar();
                }
                else
                {
                    loopErrorOccured = false;
                }

                //status changed
                if (!status.Equals(last_servst))
                {
                    //status online
                    if (status.status == ServerStatus.Status.Online)
                    {
                        await updateChannel.SendMessageAsync($"Le serveur est désormais ouvert avec {status.nbPlayer} joueurs !");
                    }


                    //status offline
                    else if (status.status == ServerStatus.Status.Offline)
                    {
                        await updateChannel.SendMessageAsync("Le serveur est malheureusement fermé...");
                    }


                    //error
                    else
                    {
                        WriteLoopLog("etat serveur : ERREUR");

                        WriteError(status.error, "GetServerStatus_0x1");
                        WriteLoopLog("Appuyer sur une touche pour réessayer...");
                        PConsole.ReadChar();
                    }
                    last_servst = status;
                }
                WriteLoopLog("Sommeil...(" + UPDATE_TIME + " ms)");
                await Task.Delay(UPDATE_TIME);
            }
        }
Ejemplo n.º 12
0
 public static string String(string message)
 {
     return(PConsole.GetLog(LogType.Log, message, null, null, null));
 }
Ejemplo n.º 13
0
 public static string StringWarning(string message, Color messageColor)
 {
     return(PConsole.GetLog(LogType.Warning, message, null, null, messageColor));
 }
Ejemplo n.º 14
0
 public static string StringWarning(string message, FontStyle messageStyle)
 {
     return(PConsole.GetLog(LogType.Warning, message, null, messageStyle, null));
 }
Ejemplo n.º 15
0
 public static string StringWarning(string message, PrefixType prefixType)
 {
     return(PConsole.GetLog(LogType.Warning, message, prefixType, null, null));
 }
Ejemplo n.º 16
0
 public static string StringError(string message, Color messageColor)
 {
     return(PConsole.GetLog(LogType.Error, message, null, null, messageColor));
 }
Ejemplo n.º 17
0
 public static void Log(string message, Color?messageColor, FontStyle?messageStyle, PrefixType?prefixType)
 {
     Debug.Log(PConsole.GetLog(LogType.Log, message, prefixType, messageStyle, messageColor));
 }
Ejemplo n.º 18
0
 public static void LogWarning(string message, Color messageColor)
 {
     Debug.LogWarning(PConsole.GetLog(LogType.Warning, message, null, null, messageColor));
 }
Ejemplo n.º 19
0
 public static void LogError(string message, Color messageColor)
 {
     Debug.LogError(PConsole.GetLog(LogType.Error, message, null, null, messageColor));
 }
Ejemplo n.º 20
0
 public static void Log(string message, FontStyle messageStyle)
 {
     Debug.Log(PConsole.GetLog(LogType.Log, message, null, messageStyle, null));
 }
Ejemplo n.º 21
0
 public static string StringError(string message, Color?messageColor, FontStyle?messageStyle, PrefixType?prefixType)
 {
     return(PConsole.GetLog(LogType.Error, message, prefixType, messageStyle, messageColor));
 }
Ejemplo n.º 22
0
 public static string StringError(string message, PrefixType prefixType)
 {
     return(PConsole.GetLog(LogType.Error, message, prefixType, null, null));
 }
Ejemplo n.º 23
0
 public static string StringError(string message, FontStyle messageStyle)
 {
     return(PConsole.GetLog(LogType.Error, message, null, messageStyle, null));
 }