public void CanExtract_Exe_Name()
        {
            const string cmdLine = "wpa -i c:\\temp\\otherfile.etl";
            string       exe     = TraceControlViewModel.ExtractExecName(cmdLine);

            Assert.AreEqual("wpa", exe);
        }
        /// <summary>
        /// Validation checks when tracing was stopped. E.g. the output file was created if the command line did contain a $FileName parameter
        /// </summary>
        public void VerifySuccesfulStop()
        {
            if (TraceStopNotExpanded.Contains(TraceControlViewModel.TraceFileNameVariable))
            {
                if (!File.Exists(TraceFileName))
                {
                    RootModel.MessageBoxDisplay.ShowMessage($"Error: Output file {RootModel.StopData.TraceFileName} was not found!", "Error");
                }
            }
            else if (TraceStopNotExpanded.Contains(TraceControlViewModel.TraceFileDirVariable))
            {
                string outputDir = TraceControlViewModel.GetDirectoryNameFromFileName(TraceFileName);

                if (!Directory.Exists(outputDir))
                {
                    RootModel.MessageBoxDisplay.ShowMessage($"Error: Output directory {outputDir} does not exist", "Error");
                }
                else
                {
                    int newEtlFiles = Directory.GetFiles(outputDir, "*.etl").Select(x => new FileInfo(x)).Where(x => x.CreationTime > TraceStartTime).Count();

                    if (newEtlFiles == 0)
                    {
                        RootModel.MessageBoxDisplay.ShowMessage($"Error: No new etl files were created in directory {outputDir} since trace start!", "Error");
                    }
                }
            }
        }
        public void Can_Extract_Exe_Name_With_Quotation_Marks()
        {
            const string cmdLine = "\"C:\\program files\\wpa.exe\" -i c:\\temp\\otherfile.etl";
            string       exe     = TraceControlViewModel.ExtractExecName(cmdLine);

            Assert.AreEqual("\"C:\\program files\\wpa.exe\"", exe);
            Console.WriteLine($"ExeName: {exe}");
        }
示例#4
0
 /// <summary>
 /// Initialize the default values for the ViewModel and load the settings from disc.
 /// </summary>
 public ViewModel(IMessageBoxDisplay messageBoxDisplay)
 {
     MessageBoxDisplay    = messageBoxDisplay;
     LocalTraceSettings   = new TraceControlViewModel(this, false);
     ServerTraceSettings  = new TraceControlViewModel(this, true);
     _ReceivedMessages    = new ObservableCollection <string>();
     _ServerTraceSessions = new string[] { "Not yet read." };
     _TraceSessions       = new string[] { "Not yet read." };
     StatusMessages       = new ObservableCollection <StatusMessage>();
     LocalTraceControler  = new TraceControlerService();
     Commands             = CreateUICommands();
     LoadSettings();
     StatusMessages.CollectionChanged += StatusMessages_CollectionChanged;
 }
        public void CanExtractDirectoryWithPlaceholders()
        {
            string ret = TraceControlViewModel.GetDirectoryNameFromFileName(@"C:\temp\etlFile%COMPUTERNAME%.ETL");

            Assert.AreEqual(@"C:\temp", ret);
        }