コード例 #1
0
 public void DebugWithMsgShouldNotCallUnderlyingDebugWhenDebugIsDisabled()
 {
     underlyingLoggerMock.Setup(l => l.IsDebugEnabled).Returns(false);
     isDebugEnabledResolverMock.Setup(r => r.Value).Returns(underlyingLoggerMock.Object.IsDebugEnabled);
     logger.Debug("msg");
     underlyingLoggerMock.Verify(l => l.Debug(It.IsAny <string>()), Times.Never());
 }
コード例 #2
0
        void ShouldNotLogEverything()
        {
            // Arrange
            var logStrategy = new Mock <ILogStrategy>();

            logStrategy.Setup(x => x.WriteMessage(It.IsAny <string>())).Verifiable();
            var shouldLog = LogLevel.Fatal | LogLevel.Info | LogLevel.Warn;
            var logger    = new LoggerFacade <RawLogger>(new LoggerSettings
            {
                LogLevel           = shouldLog,
                DefaultLogStrategy = logStrategy.Object
            });

            // Act
            logger.Debug("debug");
            logger.Error("error");
            logger.Fatal("fatal");
            logger.Info("info;");
            logger.Warn("warm;");

            // Assert
            logStrategy.Verify(x => x.WriteMessage(It.IsAny <string>()), Times.Exactly(3));


            foreach (var logLevel in Enum.GetValues(typeof(LogLevel)))
            {
                var logLevelEnum = (LogLevel)logLevel;
                if ((logLevelEnum & shouldLog) != LogLevel.None)
                {
                    logStrategy.Verify(x => x.WriteMessage(It.Is <string>(s => s.Contains($"{logLevelEnum}"))), Times.Once);
                }
            }
        }
コード例 #3
0
ファイル: Director.cs プロジェクト: SomeZyla/TsGui
 private void PopulateHwOptions()
 {
     if (this._hardwareevaluator != null)
     {
         LoggerFacade.Debug("Running hardware evaluator");
         foreach (TsVariable var in this._hardwareevaluator.GetTsVariables())
         {
             NoUIOption newhwoption = new NoUIOption();
             newhwoption.ImportFromTsVariable(var);
             this._optionlibrary.Add(newhwoption);
         }
     }
 }
コード例 #4
0
ファイル: ListBuilder.cs プロジェクト: SomeZyla/TsGui
        public List <ListItem> Rebuild()
        {
            LoggerFacade.Debug("ListBuilder rebuild initialised");
            int             i       = 0;
            List <ListItem> newlist = new List <ListItem>();

            while (i <= this._lastindex)
            {
                ListItem staticitem;
                if (this._staticitems.TryGetValue(i, out staticitem) == true)
                {
                    newlist.Add(staticitem);
                    i++;
                    continue;
                }

                QueryPriorityList qlist;
                if (this._querylists.TryGetValue(i, out qlist) == true)
                {
                    qlist.ProcessAllQueries();
                    ResultWrangler wrangler = qlist.GetResultWrangler();
                    if (wrangler != null)
                    {
                        List <KeyValueTreeNode> kvlist = wrangler.GetKeyValueTree();
                        foreach (KeyValueTreeNode node in kvlist)
                        {
                            //ListItem newoption = new ListItem(node.Value.Key, node.Value.Value, this._parent.ControlFormatting, this._parent, this._director);
                            newlist.Add(this.CreateItem(node));
                        }
                    }
                    i++;
                    continue;
                }
                i++;
            }

            if (this._parent.Sort)
            {
                newlist.Sort();
                foreach (ListItem item in newlist)
                {
                    item.Sort();
                }
            }
            this.Items = newlist;

            LoggerFacade.Debug("ListBuilder rebuild finished");
            return(newlist);
        }
コード例 #5
0
ファイル: Director.cs プロジェクト: SomeZyla/TsGui
        private void Startup()
        {
            LoggerFacade.Debug("*TsGui startup started");
            this.StartupFinished = false;
            this._prodmode       = this._envController.Init();


            XElement xconfig = this.ReadConfigFile();

            if (xconfig == null)
            {
                return;
            }

            //this.LoadXml(x);
            try { this.LoadXml(xconfig); }
            catch (TsGuiKnownException e)
            {
                string msg = "Error loading config file" + Environment.NewLine + e.CustomMessage + Environment.NewLine + e.Message;
                this.CloseWithError("Error loading config file", msg);
                return;
            }

            this.PopulateHwOptions();

            //now init everything
            this._optionlibrary.InitialiseOptions();

            //if prodmode isn't true, the envcontroller couldn't connect to sccm
            //prompt the user if they want to continue. exit if not.
            if (this._prodmode == true)
            {
                this._envController.HideProgressUI();
            }
            else
            {
                if (this.PromptTestMode() != true)
                {
                    this.Cancel(); return;
                }
                if (this._livedata == true)
                {
                    this._showtestwindow = true;
                }
            }

            //subscribe to closing event
            this.ParentWindow.Closing += this.OnWindowClosing;

            if (this._pages.Count > 0)
            {
                LoggerFacade.Debug("Loading pages");
                this.CurrentPage = this._pages.First();
                //update group settings to all controls
                foreach (IToggleControl t in this._toggles)
                {
                    t.InitialiseToggle();
                }

                this.ParentWindow.DataContext = this.TsMainWindow;

                // Now show and close the ghost window to make sure WinPE honours the
                // windowstartuplocation
                LoggerFacade.Trace("Loading ghost window");
                GhostWindow ghost = new GhostWindow();
                ghost.Show();
                ghost.Close();

                this.UpdateWindow();
                this.ParentWindow.Visibility            = Visibility.Visible;
                this.ParentWindow.WindowStartupLocation = this.TsMainWindow.WindowLocation.StartupLocation;
                this.StartupFinished = true;
                if ((this._debug == true) || (this._showtestwindow == true))
                {
                    this._testingwindow = new TestingWindow(this);
                }
                GuiTimeout.Instance?.Start(this.OnTimeoutReached);
                LoggerFacade.Info("*TsGui startup finished");
            }
            else
            {
                //No pages, finish using only the NoUI options
                LoggerFacade.Info("*No pages configured. Finishing TsGui");
                this.Finish();
            }
        }